Skip to content

Commit

Permalink
Update Abricate to include (missing) additional optional input channe…
Browse files Browse the repository at this point in the history
…l and add stub (nf-core#5849)

* Add missing optional input channel to abricate

* Update abricate module to include missing optional input path

* Update modules/nf-core/abricate/run/tests/main.nf.test

Co-authored-by: Carson J Miller <[email protected]>

* Fix linting

* Update modules/nf-core/abricate/run/main.nf

* Get downstream module test

---------

Co-authored-by: Carson J Miller <[email protected]>
  • Loading branch information
jfy133 and CarsonJM authored Jun 19, 2024
1 parent be84844 commit d19df06
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 4 deletions.
19 changes: 18 additions & 1 deletion modules/nf-core/abricate/run/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ process ABRICATE_RUN {

input:
tuple val(meta), path(assembly)
path databasedir

output:
tuple val(meta), path("*.txt"), emit: report
Expand All @@ -20,11 +21,27 @@ process ABRICATE_RUN {
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def datadir = databasedir ? "--datadir ${databasedir}" : ''
"""
abricate \\
$assembly \\
$args \\
--threads $task.cpus > ${prefix}.txt
$datadir \\
--threads $task.cpus \\
> ${prefix}.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
abricate: \$(echo \$(abricate --version 2>&1) | sed 's/^.*abricate //' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def datadir = databasedir ? '--datadir ${databasedir}' : ''
"""
touch ${prefix}.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
4 changes: 4 additions & 0 deletions modules/nf-core/abricate/run/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ input:
type: file
description: FASTA, GenBank or EMBL formatted file
pattern: "*.{fa,fasta,fna,fa.gz,fasta.gz,fna.gz,gbk,gbk.gz,embl,embl.gz}"
- databasedir:
type: directory
description: Optional location of local copy of database files, possibly with custom databases set up with `abricate --setupdb`
pattern: "*/"
output:
- meta:
type: map
Expand Down
30 changes: 29 additions & 1 deletion modules/nf-core/abricate/run/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ nextflow_process {
tag "abricate"
tag "abricate/run"

test("Should run without failures") {
test("bacteroides_fragilis - genome.fa.gz") {

when {
params {
Expand All @@ -20,6 +20,34 @@ nextflow_process {
[ id:'test', single_end:false ], // meta map
file(params.test_data['bacteroides_fragilis']['genome']['genome_fna_gz'], checkIfExists: true)
]
input[1] = []
"""
}
}

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

test("bacteroides_fragilis - genome - stub") {

options "-stub"

when {
params {
outdir = "$outputDir"
}
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
file(params.test_data['bacteroides_fragilis']['genome']['genome_fna_gz'], checkIfExists: true)
]
input[1] = []
"""
}
}
Expand Down
43 changes: 41 additions & 2 deletions modules/nf-core/abricate/run/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
{
"Should run without failures": {
"bacteroides_fragilis - genome - stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
"versions.yml:md5,2204fb00277c287f5f3d82e28964aa03"
],
"report": [
[
{
"id": "test",
"single_end": false
},
"test.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,2204fb00277c287f5f3d82e28964aa03"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-19T21:06:27.483697023"
},
"bacteroides_fragilis - genome": {
"content": [
{
"0": [
Expand Down Expand Up @@ -28,6 +63,10 @@
]
}
],
"timestamp": "2023-10-15T10:06:00.77835847"
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-19T21:06:20.036490495"
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/abricate/summary/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ nextflow_process {
tag "modules_nfcore"
tag "abricate"
tag "abricate/summary"
tag "abricate/run"

test("Should run without failures") {

Expand All @@ -21,6 +22,7 @@ nextflow_process {
tuple([ id:'test2', single_end:false ],
file(params.test_data['haemophilus_influenzae']['genome']['genome_fna_gz'], checkIfExists: true))
])
input[1] = []
"""
}
}
Expand Down

0 comments on commit d19df06

Please sign in to comment.