Skip to content

Commit

Permalink
Added nf-test for ivar/consensus (#6568)
Browse files Browse the repository at this point in the history
* Added nf-test for ivar/consensus

* Verion bump
  • Loading branch information
GallVp authored Sep 6, 2024
1 parent 99a7e61 commit 5cc90b8
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 67 deletions.
3 changes: 1 addition & 2 deletions modules/nf-core/ivar/consensus/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ name: ivar_consensus
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- bioconda::ivar=1.4
- bioconda::ivar=1.4.3
18 changes: 16 additions & 2 deletions modules/nf-core/ivar/consensus/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ process IVAR_CONSENSUS {

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ivar:1.4--h6b7c446_1' :
'biocontainers/ivar:1.4--h6b7c446_1' }"
'https://depot.galaxyproject.org/singularity/ivar:1.4.3--h43eeafb_0' :
'biocontainers/ivar:1.4.3--h43eeafb_0' }"

input:
tuple val(meta), path(bam)
Expand Down Expand Up @@ -43,4 +43,18 @@ process IVAR_CONSENSUS {
ivar: \$(echo \$(ivar version 2>&1) | sed 's/^.*iVar version //; s/ .*\$//')
END_VERSIONS
"""

stub:
def prefix = task.ext.prefix ?: "${meta.id}"
def touch_mpileup = save_mpileup ? "touch ${prefix}.mpileup" : ''
"""
touch ${prefix}.fa
touch ${prefix}.qual.txt
$touch_mpileup
cat <<-END_VERSIONS > versions.yml
"${task.process}":
ivar: \$(echo \$(ivar version 2>&1) | sed 's/^.*iVar version //; s/ .*\$//')
END_VERSIONS
"""
}
100 changes: 100 additions & 0 deletions modules/nf-core/ivar/consensus/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

nextflow_process {

name "Test Process IVAR_CONSENSUS"
script "../main.nf"
process "IVAR_CONSENSUS"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "ivar"
tag "ivar/consensus"

test("test-ivar-consensus") {

when {
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[2] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.fasta,
file(process.out.qual[0][1]).name, // empty
process.out.mpileup,
process.out.versions,
file(process.out.versions[0]).readLines().collect { it.trim() } // Trap to catch conda version mismatches
).match()
}
)
}
}

test("test-ivar-consensus-mpileup") {

when {
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[2] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.fasta,
file(process.out.qual[0][1]).name, // empty
file(process.out.mpileup[0][1]).name, // empty
process.out.versions
).match()
}
)
}
}

test("test-ivar-consensus-mpileup-stub") {
options '-stub'

when {
process {
"""
input[0] = [
[ id:'test'],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.bam', checkIfExists: true)
]
input[1] = file(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
input[2] = true
"""
}
}

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

}
117 changes: 117 additions & 0 deletions modules/nf-core/ivar/consensus/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"test-ivar-consensus-mpileup-stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.fa:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "test"
},
"test.qual.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
[
{
"id": "test"
},
"test.mpileup:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"3": [
"versions.yml:md5,e652db2cbd4a8cd9b7482a01abe5e6b3"
],
"fasta": [
[
{
"id": "test"
},
"test.fa:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"mpileup": [
[
{
"id": "test"
},
"test.mpileup:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"qual": [
[
{
"id": "test"
},
"test.qual.txt:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,e652db2cbd4a8cd9b7482a01abe5e6b3"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-06T14:58:57.447441"
},
"test-ivar-consensus-mpileup": {
"content": [
[
[
{
"id": "test"
},
"test.fa:md5,9e21a64818f4302b4dece5480fa5e8b8"
]
],
"test.qual.txt",
"test.mpileup",
[
"versions.yml:md5,e652db2cbd4a8cd9b7482a01abe5e6b3"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-06T14:58:52.938906"
},
"test-ivar-consensus": {
"content": [
[
[
{
"id": "test"
},
"test.fa:md5,9e21a64818f4302b4dece5480fa5e8b8"
]
],
"test.qual.txt",
[

],
[
"versions.yml:md5,e652db2cbd4a8cd9b7482a01abe5e6b3"
],
[
"\"IVAR_CONSENSUS\":",
"ivar: 1.4.3"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-06T14:58:48.289344"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/ivar/consensus/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: IVAR_CONSENSUS {
ext.args2 = '-aa -A -d 0 -Q 0'
}
}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,6 @@ iphop/download:
iphop/predict:
- modules/nf-core/iphop/predict/**
- tests/modules/nf-core/iphop/predict/**
ivar/consensus:
- modules/nf-core/ivar/consensus/**
- tests/modules/nf-core/ivar/consensus/**
ivar/variants:
- modules/nf-core/ivar/variants/**
- tests/modules/nf-core/ivar/variants/**
Expand Down
29 changes: 0 additions & 29 deletions tests/modules/nf-core/ivar/consensus/main.nf

This file was deleted.

9 changes: 0 additions & 9 deletions tests/modules/nf-core/ivar/consensus/nextflow.config

This file was deleted.

22 changes: 0 additions & 22 deletions tests/modules/nf-core/ivar/consensus/test.yml

This file was deleted.

0 comments on commit 5cc90b8

Please sign in to comment.