mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-11-10 20:23:10 +00:00
New module: gunc run
(+ gunc downloaddb
) (#880)
* Specify more guidelines on input channels * Linting * Updates based on code review * Update README.md * Fix broken sentence * feat: add megahit module, currently decompressed output * Update main.nf * Update tests/modules/megahit/test.yml Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * feat: compress all outputs, remove md5sums due to gz stochasicity * fix: wrong conda channel for pigz * fix: broken singleend tests and update meta.yml * Missed one * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * fix: pigz formatting * Apply suggestions from code review Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> * Apply suggestions from code review * Add GUNC download_db and run commands * Bump with version without zgrep * Apply suggestions from code review Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com> * Harshil formatting * Apply suggestions from code review Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com> Co-authored-by: Robert A. Petit III <robbie.petit@gmail.com>
This commit is contained in:
parent
11226d9d98
commit
08b71fa85f
11 changed files with 380 additions and 0 deletions
78
modules/gunc/downloaddb/functions.nf
Normal file
78
modules/gunc/downloaddb/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"
|
||||||
|
}
|
||||||
|
}
|
37
modules/gunc/downloaddb/main.nf
Normal file
37
modules/gunc/downloaddb/main.nf
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process GUNC_DOWNLOADDB {
|
||||||
|
tag '$db_name'
|
||||||
|
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:[:], publish_by_meta:[]) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::gunc=1.0.5" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/gunc:1.0.5--pyhdfd78af_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/gunc:1.0.5--pyhdfd78af_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
val db_name
|
||||||
|
|
||||||
|
output:
|
||||||
|
path "*.dmnd" , emit: db
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
"""
|
||||||
|
gunc download_db . -db $db_name $options.args
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$( gunc --version )
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
36
modules/gunc/downloaddb/meta.yml
Normal file
36
modules/gunc/downloaddb/meta.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
name: gunc_downloaddb
|
||||||
|
description: Download database for GUNC detection of Chimerism and Contamination in Prokaryotic Genomes
|
||||||
|
keywords:
|
||||||
|
- download
|
||||||
|
- prokaryote
|
||||||
|
- assembly
|
||||||
|
- genome
|
||||||
|
- quality control
|
||||||
|
- chimeras
|
||||||
|
tools:
|
||||||
|
- gunc:
|
||||||
|
description: Python package for detection of chimerism and contamination in prokaryotic genomes.
|
||||||
|
homepage: https://grp-bork.embl-community.io/gunc/
|
||||||
|
documentation: https://grp-bork.embl-community.io/gunc/
|
||||||
|
tool_dev_url: https://github.com/grp-bork/gunc
|
||||||
|
doi: "10.1186/s13059-021-02393-0"
|
||||||
|
licence: ['GNU General Public v3 or later (GPL v3+)']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- db_name:
|
||||||
|
type: string
|
||||||
|
description: "Which database to download. Options: progenomes or gtdb"
|
||||||
|
pattern: "progenomes|gtdb"
|
||||||
|
|
||||||
|
output:
|
||||||
|
- versions:
|
||||||
|
type: file
|
||||||
|
description: File containing software versions
|
||||||
|
pattern: "versions.yml"
|
||||||
|
- db:
|
||||||
|
type: file
|
||||||
|
description: GUNC database file
|
||||||
|
pattern: "*.dmnd"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@jfy133"
|
78
modules/gunc/run/functions.nf
Normal file
78
modules/gunc/run/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"
|
||||||
|
}
|
||||||
|
}
|
45
modules/gunc/run/main.nf
Normal file
45
modules/gunc/run/main.nf
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process GUNC_RUN {
|
||||||
|
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::gunc=1.0.5" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/gunc:1.0.5--pyhdfd78af_0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/gunc:1.0.5--pyhdfd78af_0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(fasta)
|
||||||
|
path(db)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("*maxCSS_level.tsv") , emit: maxcss_level_tsv
|
||||||
|
tuple val(meta), path("*all_levels.tsv") , optional: true, emit: all_levels_tsv
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
"""
|
||||||
|
gunc \\
|
||||||
|
run \\
|
||||||
|
--input_fasta $fasta \\
|
||||||
|
--db_file $db \\
|
||||||
|
--threads $task.cpus \\
|
||||||
|
$options.args
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$( gunc --version )
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
53
modules/gunc/run/meta.yml
Normal file
53
modules/gunc/run/meta.yml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
name: gunc_run
|
||||||
|
description: Detection of Chimerism and Contamination in Prokaryotic Genomes
|
||||||
|
keywords:
|
||||||
|
- prokaryote
|
||||||
|
- assembly
|
||||||
|
- genome
|
||||||
|
- quality control
|
||||||
|
- chimeras
|
||||||
|
tools:
|
||||||
|
- gunc:
|
||||||
|
description: Python package for detection of chimerism and contamination in prokaryotic genomes.
|
||||||
|
homepage: https://grp-bork.embl-community.io/gunc/
|
||||||
|
documentation: https://grp-bork.embl-community.io/gunc/
|
||||||
|
tool_dev_url: https://github.com/grp-bork/gunc
|
||||||
|
doi: "10.1186/s13059-021-02393-0"
|
||||||
|
licence: ['GNU General Public v3 or later (GPL v3+)']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test', single_end:false ]
|
||||||
|
- fasta:
|
||||||
|
type: file
|
||||||
|
description: FASTA file containing contig (bins)
|
||||||
|
pattern: "*.fa"
|
||||||
|
- db:
|
||||||
|
type: file
|
||||||
|
description: GUNC database file
|
||||||
|
pattern: "*.dmnd"
|
||||||
|
|
||||||
|
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"
|
||||||
|
- maxcss_levels_tsv:
|
||||||
|
type: file
|
||||||
|
description: Output file with scores for a taxonomic level with the highest CSS score
|
||||||
|
pattern: "*.tsv"
|
||||||
|
- all_levels_tsv:
|
||||||
|
type: file
|
||||||
|
description: Optional output file with results for each taxonomic level
|
||||||
|
pattern: "*.tsv"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@jfy133"
|
|
@ -546,6 +546,14 @@ gubbins:
|
||||||
- modules/gubbins/**
|
- modules/gubbins/**
|
||||||
- tests/modules/gubbins/**
|
- tests/modules/gubbins/**
|
||||||
|
|
||||||
|
gunc/downloaddb:
|
||||||
|
- modules/gunc/downloaddb/**
|
||||||
|
- tests/modules/gunc/downloaddb/**
|
||||||
|
|
||||||
|
gunc/run:
|
||||||
|
- modules/gunc/run/**
|
||||||
|
- tests/modules/gunc/run/**
|
||||||
|
|
||||||
gunzip:
|
gunzip:
|
||||||
- modules/gunzip/**
|
- modules/gunzip/**
|
||||||
- tests/modules/gunzip/**
|
- tests/modules/gunzip/**
|
||||||
|
|
12
tests/modules/gunc/downloaddb/main.nf
Normal file
12
tests/modules/gunc/downloaddb/main.nf
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { GUNC_DOWNLOADDB } from '../../../../modules/gunc/downloaddb/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_gunc_downloaddb {
|
||||||
|
|
||||||
|
input = 'progenomes'
|
||||||
|
|
||||||
|
GUNC_DOWNLOADDB ( input )
|
||||||
|
}
|
8
tests/modules/gunc/downloaddb/test.yml
Normal file
8
tests/modules/gunc/downloaddb/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- name: gunc downloaddb
|
||||||
|
command: nextflow run ./tests/modules/gunc/downloaddb -entry test_gunc_downloaddb -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- gunc
|
||||||
|
- gunc/downloaddb
|
||||||
|
files:
|
||||||
|
- path: output/gunc/gunc_db_progenomes2.1.dmnd
|
||||||
|
md5sum: 447c9330056b02f29f30fe81fe4af4eb
|
17
tests/modules/gunc/run/main.nf
Normal file
17
tests/modules/gunc/run/main.nf
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { GUNC_RUN } from '../../../../modules/gunc/run/main.nf' addParams( options: [:] )
|
||||||
|
include { GUNC_DOWNLOADDB } from '../../../../modules/gunc/downloaddb/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
|
||||||
|
workflow test_gunc_run {
|
||||||
|
|
||||||
|
input = [ [ id:'test', single_end:false ], // meta map
|
||||||
|
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
GUNC_DOWNLOADDB('progenomes')
|
||||||
|
|
||||||
|
GUNC_RUN ( input, GUNC_DOWNLOADDB.out.db )
|
||||||
|
}
|
8
tests/modules/gunc/run/test.yml
Normal file
8
tests/modules/gunc/run/test.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
- name: gunc run
|
||||||
|
command: nextflow run ./tests/modules/gunc/run -entry test_gunc_run -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- gunc
|
||||||
|
- gunc/run
|
||||||
|
files:
|
||||||
|
- path: output/gunc/GUNC.progenomes_2.1.maxCSS_level.tsv
|
||||||
|
md5sum: 0420c1a9f2c50fefaee9fab5d80a551a
|
Loading…
Reference in a new issue