From 86ab63fcf1a001ce25067b475d99462d9df122d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Cavalcante?= Date: Sun, 31 Mar 2024 11:01:53 -0300 Subject: [PATCH] feat: Implement microview into taxonomy subwf (#33) * feat: Add MicroView module * refactor: Allow mixing kaiju and kraken results * chore: Remove hidden default logo param --- conf/modules.config | 7 ++++++ docs/params.md | 1 + modules/local/microview.nf | 43 ++++++++++++++++++++++++++++++++++ nextflow.config | 1 + nextflow_schema.json | 5 ++++ subworkflows/local/taxonomy.nf | 21 +++++++++++++---- workflows/euryale.nf | 2 +- 7 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 modules/local/microview.nf diff --git a/conf/modules.config b/conf/modules.config index 96a215b..6bf4697 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -75,6 +75,13 @@ process { ] } + withName: MICROVIEW { + publishDir = [ + path: { "${params.outdir}/taxonomy/microview" }, + mode: params.publish_dir_mode, + saveAs: { filename -> filename.equals('versions.yml') ? null : filename } + ] + } withName: MEGAHIT { publishDir = [ diff --git a/docs/params.md b/docs/params.md index 3ca92a6..5a5571c 100644 --- a/docs/params.md +++ b/docs/params.md @@ -24,6 +24,7 @@ Choose to skip pipeline steps | `skip_alignment` | Skip alignment | `boolean` | | | | | `skip_functional` | Skip functional annotation | `boolean` | | | | | `skip_host_removal` | Skip host removal | `boolean` | | | | +| `skip_microview` | Skip MicroView report | `boolean` | | | | ## Decontamination diff --git a/modules/local/microview.nf b/modules/local/microview.nf new file mode 100644 index 0000000..997f89b --- /dev/null +++ b/modules/local/microview.nf @@ -0,0 +1,43 @@ +process MICROVIEW { + tag 'report' + label 'process_low' + + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'docker://docker.io/jvfe/microview:v0.10.0': + 'docker.io/jvfe/microview:v0.10.0' }" + + input: + path reports + + output: + path "microview_report.html", emit: report + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + """ + microview \\ + --taxonomy . \\ + --output microview_report.html + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + MicroView: \$(microview --version | sed 's/.*version \\([0-9.]\\+\\).*/\\1/') + END_VERSIONS + """ + + stub: + def args = task.ext.args ?: '' + + """ + touch microview_report.html + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + MicroView: \$(microview --version | sed 's/.*version \\([0-9.]\\+\\).*/\\1/') + END_VERSIONS + """ +} diff --git a/nextflow.config b/nextflow.config index 71d1bcd..6227fcd 100644 --- a/nextflow.config +++ b/nextflow.config @@ -47,6 +47,7 @@ params { skip_classification = false skip_functional = false skip_alignment = false + skip_microview = false // MultiQC options multiqc_config = null diff --git a/nextflow_schema.json b/nextflow_schema.json index 6cdec5c..0488efe 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -74,6 +74,11 @@ "type": "boolean", "description": "Skip host removal", "fa_icon": "fab fa-ioxhost" + }, + "skip_microview": { + "type": "boolean", + "fa_icon": "fas fa-glasses", + "description": "Skip MicroView report" } }, "fa_icon": "fas fa-angle-double-right" diff --git a/subworkflows/local/taxonomy.nf b/subworkflows/local/taxonomy.nf index c13d8d1..bff669b 100644 --- a/subworkflows/local/taxonomy.nf +++ b/subworkflows/local/taxonomy.nf @@ -6,6 +6,8 @@ include { KAIJU_KAIJU2TABLE } from '../../modules/nf-core/kaiju/kaiju2table/main include { KAIJU_KAIJU2KRONA } from '../../modules/nf-core/kaiju/kaiju2krona/main' include { KRONA_KTIMPORTTEXT } from '../../modules/nf-core/krona/ktimporttext/main' +include { MICROVIEW } from '../../modules/local/microview.nf' + workflow TAXONOMY { take: reads @@ -14,6 +16,8 @@ workflow TAXONOMY { main: + tax_report = Channel.empty() + krona_input = Channel.empty() ch_versions = Channel.empty() if (params.run_kaiju) { @@ -33,10 +37,10 @@ workflow TAXONOMY { "species" ) - KAIJU_KAIJU2TABLE.out.summary.set { tax_report } + tax_report = tax_report.mix(KAIJU_KAIJU2TABLE.out.summary) KAIJU_KAIJU2KRONA (kaiju_out, kaiju_db_files) - KAIJU_KAIJU2KRONA.out.txt.set { krona_input } + krona_input = krona_input.mix(KAIJU_KAIJU2KRONA.out.txt) ch_versions = ch_versions.mix(KAIJU_KAIJU2KRONA.out.versions) } @@ -47,17 +51,24 @@ workflow TAXONOMY { false, false ) - KRAKEN2_KRAKEN2.out.report.set { tax_report } + tax_report = tax_report.mix(KRAKEN2_KRAKEN2.out.report) ch_versions = ch_versions.mix(KRAKEN2_KRAKEN2.out.versions.first()) KRAKENTOOLS_KREPORT2KRONA ( - tax_report + KRAKEN2_KRAKEN2.out.report ) - KRAKENTOOLS_KREPORT2KRONA.out.txt.set { krona_input } + krona_input = krona_input.mix(KRAKENTOOLS_KREPORT2KRONA.out.txt) ch_versions = ch_versions.mix(KRAKENTOOLS_KREPORT2KRONA.out.versions.first()) } + if (!params.skip_microview) { + MICROVIEW ( + tax_report.collect{it[1]} + ) + ch_versions = ch_versions.mix(MICROVIEW.out.versions) + } + KRONA_KTIMPORTTEXT (krona_input) ch_versions = ch_versions.mix(KRONA_KTIMPORTTEXT.out.versions) diff --git a/workflows/euryale.nf b/workflows/euryale.nf index 9c0abbd..5f5577d 100644 --- a/workflows/euryale.nf +++ b/workflows/euryale.nf @@ -37,6 +37,7 @@ ch_multiqc_custom_methods_description = params.multiqc_methods_description ? fil // MODULES // include { FASTX_COLLAPSER } from '../modules/local/fastx_toolkit/collapser' +include { MICROVIEW } from '../modules/local/microview.nf' // // SUBWORKFLOW: Consisting of a mix of local and nf-core/modules @@ -167,7 +168,6 @@ workflow EURYALE { ch_multiqc_files = ch_multiqc_files.mix(TAXONOMY.out.tax_report.collect{it[1]}.ifEmpty([])) } - if (!params.skip_functional && !params.skip_alignment) { FUNCTIONAL ( alignments,