diff --git a/modules/kaiju/kaiju2krona/main.nf b/modules/kaiju/kaiju2krona/main.nf new file mode 100644 index 00000000..c95d5a7f --- /dev/null +++ b/modules/kaiju/kaiju2krona/main.nf @@ -0,0 +1,39 @@ +process KAIJU_KAIJU2KRONA { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::kaiju=1.8.2" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/kaiju:1.8.2--h5b5514e_1': + 'quay.io/biocontainers/kaiju:1.8.2--h5b5514e_1' }" + + input: + tuple val(meta), path(tsv) + path(db) + + output: + tuple val(meta), path("*.txt"), emit: txt + 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}" + """ + dbnodes=`find -L ${db} -name "*nodes.dmp"` + dbnames=`find -L ${db} -name "*names.dmp"` + kaiju2krona \\ + $args \\ + -t \$dbnodes \\ + -n \$dbnames \\ + -i ${tsv} \\ + -o ${prefix}.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + kaiju: \$(echo \$( kaiju -h 2>&1 | sed -n 1p | sed 's/^.*Kaiju //' )) + END_VERSIONS + """ +} diff --git a/modules/kaiju/kaiju2krona/meta.yml b/modules/kaiju/kaiju2krona/meta.yml new file mode 100644 index 00000000..a0dc2fdb --- /dev/null +++ b/modules/kaiju/kaiju2krona/meta.yml @@ -0,0 +1,44 @@ +name: kaiju_kaiju2krona +description: Convert Kaiju's tab-separated output file into a tab-separated text file which can be imported into Krona. +keywords: + - taxonomy + - visualisation + - krona chart + - metagenomics +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 ] + - tsv: + type: file + description: Kaiju tab-separated output file + pattern: "*.{tsv,txt}" + +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" + - txt: + type: file + description: Krona text-based input file converted from Kaiju report + pattern: "*.{txt,krona}" + +authors: + - "@MillironX" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 017e7752..7d251539 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1137,6 +1137,10 @@ kaiju/kaiju: - modules/kaiju/kaiju/** - tests/modules/kaiju/kaiju/** +kaiju/kaiju2krona: + - modules/kaiju/kaiju2krona/** + - tests/modules/kaiju/kaiju2krona/** + kaiju/kaiju2table: - modules/kaiju/kaiju2table/** - tests/modules/kaiju/kaiju2table/** diff --git a/tests/modules/kaiju/kaiju2krona/main.nf b/tests/modules/kaiju/kaiju2krona/main.nf new file mode 100644 index 00000000..aabefd1f --- /dev/null +++ b/tests/modules/kaiju/kaiju2krona/main.nf @@ -0,0 +1,20 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { UNTAR } from '../../../../modules/untar/main.nf' +include { KAIJU_KAIJU } from '../../../../modules/kaiju/kaiju/main.nf' +include { KAIJU_KAIJU2KRONA } from '../../../../modules/kaiju/kaiju2krona/main.nf' + +workflow test_kaiju_kaiju2krona { + + input = [ + [ id:'test', single_end:true ], // meta map + file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) + ] + db = [ [], file(params.test_data['sarscov2']['genome']['kaiju_tar_gz'], checkIfExists: true) ] + + UNTAR ( db ) + KAIJU_KAIJU ( input, UNTAR.out.untar.map{ it[1] } ) + KAIJU_KAIJU2KRONA ( KAIJU_KAIJU.out.results , UNTAR.out.untar.map{ it[1] } ) +} diff --git a/tests/modules/kaiju/kaiju2krona/nextflow.config b/tests/modules/kaiju/kaiju2krona/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/kaiju/kaiju2krona/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} \ No newline at end of file diff --git a/tests/modules/kaiju/kaiju2krona/test.yml b/tests/modules/kaiju/kaiju2krona/test.yml new file mode 100644 index 00000000..a9bb294c --- /dev/null +++ b/tests/modules/kaiju/kaiju2krona/test.yml @@ -0,0 +1,8 @@ +- name: kaiju kaiju2krona test_kaiju_kaiju2krona + command: nextflow run ./tests/modules/kaiju/kaiju2krona -entry test_kaiju_kaiju2krona -c ./tests/config/nextflow.config -c ./tests/modules/kaiju/kaiju2krona/nextflow.config + tags: + - kaiju/kaiju2krona + - kaiju + files: + - path: output/kaiju/test.txt + md5sum: 68b2309d37767e444193fa6cea7c0494