From 61c88c623389ba4646e5f01547db3050f0abd7fc Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Thu, 3 Mar 2022 08:02:04 +0100 Subject: [PATCH] Add `hamronization/summarize` (#1366) * fix: remove left-over unnecessary code * Add hamronizer/deeparg * Add hamronisation/summarise * Update test.yml * Update modules/hamronization/summarize/meta.yml Co-authored-by: Jasmin F <73216762+jasmezz@users.noreply.github.com> * line up outputs Co-authored-by: Robert A. Petit III Co-authored-by: Jasmin F <73216762+jasmezz@users.noreply.github.com> --- modules/hamronization/summarize/main.nf | 38 ++++++++++++++++ modules/hamronization/summarize/meta.yml | 45 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/hamronization/summarize/main.nf | 36 +++++++++++++++ .../hamronization/summarize/nextflow.config | 5 +++ .../modules/hamronization/summarize/test.yml | 14 ++++++ 6 files changed, 142 insertions(+) create mode 100644 modules/hamronization/summarize/main.nf create mode 100644 modules/hamronization/summarize/meta.yml create mode 100644 tests/modules/hamronization/summarize/main.nf create mode 100644 tests/modules/hamronization/summarize/nextflow.config create mode 100644 tests/modules/hamronization/summarize/test.yml diff --git a/modules/hamronization/summarize/main.nf b/modules/hamronization/summarize/main.nf new file mode 100644 index 00000000..9b10de80 --- /dev/null +++ b/modules/hamronization/summarize/main.nf @@ -0,0 +1,38 @@ +process HAMRONIZATION_SUMMARIZE { + label 'process_low' + + conda (params.enable_conda ? "bioconda::hamronization=1.0.3" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/hamronization:1.0.3--py_0': + 'quay.io/biocontainers/hamronization:1.0.3--py_0' }" + + input: + path(reports) + val(format) + + output: + path("hamronization_combined_report.json"), optional: true, emit: json + path("hamronization_combined_report.tsv") , optional: true, emit: tsv + path("hamronization_combined_report.html"), optional: true, emit: html + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def outformat = format == 'interactive' ? 'html' : format + """ + hamronize \\ + summarize \\ + ${reports.join(' ')} \\ + -t ${format} \\ + $args \\ + -o hamronization_combined_report.${outformat} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + hamronization: \$(echo \$(hamronize --version 2>&1) | cut -f 2 -d ' ' ) + END_VERSIONS + """ +} diff --git a/modules/hamronization/summarize/meta.yml b/modules/hamronization/summarize/meta.yml new file mode 100644 index 00000000..7665c2c5 --- /dev/null +++ b/modules/hamronization/summarize/meta.yml @@ -0,0 +1,45 @@ +name: hamronization_summarize +description: Tool to summarize and combine all hAMRonization reports into a single file +keywords: + - amr + - antimicrobial resistance + - reporting +tools: + - hamronization: + description: Tool to convert and summarize AMR gene detection outputs using the hAMRonization specification + homepage: https://github.com/pha4ge/hAMRonization/blob/master/README.md + documentation: https://github.com/pha4ge/hAMRonization/blob/master/README.md + tool_dev_url: https://github.com/pha4ge/hAMRonization + doi: "" + licence: ['GNU Lesser General Public v3 (LGPL v3)'] + +input: + - reports: + type: file + description: List of multiple hAMRonization reports in either JSON or TSV format + pattern: "*.{json,tsv}" + - format: + type: value + description: Type of final combined report file to be produced + pattern: "tsv|json|interactive" + +output: + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + - json: + type: file + description: hAMRonised summary in JSON format + pattern: "*.json" + - tsv: + type: file + description: hAMRonised summary in TSV format + pattern: "*.json" + - html: + type: file + description: hAMRonised summary in HTML format + pattern: "*.html" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 7146639c..de03a379 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -756,6 +756,10 @@ hamronization/deeparg: - modules/hamronization/deeparg/** - tests/modules/hamronization/deeparg/** +hamronization/summarize: + - modules/hamronization/summarize/** + - tests/modules/hamronization/summarize/** + hicap: - modules/hicap/** - tests/modules/hicap/** diff --git a/tests/modules/hamronization/summarize/main.nf b/tests/modules/hamronization/summarize/main.nf new file mode 100644 index 00000000..e0eae4a4 --- /dev/null +++ b/tests/modules/hamronization/summarize/main.nf @@ -0,0 +1,36 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { HAMRONIZATION_DEEPARG } from '../../../../modules/hamronization/deeparg/main.nf' +include { HAMRONIZATION_DEEPARG as HAMRONIZATION_DEEPARG_SECOND } from '../../../../modules/hamronization/deeparg/main.nf' +include { HAMRONIZATION_SUMMARIZE } from '../../../../modules/hamronization/summarize/main.nf' + +workflow test_hamronization_summarize { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['bacteroides_fragilis']['genome']['genome_mapping_potential_arg'], checkIfExists: true), + ] + + input2 = [ + [ id:'test2', single_end:false ], // meta map + file(params.test_data['bacteroides_fragilis']['genome']['genome_mapping_potential_arg'], checkIfExists: true), + ] + + HAMRONIZATION_DEEPARG ( input, 'tsv', '1.0.2', '2' ) + HAMRONIZATION_DEEPARG_SECOND ( input2, 'tsv', '1.0.2', '2' ) + + ch_deeparg_run_one = HAMRONIZATION_DEEPARG.out.tsv + ch_deeparg_run_two = HAMRONIZATION_DEEPARG_SECOND.out.tsv + + ch_deeparg_run_one + .mix( ch_deeparg_run_two ) + .map{ + [ it[1] ] + } + .collect() + .set { ch_input_for_summarize } + + HAMRONIZATION_SUMMARIZE ( ch_input_for_summarize , 'json' ) +} diff --git a/tests/modules/hamronization/summarize/nextflow.config b/tests/modules/hamronization/summarize/nextflow.config new file mode 100644 index 00000000..8730f1c4 --- /dev/null +++ b/tests/modules/hamronization/summarize/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/hamronization/summarize/test.yml b/tests/modules/hamronization/summarize/test.yml new file mode 100644 index 00000000..ad883971 --- /dev/null +++ b/tests/modules/hamronization/summarize/test.yml @@ -0,0 +1,14 @@ +- name: hamronization summarize test_hamronization_summarize + command: nextflow run tests/modules/hamronization/summarize -entry test_hamronization_summarize -c tests/config/nextflow.config + tags: + - hamronization + - hamronization/summarize + files: + - path: output/hamronization/hamronization_combined_report.json + md5sum: 1623b6cc3b213208a425e023edd94691 + - path: output/hamronization/test.tsv + md5sum: 3c315605aca0c5964796bb5fd4cdd522 + - path: output/hamronization/test2.tsv + md5sum: 453f38502e35261a50a0849dca34f05b + - path: output/hamronization/versions.yml + md5sum: 99b5046fac643e16ca3362d1baf3284b