From 4983f77796ce7e367df6e1dd68ffd24cc924074f Mon Sep 17 00:00:00 2001 From: "James A. Fellows Yates" Date: Wed, 2 Mar 2022 13:04:22 +0100 Subject: [PATCH] Add `hamronization/deeparg` (#1364) * fix: remove left-over unnecessary code * Add hamronizer/deeparg * Add when condition * Apply suggestions from code review * Update modules/hamronization/deeparg/meta.yml --- modules/hamronization/deeparg/main.nf | 44 ++++++++++++++ modules/hamronization/deeparg/meta.yml | 60 +++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/config/test_data.config | 4 +- tests/modules/hamronization/deeparg/main.nf | 15 +++++ .../hamronization/deeparg/nextflow.config | 5 ++ tests/modules/hamronization/deeparg/test.yml | 8 +++ 7 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 modules/hamronization/deeparg/main.nf create mode 100644 modules/hamronization/deeparg/meta.yml create mode 100644 tests/modules/hamronization/deeparg/main.nf create mode 100644 tests/modules/hamronization/deeparg/nextflow.config create mode 100644 tests/modules/hamronization/deeparg/test.yml diff --git a/modules/hamronization/deeparg/main.nf b/modules/hamronization/deeparg/main.nf new file mode 100644 index 00000000..ebfdcf17 --- /dev/null +++ b/modules/hamronization/deeparg/main.nf @@ -0,0 +1,44 @@ +process HAMRONIZATION_DEEPARG { + tag "$meta.id" + 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: + tuple val(meta), path(report) + val(format) + val(software_version) + val(reference_db_version) + + output: + tuple val(meta), path("*.json"), optional: true, emit: json + tuple val(meta), path("*.tsv") , optional: true, emit: tsv + 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}" + """ + hamronize \\ + deeparg \\ + ${report} \\ + $args \\ + --format ${format} \\ + --analysis_software_version ${software_version} \\ + --reference_database_version ${reference_db_version} \\ + --input_file_name ${prefix} \\ + > ${prefix}.${format} + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + hamronization: \$(echo \$(hamronize --version 2>&1) | cut -f 2 -d ' ' ) + END_VERSIONS + """ +} diff --git a/modules/hamronization/deeparg/meta.yml b/modules/hamronization/deeparg/meta.yml new file mode 100644 index 00000000..0747700e --- /dev/null +++ b/modules/hamronization/deeparg/meta.yml @@ -0,0 +1,60 @@ +name: hamronization_deeparg +description: Tool to convert and summarize DeepARG outputs using the hAMRonization specification +keywords: + - amr + - antimicrobial resistance + - reporting + - deeparg +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: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - report: + type: file + description: Output .mapping.ARG file from DeepARG + pattern: "*.mapping.ARG" + - format: + type: value + description: Type of report file to be produced + pattern: "tsv|json" + - software_version: + type: value + description: Version of DeepARG used + pattern: "[0-9].[0-9].[0-9]" + - reference_db_version: + type: value + description: Database version of DeepARG used + pattern: "[0-9]" + +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" + - json: + type: file + description: hAMRonised report in JSON format + pattern: "*.json" + - tsv: + type: file + description: hAMRonised report in TSV format + pattern: "*.json" + +authors: + - "@jfy133" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 8ec52a63..7146639c 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -752,6 +752,10 @@ gunzip: - modules/gunzip/** - tests/modules/gunzip/** +hamronization/deeparg: + - modules/hamronization/deeparg/** + - tests/modules/hamronization/deeparg/** + hicap: - modules/hicap/** - tests/modules/hicap/** diff --git a/tests/config/test_data.config b/tests/config/test_data.config index a3c26bcc..dda10192 100644 --- a/tests/config/test_data.config +++ b/tests/config/test_data.config @@ -68,7 +68,7 @@ params { test_computematrix_mat_gz = "${test_data_dir}/genomics/sarscov2/illumina/deeptools/test.computeMatrix.mat.gz" test_bcf = "${test_data_dir}/genomics/sarscov2/illumina/vcf/test.bcf" - + test_vcf = "${test_data_dir}/genomics/sarscov2/illumina/vcf/test.vcf" test_vcf_gz = "${test_data_dir}/genomics/sarscov2/illumina/vcf/test.vcf.gz" test_vcf_gz_tbi = "${test_data_dir}/genomics/sarscov2/illumina/vcf/test.vcf.gz.tbi" @@ -321,6 +321,8 @@ params { 'genome' { genome_fna_gz = "${test_data_dir}/genomics/prokaryotes/bacteroides_fragilis/genome/genome.fna.gz" genome_paf = "${test_data_dir}/genomics/prokaryotes/bacteroides_fragilis/genome/genome.paf" + genome_mapping_potential_arg = "${test_data_dir}/genomics/prokaryotes/bacteroides_fragilis/genome/genome.mapping.potential.ARG" + } 'illumina' { test1_contigs_fa_gz = "${test_data_dir}/genomics/prokaryotes/bacteroides_fragilis/illumina/fasta/test1.contigs.fa.gz" diff --git a/tests/modules/hamronization/deeparg/main.nf b/tests/modules/hamronization/deeparg/main.nf new file mode 100644 index 00000000..9888bc42 --- /dev/null +++ b/tests/modules/hamronization/deeparg/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { HAMRONIZATION_DEEPARG } from '../../../../modules/hamronization/deeparg/main.nf' + +workflow test_hamronization_deeparg { + + input = [ + [ id:'test', 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' ) +} diff --git a/tests/modules/hamronization/deeparg/nextflow.config b/tests/modules/hamronization/deeparg/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/hamronization/deeparg/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/hamronization/deeparg/test.yml b/tests/modules/hamronization/deeparg/test.yml new file mode 100644 index 00000000..4884ac6c --- /dev/null +++ b/tests/modules/hamronization/deeparg/test.yml @@ -0,0 +1,8 @@ +- name: hamronization deeparg test_hamronization_deeparg + command: nextflow run tests/modules/hamronization/deeparg -entry test_hamronization_deeparg -c tests/config/nextflow.config + tags: + - hamronization + - hamronization/deeparg + files: + - path: output/hamronization/test.tsv + md5sum: 3c315605aca0c5964796bb5fd4cdd522