From be798861c616e445abbaf9f2549deb10055c2ed1 Mon Sep 17 00:00:00 2001 From: "Robert A. Petit III" Date: Fri, 18 Feb 2022 18:00:21 -0700 Subject: [PATCH] add module for abricate (#1280) * add module for abricate * rename abricate/abricate to abricate/run * Update test.yml Co-authored-by: Sateesh <33637490+sateeshperi@users.noreply.github.com> --- modules/abricate/run/main.nf | 34 +++++++++++++++ modules/abricate/run/meta.yml | 43 +++++++++++++++++++ modules/abricate/summary/main.nf | 33 ++++++++++++++ modules/abricate/summary/meta.yml | 43 +++++++++++++++++++ tests/config/pytest_modules.yml | 8 ++++ tests/modules/abricate/run/main.nf | 15 +++++++ tests/modules/abricate/run/nextflow.config | 5 +++ tests/modules/abricate/run/test.yml | 10 +++++ tests/modules/abricate/summary/main.nf | 21 +++++++++ .../modules/abricate/summary/nextflow.config | 5 +++ tests/modules/abricate/summary/test.yml | 14 ++++++ 11 files changed, 231 insertions(+) create mode 100644 modules/abricate/run/main.nf create mode 100644 modules/abricate/run/meta.yml create mode 100644 modules/abricate/summary/main.nf create mode 100644 modules/abricate/summary/meta.yml create mode 100644 tests/modules/abricate/run/main.nf create mode 100644 tests/modules/abricate/run/nextflow.config create mode 100644 tests/modules/abricate/run/test.yml create mode 100644 tests/modules/abricate/summary/main.nf create mode 100644 tests/modules/abricate/summary/nextflow.config create mode 100644 tests/modules/abricate/summary/test.yml diff --git a/modules/abricate/run/main.nf b/modules/abricate/run/main.nf new file mode 100644 index 00000000..11992791 --- /dev/null +++ b/modules/abricate/run/main.nf @@ -0,0 +1,34 @@ +process ABRICATE_RUN { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::abricate=1.0.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/abricate%3A1.0.1--ha8f3691_1': + 'quay.io/biocontainers/abricate:1.0.1--ha8f3691_1' }" + + input: + tuple val(meta), path(assembly) + + output: + tuple val(meta), path("*.txt"), emit: report + 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}" + """ + abricate \\ + $assembly \\ + $args \\ + --threads $task.cpus > ${prefix}.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + abricate: \$(echo \$(abricate --version 2>&1) | sed 's/^.*abricate //' ) + END_VERSIONS + """ +} diff --git a/modules/abricate/run/meta.yml b/modules/abricate/run/meta.yml new file mode 100644 index 00000000..2464d03e --- /dev/null +++ b/modules/abricate/run/meta.yml @@ -0,0 +1,43 @@ +name: abricate_run +description: Screen assemblies for antimicrobial resistance against multiple databases +keywords: + - bacteria + - assembly + - antimicrobial reistance +tools: + - abricate: + description: Mass screening of contigs for antibiotic resistance genes + homepage: https://github.com/tseemann/abricate + documentation: https://github.com/tseemann/abricate + tool_dev_url: https://github.com/tseemann/abricate + doi: "" + licence: ['GPL v2', 'GPL v2'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - assembly: + type: file + description: FASTA, GenBank or EMBL formatted file + pattern: "*.{fa,fasta,fna,fa.gz,fasta.gz,fna.gz,gbk,gbk.gz,embl,embl.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: Tab-delimited report of results + pattern: "*.{txt}" + +authors: + - "@rpetit3" diff --git a/modules/abricate/summary/main.nf b/modules/abricate/summary/main.nf new file mode 100644 index 00000000..b3ba4d58 --- /dev/null +++ b/modules/abricate/summary/main.nf @@ -0,0 +1,33 @@ +process ABRICATE_SUMMARY { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::abricate=1.0.1" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/abricate%3A1.0.1--ha8f3691_1': + 'quay.io/biocontainers/abricate:1.0.1--ha8f3691_1' }" + + input: + tuple val(meta), path(reports) + + output: + tuple val(meta), path("*.txt"), emit: report + 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}" + """ + abricate \\ + --summary \\ + $reports > ${prefix}.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + abricate: \$(echo \$(abricate --version 2>&1) | sed 's/^.*abricate //' ) + END_VERSIONS + """ +} diff --git a/modules/abricate/summary/meta.yml b/modules/abricate/summary/meta.yml new file mode 100644 index 00000000..b02ba930 --- /dev/null +++ b/modules/abricate/summary/meta.yml @@ -0,0 +1,43 @@ +name: abricate_summary +description: Screen assemblies for antimicrobial resistance against multiple databases +keywords: + - bacteria + - assembly + - antimicrobial reistance +tools: + - abricate: + description: Mass screening of contigs for antibiotic resistance genes + homepage: https://github.com/tseemann/abricate + documentation: https://github.com/tseemann/abricate + tool_dev_url: https://github.com/tseemann/abricate + doi: "" + licence: ['GPL v2', 'GPL v2'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - assembly: + type: file + description: FASTA, GenBank or EMBL formatted file + pattern: "*.{fa,fasta,fna,fa.gz,fasta.gz,fna.gz,gbk,gbk.gz,embl,embl.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" + - summary: + type: file + description: Tab-delimited report of aggregated results + pattern: "*.{txt}" + +authors: + - "@rpetit3" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index a053a57c..8752765f 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -2,6 +2,14 @@ abacas: - modules/abacas/** - tests/modules/abacas/** +abricate/run: + - modules/abricate/run/** + - tests/modules/abricate/run/** + +abricate/summary: + - modules/abricate/summary/** + - tests/modules/abricate/summary/** + adapterremoval: - modules/adapterremoval/** - tests/modules/adapterremoval/** diff --git a/tests/modules/abricate/run/main.nf b/tests/modules/abricate/run/main.nf new file mode 100644 index 00000000..19d1f8a8 --- /dev/null +++ b/tests/modules/abricate/run/main.nf @@ -0,0 +1,15 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ABRICATE_RUN } from '../../../../modules/abricate/run/main.nf' + +workflow test_abricate_run { + + input = [ + [ id:'test', single_end:false ], // meta map + file(params.test_data['bacteroides_fragilis']['genome']['genome_fna_gz'], checkIfExists: true) + ] + + ABRICATE_RUN ( input ) +} diff --git a/tests/modules/abricate/run/nextflow.config b/tests/modules/abricate/run/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/abricate/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/abricate/run/test.yml b/tests/modules/abricate/run/test.yml new file mode 100644 index 00000000..3377623c --- /dev/null +++ b/tests/modules/abricate/run/test.yml @@ -0,0 +1,10 @@ +- name: abricate run + command: nextflow run tests/modules/abricate/run -entry test_abricate_run -c tests/config/nextflow.config + tags: + - abricate + - abricate/run + files: + - path: output/abricate/test.txt + md5sum: cd07e2953b127aed8d09bf1b2b903a1f + - path: output/abricate/versions.yml + md5sum: ae9cafaae96a644bb852e337aa7251f3 diff --git a/tests/modules/abricate/summary/main.nf b/tests/modules/abricate/summary/main.nf new file mode 100644 index 00000000..9acbdba9 --- /dev/null +++ b/tests/modules/abricate/summary/main.nf @@ -0,0 +1,21 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { ABRICATE_RUN } from '../../../../modules/abricate/run/main.nf' +include { ABRICATE_SUMMARY } from '../../../../modules/abricate/summary/main.nf' + +workflow test_abricate_summary { + + inputs = [ + tuple([ id:'test1', single_end:false ], // meta map + file(params.test_data['bacteroides_fragilis']['genome']['genome_fna_gz'], checkIfExists: true)), + tuple([ id:'test2', single_end:false ], + file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true)) + ] + + ABRICATE_RUN ( Channel.fromList(inputs) ) + ABRICATE_SUMMARY ( + ABRICATE_RUN.out.report.collect{ meta, report -> report }.map{ report -> [[ id: 'test_summary'], report]} + ) +} diff --git a/tests/modules/abricate/summary/nextflow.config b/tests/modules/abricate/summary/nextflow.config new file mode 100644 index 00000000..50f50a7a --- /dev/null +++ b/tests/modules/abricate/summary/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/abricate/summary/test.yml b/tests/modules/abricate/summary/test.yml new file mode 100644 index 00000000..abbd747b --- /dev/null +++ b/tests/modules/abricate/summary/test.yml @@ -0,0 +1,14 @@ +- name: abricate summary + command: nextflow run tests/modules/abricate/summary -entry test_abricate_summary -c tests/config/nextflow.config + tags: + - abricate + - abricate/summary + files: + - path: output/abricate/test1.txt + md5sum: cd07e2953b127aed8d09bf1b2b903a1f + - path: output/abricate/test2.txt + md5sum: 69af3321b0bc808b7ef85f102395736f + - path: output/abricate/test_summary.txt + md5sum: a4ec7010e75404ce3a1033f0c4b4a7f9 + - path: output/abricate/versions.yml + md5sum: a18f0471c49e5f25ec0b0c4ad5fab08e