From 15d39f841af22581cfa472eafea37810dc6293c1 Mon Sep 17 00:00:00 2001 From: "Robert A. Petit III" Date: Sat, 19 Feb 2022 16:02:23 -0700 Subject: [PATCH] add amrfinderplus module (#1284) * add amrfinderplus module * Update test.yml * Update main.nf * Update main.nf * Update test.yml * Update test.yml * Update test.yml * Update main.nf * Update meta.yml * Update meta.yml * Update main.nf * Update test.yml * Update test.yml --- modules/amrfinderplus/run/main.nf | 55 +++++++++++++++++++ modules/amrfinderplus/run/meta.yml | 51 +++++++++++++++++ modules/amrfinderplus/update/main.nf | 29 ++++++++++ modules/amrfinderplus/update/meta.yml | 37 +++++++++++++ tests/config/pytest_modules.yml | 8 +++ tests/modules/amrfinderplus/run/main.nf | 17 ++++++ .../modules/amrfinderplus/run/nextflow.config | 5 ++ tests/modules/amrfinderplus/run/test.yml | 11 ++++ tests/modules/amrfinderplus/update/main.nf | 11 ++++ .../amrfinderplus/update/nextflow.config | 5 ++ tests/modules/amrfinderplus/update/test.yml | 9 +++ 11 files changed, 238 insertions(+) create mode 100644 modules/amrfinderplus/run/main.nf create mode 100644 modules/amrfinderplus/run/meta.yml create mode 100644 modules/amrfinderplus/update/main.nf create mode 100644 modules/amrfinderplus/update/meta.yml create mode 100644 tests/modules/amrfinderplus/run/main.nf create mode 100644 tests/modules/amrfinderplus/run/nextflow.config create mode 100644 tests/modules/amrfinderplus/run/test.yml create mode 100644 tests/modules/amrfinderplus/update/main.nf create mode 100644 tests/modules/amrfinderplus/update/nextflow.config create mode 100644 tests/modules/amrfinderplus/update/test.yml diff --git a/modules/amrfinderplus/run/main.nf b/modules/amrfinderplus/run/main.nf new file mode 100644 index 00000000..47a8fb46 --- /dev/null +++ b/modules/amrfinderplus/run/main.nf @@ -0,0 +1,55 @@ +process AMRFINDERPLUS_RUN { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::ncbi-amrfinderplus=3.10.23" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/ncbi-amrfinderplus%3A3.10.23--h17dc2d4_0': + 'quay.io/biocontainers/ncbi-amrfinderplus:3.10.23--h17dc2d4_0' }" + + input: + tuple val(meta), path(fasta) + path db + + output: + tuple val(meta), path("${prefix}.tsv") , emit: report + tuple val(meta), path("${prefix}-mutations.tsv"), emit: mutation_report, optional: true + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + def is_compressed = fasta.getName().endsWith(".gz") ? true : false + prefix = task.ext.prefix ?: "${meta.id}" + organism_param = meta.containsKey("organism") ? "--organism ${meta.organism} --mutation_all ${prefix}-mutations.tsv" : "" + fasta_name = fasta.getName().replace(".gz", "") + fasta_param = "-n" + if (meta.containsKey("is_proteins")) { + if (meta.is_proteins) { + fasta_param = "-p" + } + } + """ + if [ "$is_compressed" == "true" ]; then + gzip -c -d $fasta > $fasta_name + fi + + mkdir amrfinderdb + tar xzvf $db -C amrfinderdb + + amrfinder \\ + $fasta_param $fasta_name \\ + $organism_param \\ + $args \\ + --database amrfinderdb \\ + --threads $task.cpus > ${prefix}.tsv + + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + amrfinderplus: \$(amrfinder --version) + END_VERSIONS + """ +} diff --git a/modules/amrfinderplus/run/meta.yml b/modules/amrfinderplus/run/meta.yml new file mode 100644 index 00000000..b0f3b8fa --- /dev/null +++ b/modules/amrfinderplus/run/meta.yml @@ -0,0 +1,51 @@ +name: amrfinderplus_run +description: Identify antimicrobial resistance in gene or protein sequences +keywords: + - bacteria + - fasta + - antibiotic resistance +tools: + - amrfinderplus: + description: AMRFinderPlus finds antimicrobial resistance and other genes in protein or nucleotide sequences. + homepage: https://github.com/ncbi/amr/wiki + documentation: https://github.com/ncbi/amr/wiki + tool_dev_url: https://github.com/ncbi/amr + doi: "10.1038/s41598-021-91456-0" + licence: ['Public Domain'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fasta: + type: file + description: Nucleotide or protein sequences in FASTA format + pattern: "*.{fasta,fasta.gz,fa,fa.gz,fna,fna.gz,faa,faa.gz}" + - db: + type: file + description: A compressed tarball of the AMRFinderPlus database to query + pattern: "*.tar.gz" + +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" + - report: + type: file + description: AMRFinder+ final report + pattern: "*.tsv" + - mutation_report: + type: file + description: Report of organism-specific point-mutations + pattern: "*-mutations.tsv" + +authors: + - "@rpetit3" diff --git a/modules/amrfinderplus/update/main.nf b/modules/amrfinderplus/update/main.nf new file mode 100644 index 00000000..ad09c391 --- /dev/null +++ b/modules/amrfinderplus/update/main.nf @@ -0,0 +1,29 @@ +process AMRFINDERPLUS_UPDATE { + tag "update" + label 'process_low' + + conda (params.enable_conda ? "bioconda::ncbi-amrfinderplus=3.10.23" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/ncbi-amrfinderplus%3A3.10.23--h17dc2d4_0': + 'quay.io/biocontainers/ncbi-amrfinderplus:3.10.23--h17dc2d4_0' }" + + output: + path "amrfinderdb.tar.gz", emit: db + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + def args = task.ext.args ?: '' + """ + mkdir amrfinderdb + amrfinder_update -d amrfinderdb + tar czvf amrfinderdb.tar.gz -C \$(readlink amrfinderdb/latest) ./ + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + amrfinderplus: \$(amrfinder --version) + END_VERSIONS + """ +} diff --git a/modules/amrfinderplus/update/meta.yml b/modules/amrfinderplus/update/meta.yml new file mode 100644 index 00000000..84fee3df --- /dev/null +++ b/modules/amrfinderplus/update/meta.yml @@ -0,0 +1,37 @@ +name: amrfinderplus_update +description: Identify antimicrobial resistance in gene or protein sequences +keywords: + - bacteria + - fasta + - antibiotic resistance +tools: + - amrfinderplus: + description: AMRFinderPlus finds antimicrobial resistance and other genes in protein or nucleotide sequences. + homepage: https://github.com/ncbi/amr/wiki + documentation: https://github.com/ncbi/amr/wiki + tool_dev_url: https://github.com/ncbi/amr + doi: "10.1038/s41598-021-91456-0" + licence: ['Public Domain'] + +input: + - input_not_required: + type: null + description: module does not have an input + +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" + - db: + type: file + description: The latest AMRFinder+ database in a compressed tarball + pattern: "*.tar.gz" + +authors: + - "@rpetit3" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index e6773293..93903a65 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -26,6 +26,14 @@ amps: - modules/amps/** - tests/modules/amps/** +amrfinderplus/run: + - modules/amrfinderplus/run/** + - tests/modules/amrfinderplus/run/** + +amrfinderplus/update: + - modules/amrfinderplus/update/** + - tests/modules/amrfinderplus/update/** + arriba: - modules/arriba/** - tests/modules/arriba/** diff --git a/tests/modules/amrfinderplus/run/main.nf b/tests/modules/amrfinderplus/run/main.nf new file mode 100644 index 00000000..917ac28d --- /dev/null +++ b/tests/modules/amrfinderplus/run/main.nf @@ -0,0 +1,17 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { AMRFINDERPLUS_UPDATE } from '../../../../modules/amrfinderplus/update/main.nf' +include { AMRFINDERPLUS_RUN } from '../../../../modules/amrfinderplus/run/main.nf' + +workflow test_amrfinderplus_run { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true) + ] + + AMRFINDERPLUS_UPDATE ( ) + AMRFINDERPLUS_RUN ( input, AMRFINDERPLUS_UPDATE.out.db ) +} diff --git a/tests/modules/amrfinderplus/run/nextflow.config b/tests/modules/amrfinderplus/run/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/amrfinderplus/run/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/amrfinderplus/run/test.yml b/tests/modules/amrfinderplus/run/test.yml new file mode 100644 index 00000000..d858cb88 --- /dev/null +++ b/tests/modules/amrfinderplus/run/test.yml @@ -0,0 +1,11 @@ +- name: amrfinderplus run test_amrfinderplus_run + command: nextflow run tests/modules/amrfinderplus/run -entry test_amrfinderplus_run -c tests/config/nextflow.config + tags: + - amrfinderplus/run + - amrfinderplus + files: + - path: output/amrfinderplus/amrfinderdb.tar.gz + - path: output/amrfinderplus/test.tsv + md5sum: b4d261ace9be7d013c19d1f5c0005bfe + - path: output/amrfinderplus/versions.yml + md5sum: 642ca04a07d79fe4c4d02348562e3961 diff --git a/tests/modules/amrfinderplus/update/main.nf b/tests/modules/amrfinderplus/update/main.nf new file mode 100644 index 00000000..f3a34ea0 --- /dev/null +++ b/tests/modules/amrfinderplus/update/main.nf @@ -0,0 +1,11 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { AMRFINDERPLUS_UPDATE } from '../../../../modules/amrfinderplus/update/main.nf' + +workflow test_amrfinderplus_update { + + AMRFINDERPLUS_UPDATE ( ) + +} diff --git a/tests/modules/amrfinderplus/update/nextflow.config b/tests/modules/amrfinderplus/update/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/amrfinderplus/update/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/amrfinderplus/update/test.yml b/tests/modules/amrfinderplus/update/test.yml new file mode 100644 index 00000000..7ae89992 --- /dev/null +++ b/tests/modules/amrfinderplus/update/test.yml @@ -0,0 +1,9 @@ +- name: amrfinderplus update test_amrfinderplus_update + command: nextflow run tests/modules/amrfinderplus/update -entry test_amrfinderplus_update -c tests/config/nextflow.config + tags: + - amrfinderplus + - amrfinderplus/update + files: + - path: output/amrfinderplus/amrfinderdb.tar.gz + - path: output/amrfinderplus/versions.yml + md5sum: 4db18fa509309db4da0920a7eeaba86c