Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
75f95ec
rgi/bwt: add draft
vinisalazar Dec 18, 2025
42bf5c7
rgi/bwt: editing input channel
vinisalazar Dec 18, 2025
77ec4ba
rgi/bwt: edit meta.yaml
vinisalazar Dec 18, 2025
fe0039c
rgi/bwt: update meta.yaml
vinisalazar Dec 18, 2025
6252f12
rgi/bwt: add test snapshot
vinisalazar Dec 18, 2025
738ffc3
rgi/bwt: add '--local' flag
vinisalazar Dec 18, 2025
47300b4
rgi/bwt: update snapshot
vinisalazar Dec 18, 2025
c95108c
rgi/bwt: fix tests
vinisalazar Dec 18, 2025
e90b13c
rgi/bwt: continue to fix tests
vinisalazar Dec 18, 2025
8db0574
rgi/bwt: remove json from snapshots
vinisalazar Dec 18, 2025
fdf2574
Merge branch 'master' into rgi/bwt
vinisalazar Dec 30, 2025
cd2faf4
rgi/bwt: remove task.ext value
vinisalazar Dec 30, 2025
c167336
rgi/bwt: move version to topics output
vinisalazar Jan 15, 2026
6efbbe3
rgi/bwt: update meta.yml
vinisalazar Jan 15, 2026
668cf72
Merge branch 'master' into rgi/bwt
SPPearce Jan 15, 2026
b1f3cae
Apply suggestions from code review
vinisalazar Jan 18, 2026
8903429
rgi/bwt: fix tests and linting
vinisalazar Jan 20, 2026
a63bb29
rgi/bwt: formatting
vinisalazar Jan 20, 2026
6647bb8
rgi/bwt: formatting
vinisalazar Jan 20, 2026
60c83c3
rgi/bwt: formatting
vinisalazar Jan 20, 2026
32bba94
rgi/bwt: formatting
vinisalazar Feb 3, 2026
2bd82c1
rgi/bwt: update snapshot
vinisalazar Feb 4, 2026
d8637d4
Merge branch 'master' into rgi/bwt
mashehu Feb 4, 2026
052fe23
rgi/bwt: fix module test dataset path
vinisalazar Feb 5, 2026
f218a8b
rgi/bwt: update branch
vinisalazar Feb 5, 2026
c16ebaf
Merge branch 'master' into rgi/bwt
SPPearce Feb 5, 2026
10334f4
rgi/bwt: apply suggestions from code review (#9873)
vinisalazar Feb 5, 2026
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
81 changes: 81 additions & 0 deletions modules/nf-core/rgi/bwt/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
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 \\
${args2} \\
--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
"""
}
126 changes: 126 additions & 0 deletions modules/nf-core/rgi/bwt/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
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: Command used to collect the version
- - ${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: Command used to collect the version

authors:
- "@vinisalazar"
maintainers:
- "@nickp60"
- "@vinisalazar"
95 changes: 95 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,95 @@
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')
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't like to use externally hosted files, as they can sometimes become missing over time. How big is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SPPearce thanks again for the review. The file is 4.5 Mb. What would be the best practice in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Best practice will be to make a PR into the test-datasets repository then.
Could you make it any smaller than that?
That is quite annoyingly finnicky (and redoing how we do test-datasets has been on the to-do list for a long time now).

  1. Make the file smaller if possible, but still let the tool run.
  2. Shallow clone nf-core/test-datasets, just the modules branch.
  3. Make a PR adding the file into an appropriate place. Please don't put it in delete_me, find somewhere more appropriate.
  4. Once the PR is in, you can refer to the file like the others in the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @SPPearce. PR created, see below.


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.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test_2.fastq.gz', checkIfExists: true),
]
]
input[1] = RGI_CARDANNOTATION.out.db
input[2] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.findAll { key, val -> key.startsWith("versions") },
file(process.out.tmp.get(0).get(1)).list().sort(),
).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.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/fastq/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