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"
51 changes: 51 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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("*_merged.tsv"), emit: merged
Joon-Klaps marked this conversation as resolved.
Show resolved Hide resolved
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")' : ''
"""
kaiju-mergeOutputs \\
-i <(sort -k2,2 ${kaiju}) \\
nvnieuwk marked this conversation as resolved.
Show resolved Hide resolved
-j <(sort -k2,2 ${kraken}) \\
-o ${prefix}_merged.tsv \\
Joon-Klaps marked this conversation as resolved.
Show resolved Hide resolved
$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}_merged.tsv
Joon-Klaps marked this conversation as resolved.
Show resolved Hide resolved

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"
129 changes: 129 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,129 @@
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" ) {
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") {
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" ) {
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") {
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 ") {

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.

5 changes: 5 additions & 0 deletions modules/nf-core/kaiju/mergeoutputs/tests/nodb.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: KAIJU_MERGEOUTPUTS{
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/**"
27 changes: 27 additions & 0 deletions modules/nf-core/kraken2/kraken2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,31 @@ process KRAKEN2_KRAKEN2 {
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def paired = meta.single_end ? "" : "--paired"
def classified = meta.single_end ? "${prefix}.classified.fastq.gz" : "${prefix}.classified_1.fastq.gz ${prefix}.classified_2.fastq.gz"
def unclassified = meta.single_end ? "${prefix}.unclassified.fastq.gz" : "${prefix}.unclassified_1.fastq.gz ${prefix}.unclassified_2.fastq.gz"
def readclassification_option = save_reads_assignment ? "--output ${prefix}.kraken2.classifiedreads.txt" : "--output /dev/null"
def compress_reads_command = save_output_fastqs ? "pigz -p $task.cpus *.fastq" : ""

"""
touch ${prefix}.kraken2.report.txt
if [ "$save_output_fastqs" == "true" ]; then
touch $classified
touch $unclassified
fi
if [ "$save_reads_assignment" == "true" ]; then
touch ${prefix}.kraken2.classifiedreads.txt
fi

cat <<-END_VERSIONS > versions.yml
"${task.process}":
kraken2: \$(echo \$(kraken2 --version 2>&1) | sed 's/^.*Kraken version //; s/ .*\$//')
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""

}
Loading