From 45466684e7d933057054c28c160d27628852390c Mon Sep 17 00:00:00 2001 From: "Robert A. Petit III" Date: Fri, 18 Feb 2022 17:52:38 -0700 Subject: [PATCH] add mobsuite_recon module (#1270) * add mobsuite_recon module * Update main.nf * Update nextflow.config * Update test.yml Co-authored-by: Sateesh <33637490+sateeshperi@users.noreply.github.com> --- modules/mobsuite/recon/main.nf | 45 ++++++++++++++++ modules/mobsuite/recon/meta.yml | 54 ++++++++++++++++++++ tests/config/pytest_modules.yml | 4 ++ tests/modules/mobsuite/recon/main.nf | 13 +++++ tests/modules/mobsuite/recon/nextflow.config | 5 ++ tests/modules/mobsuite/recon/test.yml | 12 +++++ 6 files changed, 133 insertions(+) create mode 100644 modules/mobsuite/recon/main.nf create mode 100644 modules/mobsuite/recon/meta.yml create mode 100644 tests/modules/mobsuite/recon/main.nf create mode 100644 tests/modules/mobsuite/recon/nextflow.config create mode 100644 tests/modules/mobsuite/recon/test.yml diff --git a/modules/mobsuite/recon/main.nf b/modules/mobsuite/recon/main.nf new file mode 100644 index 00000000..9ca7e180 --- /dev/null +++ b/modules/mobsuite/recon/main.nf @@ -0,0 +1,45 @@ +process MOBSUITE_RECON { + tag "$meta.id" + label 'process_medium' + + conda (params.enable_conda ? "bioconda::mob_suite=3.0.3" : null) + container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? + 'https://depot.galaxyproject.org/singularity/mob_suite%3A3.0.3--pyhdfd78af_0': + 'quay.io/biocontainers/mob_suite:3.0.3--pyhdfd78af_0' }" + + input: + tuple val(meta), path(fasta) + + output: + tuple val(meta), path("results/chromosome.fasta") , emit: chromosome + tuple val(meta), path("results/contig_report.txt") , emit: contig_report + tuple val(meta), path("results/plasmid_*.fasta") , emit: plasmids , optional: true + tuple val(meta), path("results/mobtyper_results.txt"), emit: mobtyper_results, optional: true + 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}" + def is_compressed = fasta.getName().endsWith(".gz") ? true : false + def fasta_name = fasta.getName().replace(".gz", "") + """ + if [ "$is_compressed" == "true" ]; then + gzip -c -d $fasta > $fasta_name + fi + + mob_recon \\ + --infile $fasta_name \\ + $args \\ + --num_threads $task.cpus \\ + --outdir results \\ + --sample_id $prefix + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + mobsuite: \$(echo \$(mob_recon --version 2>&1) | sed 's/^.*mob_recon //; s/ .*\$//') + END_VERSIONS + """ +} diff --git a/modules/mobsuite/recon/meta.yml b/modules/mobsuite/recon/meta.yml new file mode 100644 index 00000000..b5232142 --- /dev/null +++ b/modules/mobsuite/recon/meta.yml @@ -0,0 +1,54 @@ +name: mobsuite_recon +description: A tool to reconstruct plasmids in bacterial assemblies +keywords: + - bacteria + - plasmid +tools: + - mobsuite: + description: Software tools for clustering, reconstruction and typing of plasmids from draft assemblies. + homepage: https://github.com/phac-nml/mob-suite + documentation: https://github.com/phac-nml/mob-suite + tool_dev_url: https://github.com/phac-nml/mob-suite + doi: "10.1099/mgen.0.000435" + licence: ['Apache License, Version 2.0'] + +input: + - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test', single_end:false ] + - fasta: + type: file + description: A bacterial genome assembly in FASTA format + pattern: "*.{fasta,fa,fna}" + +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" + - chromosome: + type: file + description: FASTA file of all contigs found to belong to the chromosome + pattern: "chromosome.fasta" + - contig_report: + type: file + description: Assignment of the contig to chromosome or a particular plasmid grouping + pattern: "contig_report.txt" + - plasmids: + type: file + description: Each plasmid group is written to an individual FASTA + pattern: "plasmid_*.fasta" + - mobtyper_results: + type: file + description: Aggregate MOB-typer report files for all identified plasmid + pattern: "mobtyper_results.txt" + +authors: + - "@rpetit3" diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 8cc03dd3..a053a57c 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -1024,6 +1024,10 @@ mlst: - modules/mlst/** - tests/modules/mlst/** +mobsuite/recon: + - modules/mobsuite/recon/** + - tests/modules/mobsuite/recon/** + mosdepth: - modules/mosdepth/** - tests/modules/mosdepth/** diff --git a/tests/modules/mobsuite/recon/main.nf b/tests/modules/mobsuite/recon/main.nf new file mode 100644 index 00000000..0d18ef9c --- /dev/null +++ b/tests/modules/mobsuite/recon/main.nf @@ -0,0 +1,13 @@ +#!/usr/bin/env nextflow + +nextflow.enable.dsl = 2 + +include { MOBSUITE_RECON } from '../../../../modules/mobsuite/recon/main.nf' + +workflow test_mobsuite_recon { + + input = [ [ id:'test', single_end:false ], // meta map + file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ] + + MOBSUITE_RECON ( input ) +} diff --git a/tests/modules/mobsuite/recon/nextflow.config b/tests/modules/mobsuite/recon/nextflow.config new file mode 100644 index 00000000..06a716aa --- /dev/null +++ b/tests/modules/mobsuite/recon/nextflow.config @@ -0,0 +1,5 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + +} diff --git a/tests/modules/mobsuite/recon/test.yml b/tests/modules/mobsuite/recon/test.yml new file mode 100644 index 00000000..dfff835b --- /dev/null +++ b/tests/modules/mobsuite/recon/test.yml @@ -0,0 +1,12 @@ +- name: mobsuite recon test_mobsuite_recon + command: nextflow run tests/modules/mobsuite/recon -entry test_mobsuite_recon -c tests/config/nextflow.config + tags: + - mobsuite/recon + - mobsuite + files: + - path: output/mobsuite/results/chromosome.fasta + md5sum: 33b2a0fa321c73c6ba8d8272dd53c6d4 + - path: output/mobsuite/results/contig_report.txt + md5sum: a0ae364a9f2b475f77588d0b3c24b857 + - path: output/mobsuite/versions.yml + md5sum: 7f7a0f8957394b0e526233a0edb8e20a