mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2025-01-04 21:42:08 -05:00
Bbmap/bbduk (#487)
* bbmap/bbduk module created * created bbmap/bbduk module * updated main.nf * changed test.yml tags * removed whitespaces * Adjusted main.nf spacing * whitespace, tags * fix optional files, tags, tidy code * fix suffix * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
12ebce50f7
commit
1f465a63d0
6 changed files with 265 additions and 0 deletions
70
software/bbmap/bbduk/functions.nf
Normal file
70
software/bbmap/bbduk/functions.nf
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* -----------------------------------------------------
|
||||||
|
* 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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) {
|
||||||
|
if (!args.filename.endsWith('.version.txt')) {
|
||||||
|
def ioptions = initOptions(args.options)
|
||||||
|
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
47
software/bbmap/bbduk/main.nf
Normal file
47
software/bbmap/bbduk/main.nf
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process BBMAP_BBDUK {
|
||||||
|
tag "$meta.id"
|
||||||
|
label 'process_medium'
|
||||||
|
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::bbmap=38.90" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/bbmap:38.90--he522d1c_1"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/bbmap:38.90--he522d1c_1"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(reads)
|
||||||
|
path contaminants
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path('*.fastq.gz'), emit: reads
|
||||||
|
tuple val(meta), path('*.log') , emit: log
|
||||||
|
path '*.version.txt' , emit: version
|
||||||
|
|
||||||
|
script:
|
||||||
|
def software = getSoftwareName(task.process)
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
def raw = meta.single_end ? "in=${reads[0]}" : "in1=${reads[0]} in2=${reads[1]}"
|
||||||
|
def trimmed = meta.single_end ? "out=${prefix}.fastq.gz" : "out1=${prefix}_1.fastq.gz out2=${prefix}_2.fastq.gz"
|
||||||
|
def contaminants_fa = contaminants ? "ref=$contaminants" : ''
|
||||||
|
"""
|
||||||
|
maxmem=\$(echo \"$task.memory\"| sed 's/ GB/g/g')
|
||||||
|
bbduk.sh \\
|
||||||
|
-Xmx\$maxmem \\
|
||||||
|
$raw \\
|
||||||
|
$trimmed \\
|
||||||
|
threads=$task.cpus \\
|
||||||
|
$options.args \\
|
||||||
|
$contaminants_fa \\
|
||||||
|
&> ${prefix}.bbduk.log
|
||||||
|
echo \$(bbversion.sh) > ${software}.version.txt
|
||||||
|
"""
|
||||||
|
}
|
52
software/bbmap/bbduk/meta.yml
Normal file
52
software/bbmap/bbduk/meta.yml
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
name: bbmap_bbduk
|
||||||
|
description: Adapter and quality trimming of sequencing reads
|
||||||
|
keywords:
|
||||||
|
- trimming
|
||||||
|
- adapter trimming
|
||||||
|
- quality trimming
|
||||||
|
tools:
|
||||||
|
- bbmap:
|
||||||
|
description: BBMap is a short read aligner, as well as various other bioinformatic tools.
|
||||||
|
homepage: https://jgi.doe.gov/data-and-tools/bbtools/bb-tools-user-guide/
|
||||||
|
documentation: https://jgi.doe.gov/data-and-tools/bbtools/bb-tools-user-guide/
|
||||||
|
tool_dev_url: None
|
||||||
|
doi: ""
|
||||||
|
licence: ['UC-LBL license (see package)']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- reads:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
List of input FastQ files of size 1 and 2 for single-end and paired-end data,
|
||||||
|
respectively.
|
||||||
|
- contaminants:
|
||||||
|
type: file
|
||||||
|
description: |
|
||||||
|
Reference files containing adapter and/or contaminant sequences for sequence kmer matching
|
||||||
|
|
||||||
|
output:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- reads:
|
||||||
|
type: file
|
||||||
|
description: The trimmed/modified fastq reads
|
||||||
|
pattern: "*fastq.gz"
|
||||||
|
- version:
|
||||||
|
type: file
|
||||||
|
description: File containing software version
|
||||||
|
pattern: "*.{version.txt}"
|
||||||
|
- log:
|
||||||
|
type: file
|
||||||
|
description: Bbduk log file
|
||||||
|
pattern: "*bbduk.log"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@MGordon09"
|
|
@ -22,6 +22,10 @@ bandage/image:
|
||||||
- software/bandage/image/**
|
- software/bandage/image/**
|
||||||
- tests/software/bandage/image/**
|
- tests/software/bandage/image/**
|
||||||
|
|
||||||
|
bbmap/bbduk:
|
||||||
|
- software/bbmap/bbduk/**
|
||||||
|
- tests/software/bbmap/bbduk/**
|
||||||
|
|
||||||
bcftools/consensus:
|
bcftools/consensus:
|
||||||
- software/bcftools/consensus/**
|
- software/bcftools/consensus/**
|
||||||
- tests/software/bcftools/consensus/**
|
- tests/software/bcftools/consensus/**
|
||||||
|
|
45
tests/software/bbmap/bbduk/main.nf
Normal file
45
tests/software/bbmap/bbduk/main.nf
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { BBMAP_BBDUK } from '../../../../software/bbmap/bbduk/main.nf' addParams( options: [ 'args' : 'trimq=10 qtrim=r', 'suffix' : '.trim' ] )
|
||||||
|
|
||||||
|
workflow test_bbmap_bbduk_single_end {
|
||||||
|
|
||||||
|
input = [ [ id:'test', single_end:true ], // meta map
|
||||||
|
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ]
|
||||||
|
]
|
||||||
|
|
||||||
|
BBMAP_BBDUK ( input, [] )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_bbmap_bbduk_paired_end {
|
||||||
|
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]
|
||||||
|
]
|
||||||
|
|
||||||
|
BBMAP_BBDUK ( input, [] )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_bbmap_bbduk_se_ref {
|
||||||
|
|
||||||
|
input = [ [ id:'test', single_end:true ], // meta map
|
||||||
|
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ]
|
||||||
|
]
|
||||||
|
contaminants = [file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) ] // transciptome file - remove contaminants (*trim.fastq files empty)
|
||||||
|
|
||||||
|
BBMAP_BBDUK ( input, contaminants )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_bbmap_bbduk_pe_ref {
|
||||||
|
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]
|
||||||
|
]
|
||||||
|
contaminants = [file(params.test_data['sarscov2']['genome']['transcriptome_fasta'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
BBMAP_BBDUK ( input, contaminants )
|
||||||
|
}
|
47
tests/software/bbmap/bbduk/test.yml
Normal file
47
tests/software/bbmap/bbduk/test.yml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
- name: bbmap bbduk test_bbmap_bbduk_single_end
|
||||||
|
command: nextflow run tests/software/bbmap/bbduk -entry test_bbmap_bbduk_single_end -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- bbmap/bbduk
|
||||||
|
files:
|
||||||
|
- path: output/bbmap/test.trim.bbduk.log
|
||||||
|
contains:
|
||||||
|
- "Input is being processed as unpaired"
|
||||||
|
- path: output/bbmap/test.trim.fastq.gz
|
||||||
|
md5sum: a87d0cbd5ced7df8bf1751e4cb407482
|
||||||
|
|
||||||
|
- name: bbmap bbduk test_bbmap_bbduk_paired_end
|
||||||
|
command: nextflow run tests/software/bbmap/bbduk -entry test_bbmap_bbduk_paired_end -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- bbmap/bbduk
|
||||||
|
files:
|
||||||
|
- path: output/bbmap/test.trim.bbduk.log
|
||||||
|
contains:
|
||||||
|
- "Input is being processed as paired"
|
||||||
|
- path: output/bbmap/test.trim_1.fastq.gz
|
||||||
|
md5sum: a87d0cbd5ced7df8bf1751e4cb407482
|
||||||
|
- path: output/bbmap/test.trim_2.fastq.gz
|
||||||
|
md5sum: 406e068fbe198f02b48e7e210cc0c69f
|
||||||
|
|
||||||
|
- name: bbmap bbduk test_bbmap_bbduk_se_ref
|
||||||
|
command: nextflow run tests/software/bbmap/bbduk -entry test_bbmap_bbduk_se_ref -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- bbmap/bbduk
|
||||||
|
files:
|
||||||
|
- path: output/bbmap/test.trim.bbduk.log
|
||||||
|
contains:
|
||||||
|
- "Input is being processed as unpaired"
|
||||||
|
- path: output/bbmap/test.trim.fastq.gz
|
||||||
|
md5sum: 3970e82605c7d109bb348fc94e9eecc0
|
||||||
|
|
||||||
|
- name: bbmap bbduk test_bbmap_bbduk_pe_ref
|
||||||
|
command: nextflow run tests/software/bbmap/bbduk -entry test_bbmap_bbduk_pe_ref -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- bbmap/bbduk
|
||||||
|
files:
|
||||||
|
- path: output/bbmap/test.trim.bbduk.log
|
||||||
|
contains:
|
||||||
|
- "Input is being processed as paired"
|
||||||
|
- path: output/bbmap/test.trim_1.fastq.gz
|
||||||
|
md5sum: 3970e82605c7d109bb348fc94e9eecc0
|
||||||
|
- path: output/bbmap/test.trim_2.fastq.gz
|
||||||
|
md5sum: 3970e82605c7d109bb348fc94e9eecc0
|
Loading…
Reference in a new issue