Skip to content

Commit

Permalink
ADD argNorm module (nf-core#5905)
Browse files Browse the repository at this point in the history
* ADD argnorm module

* ENH correct pattern for 'hamronized' input

* ENH specify hamronization command in script

* ENH don't pass 'hamronized' as val

* Fixed trailing whitespace

* "single_end" is not relevant in this module

* alignment

* "db_args" to avoid any confusion with the input channel

* Added a test to check $tool is provided

* Implemented the stub mode

* Added a test for the missing database

* Reordered the arguments to match the script

---------

Co-authored-by: Matthieu Muffato <[email protected]>
  • Loading branch information
Vedanth-Ramji and muffato authored Jul 8, 2024
1 parent c274982 commit e4fc46a
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/nf-core/argnorm/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "argnorm"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::argnorm=0.5.0"
68 changes: 68 additions & 0 deletions modules/nf-core/argnorm/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
process ARGNORM {
tag "$meta.id"
label 'process_low'
// WARN: Version information not provided by tool on CLI. Please update version string below when bumping container versions.
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/argnorm:0.5.0--pyhdfd78af_0':
'biocontainers/argnorm:0.5.0--pyhdfd78af_0' }"

input:
tuple val(meta), path(input_tsv)
val tool
val db

output:
tuple val(meta), path("*.tsv"), emit: tsv
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 VERSION = '0.5.0' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
def db_args = db ? "--db ${db}" : ""
if (!tool) {
error 'Tool not provided.'
}
if ((tool in ["abricate"]) && !db) {
error "$tool requires a database but <db> not provided."
}

"""
argnorm \\
$tool \\
-i $input_tsv \\
-o $prefix \\
$db_args \\
$args
cat <<-END_VERSIONS > versions.yml
"${task.process}":
argnorm: $VERSION
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def VERSION = '0.5.0' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
if (!tool) {
error 'Tool not provided.'
}
if ((tool in ["abricate"]) && !db) {
error "$tool requires a database but <db> not provided."
}

"""
touch ${prefix}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
argnorm: $VERSION
END_VERSIONS
"""

}
60 changes: 60 additions & 0 deletions modules/nf-core/argnorm/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "argnorm"
description: Normalize antibiotic resistance genes (ARGs) using the ARO ontology (developed by CARD).
keywords:
- amr
- antimicrobial resistance
- arg
- antimicrobial resistance genes
- genomics
- metagenomics
- normalization
- drug categorization
tools:
- "argnorm":
description: "Normalize antibiotic resistance genes (ARGs) using the ARO ontology (developed by CARD)."
homepage: "https://argnorm.readthedocs.io/en/latest/"
documentation: "https://argnorm.readthedocs.io/en/latest/"
tool_dev_url: "https://github.com/BigDataBiology/argNorm"
licence: ["MIT"]

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- input_tsv:
type: file
description: ARG annotation output
pattern: "*.tsv"

- tool:
type: string
description: ARG annotation tool used
pattern: "argsoap|abricate|deeparg|resfinder|amrfinderplus"

- db:
type: string
description: Database used for ARG annotation
pattern: "sarg|ncbi|resfinder|deeparg|megares|argannot|resfinderfg"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- tsv:
type: file
description: Normalized argNorm output
pattern: "*.tsv"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"

authors:
- "@Vedanth-Ramji"
maintainers:
- "@Vedanth-Ramji"
5 changes: 5 additions & 0 deletions modules/nf-core/argnorm/tests/argnorm_hamronized.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: ARGNORM {
ext.args = '--hamronized'
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/argnorm/tests/argnorm_raw.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: ARGNORM {
ext.args = ''
}
}
155 changes: 155 additions & 0 deletions modules/nf-core/argnorm/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
nextflow_process {
name "Test Process ARGNORM"
script "../main.nf"
process "ARGNORM"

tag "modules"
tag "modules_nfcore"
tag "argnorm"

test("argnorm - amrfinderplus_ncbi_raw - tsv") {
config './argnorm_raw.config'

when {
process {
"""
input[0] = [
[ id:'argnorm_raw.tsv' ], // meta map
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/delete_me/amrfinderplus/test_output.tsv", checkIfExists: true)
]
input[1] = 'amrfinderplus'
input[2] = 'ncbi'
"""
}
}

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

test("argnorm - amrfinderplus_ncbi_hamronized - tsv") {
config './argnorm_hamronized.config'

when {
process {
"""
input[0] = [
[ id:'argnorm_hamronized.tsv' ], // meta map
file("https://raw.githubusercontent.com/BigDataBiology/argNorm/main/examples/hamronized/amrfinderplus.ncbi.orfs.tsv", checkIfExists: true)
]
input[1] = 'amrfinderplus'
input[2] = 'ncbi'
"""
}
}

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

test("argnorm - missing tool") {

when {
process {
"""
input[0] = [
[ id:'argnorm_raw.tsv' ], // meta map
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/delete_me/amrfinderplus/test_output.tsv", checkIfExists: true)
]
input[1] = []
input[2] = []
"""
}
}

then {
assertAll(
{ assert !process.success },
{ assert process.stdout.toString().contains("Tool not provided") }
)
}
}

test("argnorm - missing db") {

when {
process {
"""
input[0] = [
[ id:'argnorm_raw.tsv' ], // meta map
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/delete_me/amrfinderplus/test_output.tsv", checkIfExists: true)
]
input[1] = "abricate"
input[2] = []
"""
}
}

then {
assertAll(
{ assert !process.success },
{ assert process.stdout.toString().contains("abricate requires a database but <db> not provided.") }
)
}
}

test("argnorm - amrfinderplus_ncbi_hamronized - tsv - stub") {
options "-stub"
config './argnorm_hamronized.config'

when {
process {
"""
input[0] = [
[ id:'argnorm_hamronized_stub.tsv' ], // meta map
file("https://raw.githubusercontent.com/BigDataBiology/argNorm/main/examples/hamronized/amrfinderplus.ncbi.orfs.tsv", checkIfExists: true)
]
input[1] = 'amrfinderplus'
input[2] = 'ncbi'
"""
}
}

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

test("argnorm - amrfinderplus_ncbi - tsv - stub") {

options "-stub"
config './argnorm_raw.config'

when {
process {
"""
input[0] = [
[ id:'argnorm_raw_stub.tsv' ], // meta map
file("https://raw.githubusercontent.com/BigDataBiology/argNorm/main/examples/raw/amrfinderplus.ncbi.orfs.tsv", checkIfExists: true)
]
input[1] = 'amrfinderplus'
input[2] = 'ncbi'
"""
}
}

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

}
Loading

0 comments on commit e4fc46a

Please sign in to comment.