mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
New module: bamtools/split
(#798)
* 👌 IMPROVE: Add some pacbio test files * 🐛 FIX: Add Pacbio index to test_data.config * 👌 IMPROVE: Re add 10000 data test * 👌 IMPROVE: Add some pbindex * 🐛 FIX: Add pbi extension to files * 📦 NEW: Add galgal6 chr30 test data * 📦 NEW: Add bamtools module * 👌 IMPROVE: Ignore test data * 👌 IMPROVE: Update to last templates version * 👌 IMPROVE: Update module to last template version * 👌 IMPROVE: Update module to last template version * 👌 IMPROVE: Final version of test datasets config * 👌 IMPROVE: Remove useless index + Fix Typos * 👌 IMPROVE: Add some pacbio test files * 🐛 FIX: Add Pacbio index to test_data.config * 👌 IMPROVE: Re add 10000 data test * 👌 IMPROVE: Add some pbindex * 🐛 FIX: Add pbi extension to files * 📦 NEW: Add galgal6 chr30 test data * 📦 NEW: Add bamtools module * 👌 IMPROVE: Ignore test data * 👌 IMPROVE: Update to last templates version * 👌 IMPROVE: Update module to last template version * 👌 IMPROVE: Update module to last template version * 👌 IMPROVE: Final version of test datasets config * 👌 IMPROVE: Remove useless index + Fix Typos * 👌 IMPROVE: Update with new versions.yml file * 🐛 FIX: Update meta.yml + correct typos * Update modules/bamtools/split/meta.yml Add bam, split, chunk tags Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * 🐛 FIX: Correct meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
This commit is contained in:
parent
194e598a34
commit
3a4935d21b
6 changed files with 192 additions and 0 deletions
78
modules/bamtools/split/functions.nf
Normal file
78
modules/bamtools/split/functions.nf
Normal file
|
@ -0,0 +1,78 @@
|
|||
//
|
||||
// Utility functions used in nf-core DSL2 module files
|
||||
//
|
||||
|
||||
//
|
||||
// Extract name of software tool from process name using $task.process
|
||||
//
|
||||
def getSoftwareName(task_process) {
|
||||
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
|
||||
}
|
||||
|
||||
//
|
||||
// Extract name of module from process name using $task.process
|
||||
//
|
||||
def getProcessName(task_process) {
|
||||
return task_process.tokenize(':')[-1]
|
||||
}
|
||||
|
||||
//
|
||||
// Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
|
||||
//
|
||||
def initOptions(Map args) {
|
||||
def Map options = [:]
|
||||
options.args = args.args ?: ''
|
||||
options.args2 = args.args2 ?: ''
|
||||
options.args3 = args.args3 ?: ''
|
||||
options.publish_by_meta = args.publish_by_meta ?: []
|
||||
options.publish_dir = args.publish_dir ?: ''
|
||||
options.publish_files = args.publish_files
|
||||
options.suffix = args.suffix ?: ''
|
||||
return options
|
||||
}
|
||||
|
||||
//
|
||||
// Tidy up and join elements of a list to return a path string
|
||||
//
|
||||
def getPathFromList(path_list) {
|
||||
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
|
||||
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes
|
||||
return paths.join('/')
|
||||
}
|
||||
|
||||
//
|
||||
// Function to save/publish module results
|
||||
//
|
||||
def saveFiles(Map args) {
|
||||
def ioptions = initOptions(args.options)
|
||||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||
|
||||
// Do not publish versions.yml unless running from pytest workflow
|
||||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) {
|
||||
return null
|
||||
}
|
||||
if (ioptions.publish_by_meta) {
|
||||
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta
|
||||
for (key in key_list) {
|
||||
if (args.meta && key instanceof String) {
|
||||
def path = key
|
||||
if (args.meta.containsKey(key)) {
|
||||
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key]
|
||||
}
|
||||
path = path instanceof String ? path : ''
|
||||
path_list.add(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ioptions.publish_files instanceof Map) {
|
||||
for (ext in ioptions.publish_files) {
|
||||
if (args.filename.endsWith(ext.key)) {
|
||||
def ext_list = path_list.collect()
|
||||
ext_list.add(ext.value)
|
||||
return "${getPathFromList(ext_list)}/$args.filename"
|
||||
}
|
||||
}
|
||||
} else if (ioptions.publish_files == null) {
|
||||
return "${getPathFromList(path_list)}/$args.filename"
|
||||
}
|
||||
}
|
41
modules/bamtools/split/main.nf
Normal file
41
modules/bamtools/split/main.nf
Normal file
|
@ -0,0 +1,41 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process BAMTOOLS_SPLIT {
|
||||
tag "$meta.id"
|
||||
label 'process_low'
|
||||
publishDir "${params.outdir}",
|
||||
mode: params.publish_dir_mode,
|
||||
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
|
||||
|
||||
conda (params.enable_conda ? "bioconda::bamtools=2.5.1" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/bamtools:2.5.1--h9a82719_9"
|
||||
} else {
|
||||
container "quay.io/biocontainers/bamtools:2.5.1--h9a82719_9"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(bam)
|
||||
|
||||
output:
|
||||
tuple val(meta), path("*.bam"), emit: bam
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
bamtools \\
|
||||
split \\
|
||||
-in $bam \\
|
||||
$options.args
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
bamtools: \$( bamtools --version | grep -e 'bamtools' | sed 's/^.*bamtools //' )
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
45
modules/bamtools/split/meta.yml
Normal file
45
modules/bamtools/split/meta.yml
Normal file
|
@ -0,0 +1,45 @@
|
|||
name: bamtools_split
|
||||
description: BamTools provides both a programmer's API and an end-user's toolkit for handling BAM files.
|
||||
keywords:
|
||||
- bamtools
|
||||
- bamtools/split
|
||||
- bam
|
||||
- split
|
||||
- chunk
|
||||
tools:
|
||||
- bamtools:
|
||||
description: C++ API & command-line toolkit for working with BAM data
|
||||
homepage: http://github.com/pezmaster31/bamtools
|
||||
documentation: https://github.com/pezmaster31/bamtools/wiki
|
||||
tool_dev_url: http://github.com/pezmaster31/bamtools
|
||||
doi: ""
|
||||
licence: ['MIT']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- bam:
|
||||
type: file
|
||||
description: A BAM file to split
|
||||
pattern: "*.bam"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
- bam:
|
||||
type: file
|
||||
description: Several Bam files
|
||||
pattern: "*.bam"
|
||||
|
||||
authors:
|
||||
- "@sguizard"
|
|
@ -34,6 +34,10 @@ bamaligncleaner:
|
|||
- modules/bamaligncleaner/**
|
||||
- tests/modules/bamaligncleaner/**
|
||||
|
||||
bamtools/split:
|
||||
- modules/bamtools/split/**
|
||||
- tests/modules/bamtools/split/**
|
||||
|
||||
bandage/image:
|
||||
- modules/bandage/image/**
|
||||
- tests/modules/bandage/image/**
|
||||
|
|
14
tests/modules/bamtools/split/main.nf
Normal file
14
tests/modules/bamtools/split/main.nf
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { BAMTOOLS_SPLIT } from '../../../../modules/bamtools/split/main.nf' addParams( options: [args:"-reference"] )
|
||||
|
||||
workflow test_bamtools_split {
|
||||
|
||||
input = [
|
||||
[ id:'test', single_end:false ], // meta map
|
||||
file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
|
||||
|
||||
BAMTOOLS_SPLIT ( input )
|
||||
}
|
10
tests/modules/bamtools/split/test.yml
Normal file
10
tests/modules/bamtools/split/test.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
- name: bamtools split test_bamtools_split
|
||||
command: nextflow run tests/modules/bamtools/split -entry test_bamtools_split -c tests/config/nextflow.config
|
||||
tags:
|
||||
- bamtools
|
||||
- bamtools/split
|
||||
files:
|
||||
- path: output/bamtools/test.paired_end.sorted.REF_chr22:16570000-16610000.bam
|
||||
md5sum: 256535b9a3ab5864be0f7dea2218d159
|
||||
- path: output/bamtools/test.paired_end.sorted.REF_unmapped.bam
|
||||
md5sum: 568e058d871d8bc319330360bcae4e43
|
Loading…
Reference in a new issue