mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
Add MEGAHIT (#810)
* 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 Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com> Co-authored-by: Maxime Borry <maxibor@users.noreply.github.com>
This commit is contained in:
parent
de997825de
commit
359f721cc9
6 changed files with 319 additions and 0 deletions
78
modules/megahit/functions.nf
Normal file
78
modules/megahit/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"
|
||||||
|
}
|
||||||
|
}
|
76
modules/megahit/main.nf
Normal file
76
modules/megahit/main.nf
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process MEGAHIT {
|
||||||
|
tag "$meta.id"
|
||||||
|
label 'process_high'
|
||||||
|
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::megahit=1.2.9 conda-forge::pigz=2.6" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/mulled-v2-0f92c152b180c7cd39d9b0e6822f8c89ccb59c99:8ec213d21e5d03f9db54898a2baeaf8ec729b447-0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/mulled-v2-0f92c152b180c7cd39d9b0e6822f8c89ccb59c99:8ec213d21e5d03f9db54898a2baeaf8ec729b447-0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(reads)
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path("megahit_out/*.contigs.fa.gz") , emit: contigs
|
||||||
|
tuple val(meta), path("megahit_out/intermediate_contigs/k*.contigs.fa.gz") , emit: k_contigs
|
||||||
|
tuple val(meta), path("megahit_out/intermediate_contigs/k*.addi.fa.gz") , emit: addi_contigs
|
||||||
|
tuple val(meta), path("megahit_out/intermediate_contigs/k*.local.fa.gz") , emit: local_contigs
|
||||||
|
tuple val(meta), path("megahit_out/intermediate_contigs/k*.final.contigs.fa.gz"), emit: kfinal_contigs
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
if (meta.single_end) {
|
||||||
|
"""
|
||||||
|
megahit \\
|
||||||
|
-r ${reads} \\
|
||||||
|
-t $task.cpus \\
|
||||||
|
$options.args \\
|
||||||
|
--out-prefix $prefix
|
||||||
|
|
||||||
|
pigz \\
|
||||||
|
--no-name \\
|
||||||
|
-p $task.cpus \\
|
||||||
|
$options.args2 \\
|
||||||
|
megahit_out/*.fa \\
|
||||||
|
megahit_out/intermediate_contigs/*.fa
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$(echo \$(megahit -v 2>&1) | sed 's/MEGAHIT v//')
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
} else {
|
||||||
|
"""
|
||||||
|
megahit \\
|
||||||
|
-1 ${reads[0]} \\
|
||||||
|
-2 ${reads[1]} \\
|
||||||
|
-t $task.cpus \\
|
||||||
|
$options.args \\
|
||||||
|
--out-prefix $prefix
|
||||||
|
|
||||||
|
pigz \\
|
||||||
|
--no-name \\
|
||||||
|
-p $task.cpus \\
|
||||||
|
$options.args2 \\
|
||||||
|
megahit_out/*.fa \\
|
||||||
|
megahit_out/intermediate_contigs/*.fa
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$(echo \$(megahit -v 2>&1) | sed 's/MEGAHIT v//')
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
62
modules/megahit/meta.yml
Normal file
62
modules/megahit/meta.yml
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
name: megahit
|
||||||
|
description: An ultra-fast metagenomic assembler for large and complex metagenomics
|
||||||
|
keywords:
|
||||||
|
- megahit
|
||||||
|
- denovo
|
||||||
|
- assembly
|
||||||
|
- debruijn
|
||||||
|
- metagenomics
|
||||||
|
tools:
|
||||||
|
- megahit:
|
||||||
|
description: "An ultra-fast single-node solution for large and complex metagenomics assembly via succinct de Bruijn graph"
|
||||||
|
homepage: https://github.com/voutcn/megahit
|
||||||
|
documentation: https://github.com/voutcn/megahit
|
||||||
|
tool_dev_url: https://github.com/voutcn/megahit
|
||||||
|
doi: "10.1093/bioinformatics/btv033"
|
||||||
|
licence: ['GPL v3']
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information and input single, or paired-end FASTA/FASTQ files (optionally decompressed)
|
||||||
|
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 in gzipped or uncompressed FASTQ or FASTA format.
|
||||||
|
|
||||||
|
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"
|
||||||
|
- contigs:
|
||||||
|
type: file
|
||||||
|
description: Final final contigs result of the assembly in FASTA format.
|
||||||
|
pattern: "*.contigs.fa.gz"
|
||||||
|
- k_contigs:
|
||||||
|
type: file
|
||||||
|
description: Contigs assembled from the de Bruijn graph of order-K
|
||||||
|
pattern: "k*.contigs.fa.gz"
|
||||||
|
- addi_contigs:
|
||||||
|
type: file
|
||||||
|
description: Contigs assembled after iteratively removing local low coverage unitigs in the de Bruijn graph of order-K
|
||||||
|
pattern: "k*.addi.fa.gz"
|
||||||
|
- local_contigs:
|
||||||
|
type: file
|
||||||
|
description: Contigs of the locally assembled contigs for k=K
|
||||||
|
pattern: "k*.local.fa.gz"
|
||||||
|
- kfinal_contigs:
|
||||||
|
type: file
|
||||||
|
description: Stand-alone contigs for k=K; if local assembly is turned on, the file will be empty
|
||||||
|
pattern: "k*.final.contigs.fa.gz"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@jfy133"
|
|
@ -650,6 +650,10 @@ mashtree:
|
||||||
- modules/mashtree/**
|
- modules/mashtree/**
|
||||||
- tests/modules/mashtree/**
|
- tests/modules/mashtree/**
|
||||||
|
|
||||||
|
megahit:
|
||||||
|
- modules/megahit/**
|
||||||
|
- tests/modules/megahit/**
|
||||||
|
|
||||||
metaphlan3:
|
metaphlan3:
|
||||||
- modules/metaphlan3/**
|
- modules/metaphlan3/**
|
||||||
- tests/modules/metaphlan3/**
|
- tests/modules/metaphlan3/**
|
||||||
|
|
28
tests/modules/megahit/main.nf
Normal file
28
tests/modules/megahit/main.nf
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { MEGAHIT } from '../../../modules/megahit/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_megahit {
|
||||||
|
|
||||||
|
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)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
MEGAHIT ( input )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_megahit_single {
|
||||||
|
|
||||||
|
input = [
|
||||||
|
[ id:'test', single_end:true ], // meta map
|
||||||
|
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true)
|
||||||
|
]
|
||||||
|
|
||||||
|
MEGAHIT ( input )
|
||||||
|
}
|
71
tests/modules/megahit/test.yml
Normal file
71
tests/modules/megahit/test.yml
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
- name: megahit
|
||||||
|
command: nextflow run ./tests/modules/megahit -entry test_megahit -c tests/config/nextflow.config -process.cpus 1
|
||||||
|
tags:
|
||||||
|
- megahit
|
||||||
|
files:
|
||||||
|
- path: output/megahit/megahit_out/test.contigs.fa.gz
|
||||||
|
md5sum: 8ed114f22130e16df3532d3f6b03e116
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.contigs.fa.gz
|
||||||
|
md5sum: 4221d45f238045bbdb1eea04e4ce4261
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.local.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.contigs.fa.gz
|
||||||
|
md5sum: c72aeb242788542af0260098b4d61204
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.local.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.contigs.fa.gz
|
||||||
|
md5sum: aa188f4c92e69c1a4b396e8f2991236f
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.local.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
|
||||||
|
- name: megahit_single
|
||||||
|
command: nextflow run ./tests/modules/megahit -entry test_megahit_single -c tests/config/nextflow.config -process.cpus 1
|
||||||
|
tags:
|
||||||
|
- megahit
|
||||||
|
files:
|
||||||
|
- path: output/megahit/megahit_out/test.contigs.fa.gz
|
||||||
|
md5sum: f50352838b778cc67824f631197a8346
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.contigs.fa.gz
|
||||||
|
md5sum: 61554dc60ba8e95d9c1d9dca8d465bef
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k21.local.fa.gz
|
||||||
|
md5sum: b916fc620fdf0d23ef33485352c168b3
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.contigs.fa.gz
|
||||||
|
md5sum: d916bc564854aa0fabaa5234035aa47b
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k29.local.fa.gz
|
||||||
|
md5sum: cccf44441e65913b02fb64eb0835dcc1
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.contigs.fa.gz
|
||||||
|
md5sum: 4416a9e846ccbeb06b880ac2fdc02925
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k39.local.fa.gz
|
||||||
|
md5sum: 590d0a08285226d24f7f984f7b3b4f65
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k59.addi.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k59.contigs.fa.gz
|
||||||
|
md5sum: 51ef726b87a53b0cbdde762d7973a8a7
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k59.final.contigs.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
||||||
|
- path: output/megahit/megahit_out/intermediate_contigs/k59.local.fa.gz
|
||||||
|
md5sum: 7029066c27ac6f5ef18d660d5741979a
|
Loading…
Reference in a new issue