From fe3e18eaeee1b5784bc1197cb01e9e7204de5da9 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Tue, 6 Sep 2022 19:32:30 +0200 Subject: [PATCH] Add krakentools/combinekreports (#2018) * Add krakentools_combinekreports * Update test.yml * Update main.nf * Update tests/modules/krakentools/combinekreports/test.yml * Prettier * Update modules/krakentools/combinekreports/main.nf Co-authored-by: Robert A. Petit III Co-authored-by: Robert A. Petit III --- modules/krakentools/combinekreports/main.nf | 34 +++++++++++++++++++ modules/krakentools/combinekreports/meta.yml | 33 ++++++++++++++++++ tests/config/pytest_modules.yml | 4 +++ .../krakentools/combinekreports/main.nf | 23 +++++++++++++ .../combinekreports/nextflow.config | 5 +++ .../krakentools/combinekreports/test.yml | 9 +++++ 6 files changed, 108 insertions(+) create mode 100644 modules/krakentools/combinekreports/main.nf create mode 100644 modules/krakentools/combinekreports/meta.yml create mode 100644 tests/modules/krakentools/combinekreports/main.nf create mode 100644 tests/modules/krakentools/combinekreports/nextflow.config create mode 100644 tests/modules/krakentools/combinekreports/test.yml diff --git a/modules/krakentools/combinekreports/main.nf b/modules/krakentools/combinekreports/main.nf new file mode 100644 index 00000000..c50b7dc0 --- /dev/null +++ b/modules/krakentools/combinekreports/main.nf @@ -0,0 +1,34 @@ +process KRAKENTOOLS_COMBINEKREPORTS { + 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: + path kreports + + output: + 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 ?: "kreports_combined.txt" + def VERSION = '1.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. + """ + combine_kreports.py \\ + -r ${kreports} \\ + -o ${prefix} \\ + ${args} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + combine_kreports.py: ${VERSION} + END_VERSIONS + """ +} diff --git a/modules/krakentools/combinekreports/meta.yml b/modules/krakentools/combinekreports/meta.yml new file mode 100644 index 00000000..275897cb --- /dev/null +++ b/modules/krakentools/combinekreports/meta.yml @@ -0,0 +1,33 @@ +name: krakentools_combinekreports +description: Takes a Kraken report file and prints out a krona-compatible TEXT file +keywords: + - kraken + - krakentools + - metagenomics + - table + - combining + - merging +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: + - kreports: + type: file + description: List of kraken-style report files + pattern: "*.{txt,kreport}" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - txt: + type: file + description: Combined kreport file of all input files + pattern: "*.txt" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 7640b018..2c9f3c77 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1302,6 +1302,10 @@ kraken2/kraken2: - modules/untar/** - tests/modules/kraken2/kraken2/** +krakentools/combinekreports: + - modules/krakentools/combinekreports/** + - tests/modules/krakentools/combinekreports/** + krakentools/kreport2krona: - modules/krakentools/kreport2krona/** - tests/modules/krakentools/kreport2krona/** diff --git a/tests/modules/krakentools/combinekreports/main.nf b/tests/modules/krakentools/combinekreports/main.nf new file mode 100644 index 00000000..a35fe913 --- /dev/null +++ b/tests/modules/krakentools/combinekreports/main.nf @@ -0,0 +1,23 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { UNTAR } from '../../../../modules/untar/main' +include { KRAKEN2_KRAKEN2 } from '../../../../modules/kraken2/kraken2/main' +include { KRAKENTOOLS_COMBINEKREPORTS } from '../../../../modules/krakentools/combinekreports/main.nf' + +workflow test_krakentools_combinekreports { + + input = Channel.of( + [[ id:'test', single_end:false ], [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ]], + [[ id:'test2', single_end:false ], [ 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_COMBINEKREPORTS ( KRAKEN2_KRAKEN2.out.report.map{ [ it[1] ] }.collect().dump() ) +} diff --git a/tests/modules/krakentools/combinekreports/nextflow.config b/tests/modules/krakentools/combinekreports/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/krakentools/combinekreports/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/combinekreports/test.yml b/tests/modules/krakentools/combinekreports/test.yml new file mode 100644 index 00000000..ff4cdc69 --- /dev/null +++ b/tests/modules/krakentools/combinekreports/test.yml @@ -0,0 +1,9 @@ +- name: krakentools combinekreports test_krakentools_combinekreports + command: nextflow run ./tests/modules/krakentools/combinekreports -entry test_krakentools_combinekreports -c ./tests/config/nextflow.config -c ./tests/modules/krakentools/combinekreports/nextflow.config + tags: + - krakentools/combinekreports + - krakentools + files: + - path: output/krakentools/kreports_combined.txt + contains: + - "#Number of Samples: 2"