nf-core_modules/modules/megahit/main.nf
James A. Fellows Yates 359f721cc9
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>
2021-10-12 16:06:06 +01:00

76 lines
2.9 KiB
Text

// 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
"""
}
}