mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
Add phyloflash module (#786)
* initial stubs [ci skip] * remove comments and add main command [ci skip] * design iteration [ci skip] * add new standard functions.nf [ci skip] * update the version string [ci skip] * accomodate the db stubs and single/double ends [ci skip] * add FIXME for missing info [ci skip] * Accomodate the results folder [ci skip] * Update main.nf * Apply suggestions from code review * Update main.nf * Apply suggestions from code review * Add version file to stubs [ci skip] * Tweak the output dir pattern [ci skip] * Update modules/phyloflash/main.nf * Update modules/phyloflash/main.nf * Update modules/phyloflash/main.nf Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: FriederikeHanssen <Friederike.hanssen@qbic.uni-tuebingen.de>
This commit is contained in:
parent
c25c3fe466
commit
15fd90ffe8
6 changed files with 277 additions and 0 deletions
78
modules/phyloflash/functions.nf
Normal file
78
modules/phyloflash/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"
|
||||
}
|
||||
}
|
85
modules/phyloflash/main.nf
Normal file
85
modules/phyloflash/main.nf
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process PHYLOFLASH {
|
||||
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::phyloflash=3.4" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/phyloflash:3.4--hdfd78af_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/phyloflash:3.4--hdfd78af_1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(reads)
|
||||
path silva_db
|
||||
path univec_db
|
||||
|
||||
output:
|
||||
tuple val(meta), path("${meta.id}*/*"), emit: results
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
|
||||
if (meta.single_end) {
|
||||
"""
|
||||
phyloFlash.pl \\
|
||||
$options.args \\
|
||||
-read1 ${reads[0]} \\
|
||||
-lib $prefix \\
|
||||
-interleaved \\
|
||||
-dbhome . \\
|
||||
-CPUs $task.cpus
|
||||
|
||||
mkdir $prefix
|
||||
mv ${prefix}.* $prefix
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$(echo \$(phyloFlash.pl -version 2>&1) | sed "s/^.*phyloFlash v//")
|
||||
END_VERSIONS
|
||||
"""
|
||||
} else {
|
||||
"""
|
||||
phyloFlash.pl \\
|
||||
$options.args \\
|
||||
-read1 ${reads[0]} \\
|
||||
-read2 ${reads[1]} \\
|
||||
-lib $prefix \\
|
||||
-dbhome . \\
|
||||
-CPUs $task.cpus
|
||||
|
||||
mkdir $prefix
|
||||
mv ${prefix}.* $prefix
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$(echo \$(phyloFlash.pl -version 2>&1) | sed "s/^.*phyloFlash v//")
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
||||
|
||||
stub:
|
||||
|
||||
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
|
||||
"""
|
||||
mkdir ${prefix}
|
||||
touch ${prefix}/${prefix}.SSU.collection.fasta
|
||||
touch ${prefix}/${prefix}.phyloFlash
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$(echo \$(phyloFlash.pl -version 2>&1) | sed "s/^.*phyloFlash v//")
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
51
modules/phyloflash/meta.yml
Normal file
51
modules/phyloflash/meta.yml
Normal file
|
@ -0,0 +1,51 @@
|
|||
name: phyloflash
|
||||
description: phyloFlash is a pipeline to rapidly reconstruct the SSU rRNAs and explore phylogenetic composition of an illumina (meta)genomic dataset.
|
||||
keywords:
|
||||
- metagenomics
|
||||
- illumina datasets
|
||||
- phylogenetic composition
|
||||
tools:
|
||||
- phyloflash:
|
||||
description: phyloFlash is a pipeline to rapidly reconstruct the SSU rRNAs and explore phylogenetic composition of an illumina (meta)genomic dataset.
|
||||
|
||||
homepage: https://hrgv.github.io/phyloFlash/
|
||||
documentation: https://hrgv.github.io/phyloFlash/usage.html
|
||||
tool_dev_url: https://github.com/HRGV/phyloFlash
|
||||
doi: "10.1128/mSystems.00920-20"
|
||||
licence: ['GPL v3']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- reads:
|
||||
type: file
|
||||
description: Channel containing single or paired-end reads
|
||||
pattern: "*.{fastq.gz,fq.gz}"
|
||||
- sliva_db:
|
||||
type: folder
|
||||
description: Folder containing the SILVA database
|
||||
pattern: "ref"
|
||||
- univec_db:
|
||||
type: folder
|
||||
description: Folder containing UniVec database
|
||||
pattern: "UniVec"
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- results:
|
||||
type: folder
|
||||
description: Folder containing the results of phyloFlash analysis
|
||||
pattern: "${prefix}*"
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
authors:
|
||||
- "@abhi18av"
|
|
@ -1011,6 +1011,10 @@ pbccs:
|
|||
- modules/pbccs/**
|
||||
- tests/modules/pbccs/**
|
||||
|
||||
phyloflash:
|
||||
- modules/phyloflash/**
|
||||
- tests/modules/phyloflash/**
|
||||
|
||||
picard/collecthsmetrics:
|
||||
- modules/picard/collecthsmetrics/**
|
||||
- tests/modules/picard/collecthsmetrics/**
|
||||
|
|
44
tests/modules/phyloflash/main.nf
Normal file
44
tests/modules/phyloflash/main.nf
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { PHYLOFLASH } from '../../../modules/phyloflash/main.nf' addParams( options: [:] )
|
||||
|
||||
process STUB_PHYLOFLASH_DATABASE {
|
||||
output:
|
||||
path "ref" , emit: silva_db
|
||||
path "UniVec" , emit: univec_db
|
||||
|
||||
stub:
|
||||
"""
|
||||
mkdir ref
|
||||
touch UniVec
|
||||
"""
|
||||
}
|
||||
|
||||
workflow test_phyloflash_single_end {
|
||||
|
||||
STUB_PHYLOFLASH_DATABASE ()
|
||||
|
||||
input = [
|
||||
[ id:'test', single_end:true ], // meta map
|
||||
[ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ]
|
||||
]
|
||||
|
||||
PHYLOFLASH ( input, STUB_PHYLOFLASH_DATABASE.out.silva_db, STUB_PHYLOFLASH_DATABASE.out.univec_db )
|
||||
}
|
||||
|
||||
workflow test_phyloflash_paired_end {
|
||||
|
||||
STUB_PHYLOFLASH_DATABASE ()
|
||||
|
||||
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)
|
||||
]
|
||||
]
|
||||
|
||||
PHYLOFLASH ( input, STUB_PHYLOFLASH_DATABASE.out.silva_db, STUB_PHYLOFLASH_DATABASE.out.univec_db )
|
||||
}
|
15
tests/modules/phyloflash/test.yml
Normal file
15
tests/modules/phyloflash/test.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
- name: phyloflash single-end
|
||||
command: nextflow run ./tests/modules/phyloflash -entry test_phyloflash_single_end -c tests/config/nextflow.config -stub-run
|
||||
tags:
|
||||
- phyloflash
|
||||
files:
|
||||
- path: output/phyloflash/test/test.SSU.collection.fasta
|
||||
md5sum: d41d8cd98f00b204e9800998ecf8427e
|
||||
|
||||
- name: phyloflash paired-end
|
||||
command: nextflow run ./tests/modules/phyloflash -entry test_phyloflash_paired_end -c tests/config/nextflow.config -stub-run
|
||||
tags:
|
||||
- phyloflash
|
||||
files:
|
||||
- path: output/phyloflash/test/test.SSU.collection.fasta
|
||||
md5sum: d41d8cd98f00b204e9800998ecf8427e
|
Loading…
Reference in a new issue