Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
101 changes: 101 additions & 0 deletions modules/nf-core/rgi/bwt/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
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)
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
env RGI_VERSION, emit: tool_version
env DB_VERSION, emit: db_version
path "versions.yml", emit: versions

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

script:
def args = task.ext.args ?: ''
def use_local = task.ext.local == null ? true : task.ext.local as boolean
// Add this to nextflow.config if not using local:
// withName: RGI_BWT {
// ext.local = false
// }
def local_flag = use_local ? '--local' : ''
// This customizes the command: rgi bwt
def prefix = task.ext.prefix ?: "${meta.id}"
def read_one = reads instanceof List ? reads[0] : reads
def read_two = reads instanceof List && reads.size() > 1 ? reads[1] : null
Copy link
Member

Choose a reason for hiding this comment

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

Please use the nf-core convention of using meta.single to decide how to inject single or paired end reads

Copy link
Member

Choose a reason for hiding this comment

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

An example:

input = meta.single_end ? "in=${fastq.join(',')}" : "in=${fastq[0]} in2=${fastq[1]}"

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't rush on that one, let me discuss with James ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the general consensus was to use meta.single_end for this as James said.

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_flag} \\
--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_flag} \\
--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

RGI_VERSION=\$(rgi main --version)

cat <<-END_VERSIONS > versions.yml
"${task.process}":
rgi: \$(echo \$RGI_VERSION)
rgi-database: \$(echo \$DB_VERSION)
END_VERSIONS
"""

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

RGI_VERSION=\$(rgi main --version)
DB_VERSION=stub_version

cat <<-END_VERSIONS > versions.yml
"${task.process}":
rgi: \$(echo \$RGI_VERSION)
rgi-database: \$(echo \$DB_VERSION)
END_VERSIONS
"""
}
100 changes: 100 additions & 0 deletions modules/nf-core/rgi/bwt/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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: 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: []
- 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/"
tool_version:
- RGI_VERSION:
type: string
description: The version of the tool in string format (useful for
downstream tools such as hAMRronization)
db_version:
- DB_VERSION:
type: string
description: The version of the used database in string format (useful for
downstream tools such as hAMRronization)
versions:
- versions.yml:
type: file
description: File containing software versions
pattern: "versions.yml"
ontologies:
- edam: http://edamontology.org/format_3750 # YAML
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