From d27b7a6fda7ba7fea110fbe7bbbd34173d6d31a0 Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Wed, 7 Sep 2022 09:18:21 +0200 Subject: [PATCH] Add bracken/combinebrackenoutputs (#2022) * Add combinebrackenoutputs * Prettier and relax tests contains * Apply suggestions from code review Co-authored-by: Robert A. Petit III Co-authored-by: Robert A. Petit III --- modules/bracken/combinebrackenoutputs/main.nf | 36 +++++++++++++++++++ .../bracken/combinebrackenoutputs/meta.yml | 31 ++++++++++++++++ tests/config/pytest_modules.yml | 4 +++ .../bracken/combinebrackenoutputs/main.nf | 25 +++++++++++++ .../combinebrackenoutputs/nextflow.config | 5 +++ .../bracken/combinebrackenoutputs/test.yml | 9 +++++ 6 files changed, 110 insertions(+) create mode 100644 modules/bracken/combinebrackenoutputs/main.nf create mode 100644 modules/bracken/combinebrackenoutputs/meta.yml create mode 100644 tests/modules/bracken/combinebrackenoutputs/main.nf create mode 100644 tests/modules/bracken/combinebrackenoutputs/nextflow.config create mode 100644 tests/modules/bracken/combinebrackenoutputs/test.yml diff --git a/modules/bracken/combinebrackenoutputs/main.nf b/modules/bracken/combinebrackenoutputs/main.nf new file mode 100644 index 00000000..73b7148a --- /dev/null +++ b/modules/bracken/combinebrackenoutputs/main.nf @@ -0,0 +1,36 @@ +process BRACKEN_COMBINEBRACKENOUTPUTS { + label 'process_low' + + conda (params.enable_conda ? "bioconda::bracken=2.7" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/bracken:2.7--py39hc16433a_0': + 'quay.io/biocontainers/bracken:2.7--py39hc16433a_0' }" + + input: + path input + + 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 ?: "bracken_combined.txt" + // WARN: Version information not provided by tool on CLI. + // Please update version string below when bumping container versions. + def VERSION = '2.7' + """ + combine_bracken_outputs.py \\ + $args \\ + --files ${input} \\ + -o ${prefix} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + combine_bracken_output: ${VERSION} + END_VERSIONS + """ +} diff --git a/modules/bracken/combinebrackenoutputs/meta.yml b/modules/bracken/combinebrackenoutputs/meta.yml new file mode 100644 index 00000000..c4a97120 --- /dev/null +++ b/modules/bracken/combinebrackenoutputs/meta.yml @@ -0,0 +1,31 @@ +name: "bracken_combinebrackenoutputs" +description: Combine output of metagenomic samples analyzed by bracken. +keywords: + - sort +tools: + - "bracken": + description: Bracken (Bayesian Reestimation of Abundance with KrakEN) is a highly accurate statistical method that computes the abundance of species in DNA sequences from a metagenomics sample. + homepage: https://ccb.jhu.edu/software/bracken/ + documentation: https://ccb.jhu.edu/software/bracken/index.shtml?t=manual + tool_dev_url: https://github.com/jenniferlu717/Bracken + doi: "10.7717/peerj-cs.104" + licence: ["GPL v3"] + +input: + - input: + type: file + description: List of output files from bracken + pattern: "*" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - txt: + type: file + description: Combined output in table format + pattern: "*.txt" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 2c9f3c77..6138fc55 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -397,6 +397,10 @@ bracken/bracken: - modules/bracken/bracken/** - tests/modules/bracken/bracken/** +bracken/combinebrackenoutputs: + - modules/bracken/combinebrackenoutputs/** + - tests/modules/bracken/combinebrackenoutputs/** + busco: - modules/busco/** - tests/modules/busco/** diff --git a/tests/modules/bracken/combinebrackenoutputs/main.nf b/tests/modules/bracken/combinebrackenoutputs/main.nf new file mode 100644 index 00000000..d382d907 --- /dev/null +++ b/tests/modules/bracken/combinebrackenoutputs/main.nf @@ -0,0 +1,25 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { UNTAR } from '../../../../modules/untar/main.nf' +include { KRAKEN2_KRAKEN2 } from '../../../../modules/kraken2/kraken2/main.nf' +include { BRACKEN_BRACKEN } from '../../../../modules/bracken/bracken/main.nf' +include { BRACKEN_COMBINEBRACKENOUTPUTS } from '../../../../modules/bracken/combinebrackenoutputs/main.nf' + +workflow test_bracken_combinebrackenoutputs { + + input = Channel.of( + [[ id:'test', single_end:false, threshold:0, taxonomic_level:'G', read_length:100 ], [ 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, threshold:0, taxonomic_level:'G', read_length:100 ], [ 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_bracken_tar_gz'], checkIfExists: true) + + ch_db = UNTAR ( [[:], db] ).untar + .map { it[1] } + KRAKEN2_KRAKEN2 ( input, ch_db, false, false ) + BRACKEN_BRACKEN ( KRAKEN2_KRAKEN2.out.report, ch_db ) + + BRACKEN_COMBINEBRACKENOUTPUTS ( BRACKEN_BRACKEN.out.reports.map{it[1]}.collect() ) +} + diff --git a/tests/modules/bracken/combinebrackenoutputs/nextflow.config b/tests/modules/bracken/combinebrackenoutputs/nextflow.config new file mode 100644 index 00000000..8730f1c4 --- /dev/null +++ b/tests/modules/bracken/combinebrackenoutputs/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/bracken/combinebrackenoutputs/test.yml b/tests/modules/bracken/combinebrackenoutputs/test.yml new file mode 100644 index 00000000..057a215f --- /dev/null +++ b/tests/modules/bracken/combinebrackenoutputs/test.yml @@ -0,0 +1,9 @@ +- name: bracken combinebrackenoutputs test_bracken_combinebrackenoutputs + command: nextflow run ./tests/modules/bracken/combinebrackenoutputs -entry test_bracken_combinebrackenoutputs -c ./tests/config/nextflow.config -c ./tests/modules/bracken/combinebrackenoutputs/nextflow.config + tags: + - bracken/combinebrackenoutputs + - bracken + files: + - path: output/bracken/bracken_combined.txt + contains: + - "name taxonomy_id taxonomy_lvl"