Skip to content

Commit

Permalink
Swap bbmap/align to nf-test and add stub (nf-core#7278)
Browse files Browse the repository at this point in the history
* Swap bbmap/align to nf-test

* Add missing tag
  • Loading branch information
SPPearce authored and fellen31 committed Jan 10, 2025
1 parent a14e448 commit 62b1a43
Show file tree
Hide file tree
Showing 9 changed files with 282 additions and 110 deletions.
13 changes: 13 additions & 0 deletions modules/nf-core/bbmap/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ process BBMAP_ALIGN {
-Xmx${task.memory.toGiga()}g \\
&> ${prefix}.bbmap.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset")
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
pigz: \$( pigz --version 2>&1 | sed 's/pigz //g' )
END_VERSIONS
"""
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.bam
touch ${prefix}.bbmap.log
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset")
Expand Down
171 changes: 171 additions & 0 deletions modules/nf-core/bbmap/align/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "bbmap"
tag "bbmap/align"
tag "bbmap/index"

setup {
run("BBMAP_INDEX") {
script "../../index/main.nf"
process {
"""
input[0] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)
"""
}
}
}

test("paired_end - fasta") {

when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/genome.fasta', checkIfExists: true)
"""
}
}

then {
assert process.success
assertAll(
{ assert snapshot(
file(process.out.log[0][1]).name,
process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()},
process.out.versions
).match() }
)
}

}

test("paired_end - index") {

when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = BBMAP_INDEX.out.index
"""
}
}

then {
assert process.success
assertAll(
{ assert snapshot(
file(process.out.log[0][1]).name,
process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()},
process.out.versions
).match() }
)
}

}

test("single_end - index") {

when {
process {
"""
input[0] = [ [ id:'test', single_end:true ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true)
]
]
input[1] = BBMAP_INDEX.out.index
"""
}
}

then {
assert process.success
assertAll(
{ assert snapshot(
file(process.out.log[0][1]).name,
process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()},
process.out.versions
).match() }
)
}

}

test("paired_end - index - pigz") {
config "./nextflow.config"
when {
params {
module_args = 'unpigz=t'
}
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = BBMAP_INDEX.out.index
"""
}
}

then {
assert process.success
assertAll(
{ assert snapshot(
file(process.out.log[0][1]).name,
process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()},
process.out.versions
).match() }
)
}

}

test("paired_end - index - stub") {
options "-stub"
when {
process {
"""
input[0] = [ [ id:'test', single_end:false ], // meta map
[
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true)
]
]
input[1] = BBMAP_INDEX.out.index
"""
}
}

then {
assert process.success
assertAll(
{ assert snapshot(
file(process.out.log[0][1]).name,
process.out.bam.collect { meta, bamfile -> bam(bamfile).getReadsMD5()},
process.out.versions
).match() }
)
}

}

}
82 changes: 82 additions & 0 deletions modules/nf-core/bbmap/align/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"single_end - index": {
"content": [
"test.bbmap.log",
[
"c17efa4ccc4e9018090792c71af92660"
],
[
"versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-08T21:06:20.348251263"
},
"paired_end - index": {
"content": [
"test.bbmap.log",
[
"88d78879c34214288644aec7ec3cb270"
],
[
"versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-08T21:06:05.162378558"
},
"paired_end - fasta": {
"content": [
"test.bbmap.log",
[
"88d78879c34214288644aec7ec3cb270"
],
[
"versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-08T21:05:49.658797332"
},
"paired_end - index - pigz": {
"content": [
"test.bbmap.log",
[
"88d78879c34214288644aec7ec3cb270"
],
[
"versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-08T21:06:36.326962674"
},
"paired_end - index - stub": {
"content": [
"test.bbmap.log",
[
"d41d8cd98f00b204e9800998ecf8427e"
],
[
"versions.yml:md5,7c9a1c72ae9ea9c54b7518e96f8f89bb"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2025-01-08T21:06:47.377762689"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/bbmap/align/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: BBMAP_ALIGN {
ext.args = params.module_args
}
}
11 changes: 11 additions & 0 deletions modules/nf-core/bbmap/index/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ process BBMAP_INDEX {
threads=$task.cpus \\
-Xmx${task.memory.toGiga()}g
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset")
END_VERSIONS
"""
stub:
"""
mkdir -p ref
touch ref/info.txt
touch ref/summary.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bbmap: \$(bbversion.sh | grep -v "Duplicate cpuset")
Expand Down
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ bamtools/split:
basicpy:
- modules/nf-core/basicpy/**
- tests/modules/nf-core/basicpy/**
bbmap/align:
- modules/nf-core/bbmap/align/**
- tests/modules/nf-core/bbmap/align/**
biohansel:
- modules/nf-core/biohansel/**
- tests/modules/nf-core/biohansel/**
Expand Down
59 changes: 0 additions & 59 deletions tests/modules/nf-core/bbmap/align/main.nf

This file was deleted.

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

This file was deleted.

Loading

0 comments on commit 62b1a43

Please sign in to comment.