Skip to content

Commit

Permalink
METABAT2_METABAT2: Add nf-test and stub (#7196)
Browse files Browse the repository at this point in the history
* Add stub

* Add nf-test (empty TSV for depth test expected)

* Update modules/nf-core/metabat2/metabat2/tests/main.nf.test

* Apply suggestions from code review

* Use name for expected empty file
  • Loading branch information
jfy133 authored Dec 11, 2024
1 parent 7860035 commit 299a26f
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 69 deletions.
19 changes: 19 additions & 0 deletions modules/nf-core/metabat2/metabat2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,23 @@ process METABAT2_METABAT2 {
metabat2: \$( metabat2 --help 2>&1 | head -n 2 | tail -n 1| sed 's/.*\\:\\([0-9]*\\.[0-9]*\\).*/\\1/' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def decompress_depth = depth ? "gzip -d -f $depth" : ""
def depth_file = depth ? "-a ${depth.baseName}" : ""

"""
echo "" | gzip -c > ${prefix}.1.fa.gz
echo "" | gzip -c > ${prefix}.1.tooShort.fa.gz
echo "" | gzip -c > ${prefix}.1.lowDepth.fa.gz
echo "" | gzip -c > ${prefix}.1.unbinned.fa.gz
echo "" | gzip -c > ${prefix}.tsv.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
metabat2: \$( metabat2 --help 2>&1 | head -n 2 | tail -n 1| sed 's/.*\\:\\([0-9]*\\.[0-9]*\\).*/\\1/' )
END_VERSIONS
"""
}
99 changes: 99 additions & 0 deletions modules/nf-core/metabat2/metabat2/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// nf-core modules test metabat2/metabat2
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "metabat2"
tag "metabat2/metabat2"
tag "metabat2/jgisummarizebamcontigdepths"

test("sarscov2 - genome - fasta") {

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

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

}

test("sarscov2 - genome - fasta - depths") {

setup {
run("METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS") {
script "../../jgisummarizebamcontigdepths/main.nf"
process {
"""
input[0] = [
[id: 'test', single_end: false],
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true),
]
"""
}
}
}

when {
process {
"""
input[0] = Channel
.fromPath(params.modules_testdata_base_path + 'genomics/sarscov2/genome/genome.fasta', checkIfExists: true)
.map { it -> [[ id:'test', single_end:false ], it] }
.join(METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS.out.depth)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.membership[0][1]).name).match() }
)
}

}

test("sarscov2 - genome - fasta - stub") {

options "-stub"

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

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

}

}
178 changes: 178 additions & 0 deletions modules/nf-core/metabat2/metabat2/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
{
"sarscov2 - genome - fasta": {
"content": [
{
"0": [

],
"1": [

],
"2": [

],
"3": [
[
{
"id": "test",
"single_end": false
},
"test.tsv.gz:md5,f50e2528d24fcd9a200cae3421945f05"
]
],
"4": [

],
"5": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
],
"fasta": [

],
"lowdepth": [

],
"membership": [
[
{
"id": "test",
"single_end": false
},
"test.tsv.gz:md5,f50e2528d24fcd9a200cae3421945f05"
]
],
"tooshort": [

],
"unbinned": [

],
"versions": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-11T12:28:01.970872008"
},
"sarscov2 - genome - fasta - depths": {
"content": [
"test.tsv.gz"
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-11T13:08:47.777561763"
},
"sarscov2 - genome - fasta - stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test.1.tooShort.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"1": [
[
{
"id": "test",
"single_end": false
},
"test.1.lowDepth.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"2": [
[
{
"id": "test",
"single_end": false
},
"test.1.unbinned.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"3": [
[
{
"id": "test",
"single_end": false
},
"test.tsv.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"4": [
[
{
"id": "test",
"single_end": false
},
"test.1.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"5": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
],
"fasta": [
[
{
"id": "test",
"single_end": false
},
"test.1.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"lowdepth": [
[
{
"id": "test",
"single_end": false
},
"test.1.lowDepth.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"membership": [
[
{
"id": "test",
"single_end": false
},
"test.tsv.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"tooshort": [
[
{
"id": "test",
"single_end": false
},
"test.1.tooShort.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"unbinned": [
[
{
"id": "test",
"single_end": false
},
"test.1.unbinned.fa.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
],
"versions": [
"versions.yml:md5,872d18278c2ba7812c62a8bc6b2120eb"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-11T12:28:32.122007408"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

withName: METABAT2_METABAT2 {
ext.args = '--minContig 1500 --minCV 0.1 --minCVSum 0.1 --minClsSize 10 --minS 2'
}

}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ merquryfk/katgc:
merquryfk/ploidyplot:
- modules/nf-core/merquryfk/ploidyplot/**
- tests/modules/nf-core/merquryfk/ploidyplot/**
metabat2/metabat2:
- modules/nf-core/metabat2/metabat2/**
- tests/modules/nf-core/metabat2/metabat2/**
metaeuk/easypredict:
- modules/nf-core/metaeuk/easypredict/**
- tests/modules/nf-core/metaeuk/easypredict/**
Expand Down
35 changes: 0 additions & 35 deletions tests/modules/nf-core/metabat2/metabat2/main.nf

This file was deleted.

27 changes: 0 additions & 27 deletions tests/modules/nf-core/metabat2/metabat2/test.yml

This file was deleted.

0 comments on commit 299a26f

Please sign in to comment.