Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4557 new module kaijumergeoutputs + stub Kraken2/Kraken2 #5249

Merged
9 changes: 9 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "kaiju_mergeoutputs"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::kaiju=1.10.0"
53 changes: 53 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
process KAIJU_MERGEOUTPUTS {
tag "$meta.id"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/kaiju:1.10.0--h43eeafb_0':
'biocontainers/kaiju:1.10.0--h43eeafb_0' }"

input:
tuple val(meta), path(kaiju), path(kraken)
path (db)

output:
tuple val(meta), path("*.tsv"), emit: merged
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def dbnodes = db ? '-t <(find -L ${db} -name "*nodes.dmp")' : ''
script:
if ("$kaiju" == "${prefix}.tsv") error "Input and output names are the same, set prefix in module configuration to disambiguate!"
if ("$kraken" == "${prefix}.tsv") error "Input and output names are the same, set prefix in module configuration to disambiguate!"
"""
kaiju-mergeOutputs \\
-i <(sort -k2,2 ${kaiju}) \\
nvnieuwk marked this conversation as resolved.
Show resolved Hide resolved
-j <(sort -k2,2 ${kraken}) \\
-o ${prefix}.tsv \\
$dbnodes \\
$args

cat <<-END_VERSIONS > versions.yml
"${task.process}":
kaiju: \$(echo \$( kaiju -h 2>&1 | sed -n 1p | sed 's/^.*Kaiju //' ))
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
kaiju: \$(echo \$( kaiju -h 2>&1 | sed -n 1p | sed 's/^.*Kaiju //' ))
END_VERSIONS
"""
}
53 changes: 53 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: kaiju_mergeoutputs
description: Merge two tab-separated output files of Kaiju and Kraken in the column format
keywords:
- classify
- metagenomics
- fastq
- taxonomic profiling
tools:
- kaiju:
description: Fast and sensitive taxonomic classification for metagenomics
homepage: https://kaiju.binf.ku.dk/
documentation: https://github.com/bioinformatics-centre/kaiju/blob/master/README.md
tool_dev_url: https://github.com/bioinformatics-centre/kaiju
doi: "10.1038/ncomms11257"
licence: ["GNU GPL v3"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- kaiju:
type: file
description: |
Results with taxonomic classification of each read from Kaiju
- kraken:
type: file
description: |
Results with taxonomic classification of each read from Kraken
pattern: "*.{tsv}"
- db:
type: directory
description: |
List containing the database and nodes files for Kaiju
e.g. [ 'database.fmi', 'nodes.dmp' ]
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- merged:
type: file
description: Results with merged taxonomic classification of each read based on the given strategy '1', '2', 'lca' [default] or 'lowest'
pattern: "*.tsv"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@Joon-Klaps"
maintainers:
- "@Joon-Klaps"
5 changes: 5 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/tests/db.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: KAIJU_MERGEOUTPUTS{
ext.prefix = {"${meta.id}_merged"}
}
}
133 changes: 133 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
nextflow_process {

name "Test Process KAIJU_MERGEOUTPUTS"
script "../main.nf"
process "KAIJU_MERGEOUTPUTS"

tag "modules"
tag "modules_nfcore"
tag "kaiju"
tag "untar"
tag "kaiju/kaiju"
tag "kraken2/kraken2"
tag "kaiju/mergeoutputs"

setup {
run("UNTAR",alias: "UNTAR_KRAKEN2" ) {
config "./nodb.config"
script "../../../untar/main.nf"
process {
"""
input[0] = Channel.of([
[],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/kraken2.tar.gz', checkIfExists: true)
])
"""
}
}
run("KRAKEN2_KRAKEN2") {
config "./nodb.config"
script "../../../kraken2/kraken2/main.nf"
process {
"""
input[0] = [
[ id:'test', single_end:true ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
input[1] = UNTAR_KRAKEN2.out.untar.map{ it[1] }
input[2] = false
input[3] = true
"""
}
}
run("UNTAR",alias: "UNTAR_KAIJU" ) {
config "./nodb.config"
script "../../../untar/main.nf"
process {
"""
input[0] = Channel.of([
[],
file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/db/kaiju.tar.gz', checkIfExists: true)
])
"""
}
}
run("KAIJU_KAIJU") {
config "./nodb.config"
script "../../../kaiju/kaiju/main.nf"
process {
"""
input[0] = [
[ id:'test', single_end:true ],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
input[1] = UNTAR_KAIJU.out.untar.map{ it[1] }
"""
}
}
}

test("sarscov2 - kraken2.kaiju.classified - noDB ") {
config "./nodb.config"

when {
process {
"""
input[0] = KAIJU_KAIJU.out.results.join(KRAKEN2_KRAKEN2.out.classified_reads_assignment)
input[1] = [ ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - kraken2.kaiju.classified - kaiju.DB ") {
config "./db.config"
when {
process {
"""
input[0] = KAIJU_KAIJU.out.results.join(KRAKEN2_KRAKEN2.out.classified_reads_assignment)
input[1] = UNTAR_KAIJU.out.untar.map{ it[1] }
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - kraken2.kaiju.classified - noDB - stub ") {
config "./nodb.config"
options "-stub"

when {
process {
"""
input[0] = KAIJU_KAIJU.out.results.join(KRAKEN2_KRAKEN2.out.classified_reads_assignment)
input[1] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
107 changes: 107 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/tests/nodb.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
process {
withName: UNTAR_KAIJU{
ext.args2 = {"--no-same-owner"}
}

withName: UNTAR_KRAKEN2{
ext.args2 = {"--no-same-owner"}
}

withName: KAIJU_MERGEOUTPUTS{
ext.prefix = {"${meta.id}_merged"}
ext.args= "-c 1"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kaiju/mergeoutputs:
- "modules/nf-core/kaiju/mergeoutputs/**"
Loading
Loading