Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/nf-core/rgi/bwt/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
channels:
- conda-forge
- bioconda
dependencies:
- bioconda::rgi=6.0.5
82 changes: 82 additions & 0 deletions modules/nf-core/rgi/bwt/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
process RGI_BWT {
tag "${meta.id}"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
? 'https://depot.galaxyproject.org/singularity/rgi:6.0.5--pyh05cac1d_0'
: 'biocontainers/rgi:6.0.5--pyh05cac1d_0'}"

input:
tuple val(meta), path(reads, arity: '1..2')
path card
path wildcard

output:
tuple val(meta), path("*.json"), emit: json
tuple val(meta), path("*.txt"), emit: tsv
tuple val(meta), path("temp/"), emit: tmp
tuple val("${task.process}"), val('rgi') , eval('rgi main --version') , emit: versions_rgi, topic: versions
tuple val("${task.process}"), val('rgi-database'), eval('echo $DB_VERSION') , emit: versions_db , topic: versions

when:
task.ext.when == null || task.ext.when

script:
// This customizes the command: rgi load
def args = task.ext.args ?: ''
// This customizes the command: rgi main
def args2 = task.ext.args2 ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def read_one = reads[0]
def read_two = reads.size() > 1 ? reads[1] : null
def load_wildcard = ""

if (wildcard) {
load_wildcard = """ \\
--wildcard_annotation ${wildcard}/wildcard_database_v\$DB_VERSION.fasta \\
--wildcard_annotation_all_models ${wildcard}/wildcard_database_v\$DB_VERSION\\_all.fasta \\
--wildcard_index ${wildcard}/wildcard/index-for-model-sequences.txt \\
--amr_kmers ${wildcard}/wildcard/all_amr_61mers.txt \\
--kmer_database ${wildcard}/wildcard/61_kmer_db.json \\
--kmer_size 61
"""
}

"""
DB_VERSION=\$(ls ${card}/card_database_*_all.fasta | sed "s/${card}\\/card_database_v\\([0-9].*[0-9]\\).*/\\1/")

rgi \\
load \\
${args} \\
--local \\
--card_json ${card}/card.json \\
--debug \\
--card_annotation ${card}/card_database_v\$DB_VERSION.fasta \\
--card_annotation_all_models ${card}/card_database_v\$DB_VERSION\\_all.fasta \\
${load_wildcard}

rgi \\
bwt \\
${args} \\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${args} \\
${args2} \\

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, where exactly would this args2 come from?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the ext.args variables are defined in pipelines' modules.config file. You need one args variable for each command/section of a piped command 1, so you don't duplicate the same argument for two diffren tools/subcommands

Footnotes

  1. https://nf-co.re/docs/guidelines/components/modules#each-command-must-have-an-args-variable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e., in this case you don't use it for anything (even if it has to be there) but it would be defined in the pipeline logic :)

--local \\
--threads ${task.cpus} \\
--output_file ${prefix} \\
--read_one ${read_one} \\
${ read_two ? "--read_two ${read_two}" : "" }


mkdir temp/
for FILE in *.xml *.fsa *.{nhr,nin,nsq} *.draft *.potentialGenes *{variant,rrna,protein,predictedGenes,overexpression,homolog}.json; do [[ -e \$FILE ]] && mv \$FILE temp/; done

"""

stub:
"""
mkdir -p temp
touch test.json
touch test.txt

DB_VERSION=stub_version
"""
}
117 changes: 117 additions & 0 deletions modules/nf-core/rgi/bwt/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: rgi_bwt
description: Predict antibiotic resistance from protein or nucleotide data
keywords:
- bacteria
- fasta
- antibiotic resistance
tools:
- rgi:
description: This tool provides a preliminary annotation of your DNA
sequence(s) based upon the data available in The Comprehensive Antibiotic
Resistance Database (CARD). Hits to genes tagged with Antibiotic
Resistance ontology terms will be highlighted. As CARD expands to include
more pathogens, genomes, plasmids, and ontology terms this tool will grow
increasingly powerful in providing first-pass detection of antibiotic
resistance associated genes. See license at CARD website.
homepage: https://card.mcmaster.ca
documentation: https://github.com/arpcard/rgi
tool_dev_url: https://github.com/arpcard/rgi
doi: "10.1093/nar/gkz935"
licence: ["https://card.mcmaster.ca/about"]
identifier: ""
input:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- reads:
type: file
description: Single-end or paired-end nucleotide sequences in FASTQ or FASTA format
pattern: "*.{fastq,fastq.gz,fq,fq.gz,fasta,fasta.gz,fa,fa.gz,fna,fna.gz,faa,faa.gz}"
ontologies:
- edam: http://edamontology.org/format_1930 # FASTQ
- card:
type: directory
description: Directory containing the CARD database. This is expected to be
the unarchived but otherwise unaltered download folder (see RGI
documentation for download instructions).
pattern: "*/"
- wildcard:
type: directory
description: Directory containing the WildCARD database (optional). This is
expected to be the unarchived but otherwise unaltered download folder (see
RGI documentation for download instructions).
pattern: "*/"
output:
json:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- "*.json":
type: file
description: JSON formatted file with RGI results
pattern: "*.{json}"
ontologies:
- edam: http://edamontology.org/format_3464 # JSON
tsv:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- "*.txt":
type: file
description: Tab-delimited file with RGI results
pattern: "*.{txt}"
ontologies: []
tmp:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- temp/:
type: directory
description: Directory containing various intermediate files
pattern: "temp/"
versions_rgi:
- - ${task.process}:
type: string
description: The process the versions were collected from
- rgi:
type: string
description: The tool name
- rgi main --version:
type: string
description: The version string returned by the command
versions_db:
- - ${task.process}:
type: string
description: The process the versions were collected from
- rgi-database:
type: string
description: The tool name
- echo $DB_VERSION:
type: string
description: The CARD database version string

topics:
versions:
- - ${task.process}:
type: string
description: The process the versions were collected from
- rgi:
type: string
description: The tool name
- rgi main --version:
type: string
description: The command used to generate the version of the tool

authors:
- "@vinisalazar"
maintainers:
- "@nickp60"
- "@vinisalazar"
97 changes: 97 additions & 0 deletions modules/nf-core/rgi/bwt/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
nextflow_process {

name "Test Process RGI_BWT"
script "../main.nf"
process "RGI_BWT"

tag "modules"
tag "modules_nfcore"
tag "rgi"
tag "rgi/bwt"
tag "rgi/cardannotation"
tag "untar"

setup {
run("UNTAR") {
script "modules/nf-core/untar/main.nf"
process {
"""
file('https://card.mcmaster.ca/latest/data', checkIfExists: true).copyTo('card-data.tar.bz2')

input[0] = [
[ ],
file("card-data.tar.bz2")
]
"""
}
}

run("RGI_CARDANNOTATION") {
script "modules/nf-core/rgi/cardannotation"
process {
"""
input[0] = UNTAR.out.untar.map{ it[1] }
"""
}
}
}

test("rgi/bwt - homo_sapiens - test_fastq_gz") {

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_2_fastq_gz'], checkIfExists: true),
]
]
input[1] = RGI_CARDANNOTATION.out.db
input[2] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.versions,
file(process.out.tmp.get(0).get(1)).list().sort(),
process.out.tool_version,
process.out.db_version,
).match() }
)
}
}

test("rgi/bwt - homo_sapiens - test_fastq_gz - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.test_data['homo_sapiens']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_2_fastq_gz'], checkIfExists: true),
]
]
input[1] = RGI_CARDANNOTATION.out.db
input[2] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
Loading
Loading