From 8b2a473f586bed003e72d2b183acc43fc0ddc422 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Mon, 13 Jun 2022 13:14:44 -0500 Subject: [PATCH] New module: krakentools/kreport2krona (#1746) * Add module definition for kreport2krona * Add metadata for kreport2krona module * Add tests for kreport2krona Co-authored-by: Robert A. Petit III --- modules/krakentools/kreport2krona/main.nf | 36 ++++++++++++++++ modules/krakentools/kreport2krona/meta.yml | 41 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ .../modules/krakentools/kreport2krona/main.nf | 20 +++++++++ .../krakentools/kreport2krona/nextflow.config | 5 +++ .../krakentools/kreport2krona/test.yml | 8 ++++ 6 files changed, 114 insertions(+) create mode 100644 modules/krakentools/kreport2krona/main.nf create mode 100644 modules/krakentools/kreport2krona/meta.yml create mode 100644 tests/modules/krakentools/kreport2krona/main.nf create mode 100644 tests/modules/krakentools/kreport2krona/nextflow.config create mode 100644 tests/modules/krakentools/kreport2krona/test.yml diff --git a/modules/krakentools/kreport2krona/main.nf b/modules/krakentools/kreport2krona/main.nf new file mode 100644 index 00000000..3bf46eec --- /dev/null +++ b/modules/krakentools/kreport2krona/main.nf @@ -0,0 +1,36 @@ +def VERSION = '1.2' // Version information not provided by tool on CLI + +process KRAKENTOOLS_KREPORT2KRONA { + tag "$meta.id" + label 'process_low' + + conda (params.enable_conda ? "bioconda::krakentools=1.2" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/krakentools:1.2--pyh5e36f6f_0': + 'quay.io/biocontainers/krakentools:1.2--pyh5e36f6f_0' }" + + input: + tuple val(meta), path(kreport) + + 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}" + """ + kreport2krona.py \\ + -r ${kreport} \\ + -o ${prefix}.txt \\ + ${args} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + kreport2krona.py: ${VERSION} + END_VERSIONS + """ +} diff --git a/modules/krakentools/kreport2krona/meta.yml b/modules/krakentools/kreport2krona/meta.yml new file mode 100644 index 00000000..2f8a163c --- /dev/null +++ b/modules/krakentools/kreport2krona/meta.yml @@ -0,0 +1,41 @@ +name: krakentools_kreport2krona +description: Takes a Kraken report file and prints out a krona-compatible TEXT file +keywords: + - kraken + - krona + - metagenomics + - visualization +tools: + - krakentools: + description: KrakenTools is a suite of scripts to be used for post-analysis of Kraken/KrakenUniq/Kraken2/Bracken results. Please cite the relevant paper if using KrakenTools with any of the listed programs. + homepage: https://github.com/jenniferlu717/KrakenTools + licence: ["GPL v3"] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - kreport: + type: file + description: Kraken report + pattern: "*.{txt,kreport}" + +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" + - krona: + type: file + description: Krona text-based input file converted from Kraken report + pattern: "*.{txt,krona}" + +authors: + - "@MillironX" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 578d8252..7999940e 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1146,6 +1146,10 @@ kraken2/kraken2: - modules/untar/** - tests/modules/kraken2/kraken2/** +krakentools/kreport2krona: + - modules/krakentools/kreport2krona/** + - tests/modules/krakentools/kreport2krona/** + krona/kronadb: - modules/krona/kronadb/** - tests/modules/krona/kronadb/** diff --git a/tests/modules/krakentools/kreport2krona/main.nf b/tests/modules/krakentools/kreport2krona/main.nf new file mode 100644 index 00000000..c9c626fd --- /dev/null +++ b/tests/modules/krakentools/kreport2krona/main.nf @@ -0,0 +1,20 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { UNTAR } from '../../../../modules/untar/main' +include { KRAKEN2_KRAKEN2 } from '../../../../modules/kraken2/kraken2/main' +include { KRAKENTOOLS_KREPORT2KRONA } from '../../../../modules/krakentools/kreport2krona/main' + +workflow test_krakentools_kreport2krona { + + input = Channel.of([ [ 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) ] + ]) + db = [ [], file(params.test_data['sarscov2']['genome']['kraken2_tar_gz'], checkIfExists: true) ] + + UNTAR ( db ) + KRAKEN2_KRAKEN2 ( input, UNTAR.out.untar.map{ it[1] }, false, false ) + KRAKENTOOLS_KREPORT2KRONA ( KRAKEN2_KRAKEN2.out.report ) +} diff --git a/tests/modules/krakentools/kreport2krona/nextflow.config b/tests/modules/krakentools/kreport2krona/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/krakentools/kreport2krona/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/krakentools/kreport2krona/test.yml b/tests/modules/krakentools/kreport2krona/test.yml new file mode 100644 index 00000000..6525e915 --- /dev/null +++ b/tests/modules/krakentools/kreport2krona/test.yml @@ -0,0 +1,8 @@ +- name: krakentools kreport2krona test_krakentools_kreport2krona + command: nextflow run ./tests/modules/krakentools/kreport2krona -entry test_krakentools_kreport2krona -c ./tests/config/nextflow.config -c ./tests/modules/krakentools/kreport2krona/nextflow.config + tags: + - krakentools/kreport2krona + - krakentools + files: + - path: output/krakentools/test.txt + md5sum: c89a9db7acbdba9dea0fe246bcaa85c1