mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
New module: checkm/lineagewf
(#899)
* 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 * Added but test failing due to null on output channel * fix prefix variable * Complete checkm_lineagewf * Remove TODOs * Add description of fasta_ext parameter * Improve meta map for this context * Update meta.yml * Update modules/checkm/lineagewf/meta.yml Co-authored-by: James A. Fellows Yates <jfy133@gmail.com> * Update main.nf Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com> Co-authored-by: Daniel Lundin <erik.rikard.daniel@gmail.com>
This commit is contained in:
parent
2ad98162f3
commit
a740a6ff48
6 changed files with 249 additions and 1 deletions
78
modules/checkm/lineagewf/functions.nf
Normal file
78
modules/checkm/lineagewf/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"
|
||||
}
|
||||
}
|
49
modules/checkm/lineagewf/main.nf
Normal file
49
modules/checkm/lineagewf/main.nf
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Import generic module functions
|
||||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||
|
||||
params.options = [:]
|
||||
options = initOptions(params.options)
|
||||
|
||||
process CHECKM_LINEAGEWF {
|
||||
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::checkm-genome=1.1.3" : null)
|
||||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||
container "https://depot.galaxyproject.org/singularity/checkm-genome:1.1.3--py_1"
|
||||
} else {
|
||||
container "quay.io/biocontainers/checkm-genome:1.1.3--py_1"
|
||||
}
|
||||
|
||||
input:
|
||||
tuple val(meta), path(fasta)
|
||||
val fasta_ext
|
||||
|
||||
output:
|
||||
tuple val(meta), path("${prefix}") , emit: checkm_output
|
||||
tuple val(meta), path("${prefix}.tsv"), emit: checkm_tsv
|
||||
path "versions.yml" , emit: versions
|
||||
|
||||
script:
|
||||
prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||
"""
|
||||
checkm \\
|
||||
lineage_wf \\
|
||||
-t $task.cpus \\
|
||||
-f ${prefix}.tsv \\
|
||||
--tab_table \\
|
||||
--pplacer_threads $task.cpus \\
|
||||
-x $fasta_ext \\
|
||||
$options.args \\
|
||||
. \\
|
||||
$prefix
|
||||
|
||||
cat <<-END_VERSIONS > versions.yml
|
||||
${getProcessName(task.process)}:
|
||||
${getSoftwareName(task.process)}: \$( checkm 2>&1 | grep '...:::' | sed 's/.*CheckM v//;s/ .*//' )
|
||||
END_VERSIONS
|
||||
"""
|
||||
}
|
58
modules/checkm/lineagewf/meta.yml
Normal file
58
modules/checkm/lineagewf/meta.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
name: checkm_lineagewf
|
||||
description: CheckM provides a set of tools for assessing the quality of genomes recovered from isolates, single cells, or metagenomes.
|
||||
keywords:
|
||||
- checkm
|
||||
- mag
|
||||
- metagenome
|
||||
- quality
|
||||
- isolates
|
||||
- microbes
|
||||
- single cells
|
||||
- completeness
|
||||
- contamination
|
||||
- bins
|
||||
- genome bins
|
||||
tools:
|
||||
- checkm:
|
||||
description: Assess the quality of microbial genomes recovered from isolates, single cells, and metagenomes.
|
||||
homepage: https://ecogenomics.github.io/CheckM/
|
||||
documentation: https://github.com/Ecogenomics/CheckM/wiki
|
||||
tool_dev_url: https://github.com/Ecogenomics/CheckM
|
||||
doi: "10.1101/gr.186072.114"
|
||||
licence: ['GPL v3']
|
||||
|
||||
input:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'test', single_end:false ]
|
||||
- fasta:
|
||||
type: file
|
||||
description: One or a list of multiple FASTA files of each bin, with extension defined with the fasta_ext value
|
||||
pattern: "*.{$fasta_ext}"
|
||||
- fasta_ext:
|
||||
type: value
|
||||
description: The file-type extension suffix of the input FASTA files (e.g., fasta, fna, fa, fas)
|
||||
|
||||
output:
|
||||
- meta:
|
||||
type: map
|
||||
description: |
|
||||
Groovy Map containing sample information
|
||||
e.g. [ id:'sample', bin:'1' ]
|
||||
- versions:
|
||||
type: file
|
||||
description: File containing software versions
|
||||
pattern: "versions.yml"
|
||||
- checkm_output:
|
||||
type: directory
|
||||
description: CheckM output directory
|
||||
pattern: "*/"
|
||||
- checkm_tsv:
|
||||
type: file
|
||||
description: CheckM summary completeness statistics table
|
||||
pattern: "*.tsv"
|
||||
|
||||
authors:
|
||||
- "@jfy133"
|
|
@ -254,6 +254,10 @@ cat/fastq:
|
|||
- modules/cat/fastq/**
|
||||
- tests/modules/cat/fastq/**
|
||||
|
||||
checkm/lineagewf:
|
||||
- modules/checkm/lineagewf/**
|
||||
- tests/modules/checkm/lineagewf/**
|
||||
|
||||
chromap/chromap:
|
||||
- modules/chromap/chromap/**
|
||||
- tests/modules/chromap/chromap/**
|
||||
|
|
24
tests/modules/checkm/lineagewf/main.nf
Normal file
24
tests/modules/checkm/lineagewf/main.nf
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env nextflow
|
||||
|
||||
nextflow.enable.dsl = 2
|
||||
|
||||
include { CHECKM_LINEAGEWF } from '../../../../modules/checkm/lineagewf/main.nf' addParams( options: [:] )
|
||||
|
||||
workflow test_checkm_lineagewf {
|
||||
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true) ]
|
||||
fasta_ext = 'fasta'
|
||||
|
||||
CHECKM_LINEAGEWF ( input, fasta_ext )
|
||||
}
|
||||
|
||||
workflow test_checkm_lineagewf_multi {
|
||||
|
||||
input = [ [ id:'test', single_end:false ], // meta map
|
||||
[ file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true),
|
||||
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)] ]
|
||||
fasta_ext = 'fasta'
|
||||
|
||||
CHECKM_LINEAGEWF ( input, fasta_ext )
|
||||
}
|
35
tests/modules/checkm/lineagewf/test.yml
Normal file
35
tests/modules/checkm/lineagewf/test.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
- name: checkm lineagewf
|
||||
command: nextflow run ./tests/modules/checkm/lineagewf -entry test_checkm_lineagewf -c tests/config/nextflow.config
|
||||
tags:
|
||||
- checkm
|
||||
- checkm/lineagewf
|
||||
files:
|
||||
- path: output/checkm/test.tsv
|
||||
md5sum: d5559764f563c4b55223e4e4a3dc1ec9
|
||||
- path: output/checkm/test/checkm.log
|
||||
contains:
|
||||
- "INFO: Parsing HMM hits to marker genes:"
|
||||
- path: output/checkm/test/lineage.ms
|
||||
contains:
|
||||
- "# [Lineage Marker File]"
|
||||
- "contigs"
|
||||
- "UID1"
|
||||
|
||||
- name: checkm lineagewf_multi
|
||||
command: nextflow run ./tests/modules/checkm/lineagewf -entry test_checkm_lineagewf_multi -c tests/config/nextflow.config
|
||||
tags:
|
||||
- checkm
|
||||
- checkm/lineagewf
|
||||
files:
|
||||
- path: output/checkm/test.tsv
|
||||
md5sum: 7e0fa177dcf151b84b7751813fbde3d1
|
||||
- path: output/checkm/test/checkm.log
|
||||
contains:
|
||||
- "INFO: Parsing HMM hits to marker genes:"
|
||||
- path: output/checkm/test/lineage.ms
|
||||
contains:
|
||||
- "# [Lineage Marker File]"
|
||||
- "contigs"
|
||||
- "UID1"
|
||||
- "genome"
|
||||
|
Loading…
Reference in a new issue