Skip to content

Commit

Permalink
Update rgi/main to 6.0.3 (#4933)
Browse files Browse the repository at this point in the history
* First attempt to include download of databases

* Update module files + add nf-test (almost working)

* Added stub + snapshot file + many fixes

* Make rgi/main work with CARD download

* Fix linting

* Update depency `hamronization/rgi`

* Fix command in `main.nf`

* Fix `hamronization/rgi` accordingly

* Removed DB download functionality

* Removed hamronization/rgi non-stub test

* Update meta.yml

* Add module rgi/cardannotation (not working yet)

* Make rgi/main tests work incl. dependency rgi/cardannotation

* Fix hamronization/rgi tests

* Update rgi/cardannotation snapfile

* Apply suggestions from code review
  • Loading branch information
jasmezz authored Feb 24, 2024
1 parent 874dace commit 483e483
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 87 deletions.
34 changes: 31 additions & 3 deletions modules/nf-core/hamronization/rgi/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,50 @@ nextflow_process {
tag "hamronization"
tag "hamronization/rgi"
tag "rgi/main"
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('data.tar.gz')
input[0] = [
[ ],
file("data.tar.gz")
]
"""
}
}

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

run("RGI_MAIN") {
script "../../../rgi/main/main.nf"
script "modules/nf-core/rgi/main/main.nf"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true)
]
input[1] = RGI_CARDANNOTATION.out.db
input[2] = []
"""
}
}
}

test("hamronization/amrfinderplus - haemophilus_influenzae - genome - fna.gz") {
test("hamronization/rgi - haemophilus_influenzae - genome - fna.gz") {

when {
process {
Expand All @@ -45,7 +73,7 @@ nextflow_process {
}
}

test("hamronization/amrfinderplus - haemophilus_influenzae - genome - fna.gz - stub") {
test("hamronization/rgi - haemophilus_influenzae - genome - fna.gz - stub") {

options "-stub"

Expand Down
16 changes: 8 additions & 8 deletions modules/nf-core/hamronization/rgi/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions modules/nf-core/rgi/cardannotation/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: rgi_cardannotation
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- bioconda::rgi=6.0.3
61 changes: 61 additions & 0 deletions modules/nf-core/rgi/cardannotation/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
process RGI_CARDANNOTATION {
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.3--pyha8f3691_0':
'biocontainers/rgi:6.0.3--pyha8f3691_0' }"

input:
path(card)

output:
path("card_database_processed") , emit: db
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 ?: ''

"""
rgi card_annotation \\
-i ${card}/card.json \\
$args
DB_VERSION=\$(ls card_database_*_all.fasta | sed "s/card_database_v\\([0-9].*[0-9]\\).*/\\1/")
mkdir card_database_processed
mv card*.fasta card_database_processed
cp ${card}/* card_database_processed
RGI_VERSION=\$(rgi main --version)
cat <<-END_VERSIONS > versions.yml
"${task.process}":
rgi: \$(echo \$RGI_VERSION)
rgi-database: \$(echo \$DB_VERSION)
END_VERSIONS
"""

stub:
"""
touch card.fasta
touch card_all.fasta
mkdir card_database_processed
mv card*.fasta card_database_processed
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
"""
}
42 changes: 42 additions & 0 deletions modules/nf-core/rgi/cardannotation/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: rgi_cardannotation
description: Preprocess the CARD database for RGI to predict antibiotic resistance from protein or nucleotide data
keywords:
- bacteria
- fasta
- antibiotic resistance
tools:
- rgi:
description: This module preprocesses the downloaded Comprehensive Antibiotic Resistance Database (CARD) which can then be used as input for RGI.
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"]
input:
- card:
type: directory
description: Directory containing the CARD database
pattern: "*/"
output:
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- db:
type: directory
description: Directory containing the processed CARD database files
pattern: "*/"
- tool_version:
type: string
description: The version of the tool in string format (useful for downstream tools such as hAMRronization)
- db_version:
type: string
description: The version of the used database in string format (useful for downstream tools such as hAMRronization)
authors:
- "@rpetit3"
- "@jfy133"
- "@jasmezz"
maintainers:
- "@rpetit3"
- "@jfy133"
- "@jasmezz"
66 changes: 66 additions & 0 deletions modules/nf-core/rgi/cardannotation/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "rgi"
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('data.tar.gz')
input[0] = [
[ ],
file("data.tar.gz")
]
"""
}
}
}

test("rgi/cardannotation") {

when {
process {
"""
input[0] = UNTAR.out.untar.map{ it[1] }
"""
}
}

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

test("rgi/cardannotation - stub") {

options "-stub"

when {
process {
"""
input[0] = UNTAR.out.untar.map{ it[1] }
"""
}
}

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

0 comments on commit 483e483

Please sign in to comment.