Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate umitools/group to nf-test #6653

Merged
merged 11 commits into from
Nov 20, 2024
7 changes: 4 additions & 3 deletions modules/nf-core/umitools/group/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ process UMITOOLS_GROUP {

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}"
prefix = task.ext.prefix ?: "${meta.id}_grouped"
def paired = meta.single_end ? "" : "--paired"
output_bam = create_bam ? "--output-bam -S ${prefix}.bam" : ""
group_info = get_group_info ? "--group-out ${prefix}.tsv" : ""
Expand All @@ -48,11 +48,12 @@ process UMITOOLS_GROUP {
"""

stub:
prefix = task.ext.prefix ?: "${meta.id}"
prefix = task.ext.prefix ?: "${meta.id}_grouped"
output_bam = create_bam ? "touch ${prefix}.bam" : ""
"""
touch ${prefix}.bam
touch ${prefix}.log
touch ${prefix}.tsv
$output_bam

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
169 changes: 169 additions & 0 deletions modules/nf-core/umitools/group/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "umitools"
tag "umitools/extract"
tag "umitools/group"
tag "bwa/index"
tag "bwa/mem"
tag "samtools/index"

setup {
run("UMITOOLS_EXTRACT") {
script "../../extract/main.nf"
config "./nextflow.config"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true)
]
]
"""
}
}

run("BWA_INDEX") {
script "../../../bwa/index/main.nf"
process {
"""
input[0] = [
[ id:'sarscov2'],
file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
]
"""
}
}

run("BWA_MEM") {
script "../../../bwa/mem/main.nf"
process {
"""
input[0] = UMITOOLS_EXTRACT.out.reads
input[1] = BWA_INDEX.out.index
input[2] = [ [], [] ]
input[3] = true
"""
}
}

run("SAMTOOLS_INDEX") {
script "../../../samtools/index/main.nf"
process {
"""
input[0] = BWA_MEM.out.bam
"""
}
}

}

test("no_umi") {

when {
process {
"""
input[0] = [[ id:'test'], // meta map
file(params.test_data_base + '/data/genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true),
file(params.test_data_base + '/data/genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam.bai', checkIfExists: true)
]
input[1] = true
input[2] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
process.out.tsv,
file(process.out.log[0][1]).readLines()[0..1],
process.out.versions
).match() }
)
}

}

test("with_umi - create only bam") {

when {
process {
"""
input[0] = BWA_MEM.out.bam.join(SAMTOOLS_INDEX.out.bai, by: [0])
input[1] = true
input[2] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
bam(process.out.bam[0][1]).getReadsMD5(),
file(process.out.log[0][1]).readLines()[0..1],
process.out.versions
).match() }
)
}

}

test("with_umi - create bam and tsv") {

when {
process {
"""
input[0] = BWA_MEM.out.bam.join(SAMTOOLS_INDEX.out.bai, by: [0])
input[1] = true
input[2] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
process.out.tsv,
SPPearce marked this conversation as resolved.
Show resolved Hide resolved
bam(process.out.bam[0][1]).getReadsMD5(),
file(process.out.log[0][1]).readLines()[0..1],
process.out.versions
).match() }
)
}

}

test("with_umi - stub") {
options "-stub"
when {
process {
"""
input[0] = BWA_MEM.out.bam.join(SAMTOOLS_INDEX.out.bai, by: [0])
input[1] = true
input[2] = true
"""
}
}

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

}

}
141 changes: 141 additions & 0 deletions modules/nf-core/umitools/group/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"with_umi - create only bam": {
"content": [
"72da540b9a840cf39e3567cc35045143",
[
"# UMI-tools version: 1.1.5",
"# output generated by group -I test.bam --output-bam -S test_grouped.bam -L test_grouped.log --paired --random-seed=100"
],
[
"versions.yml:md5,1f4cec69f12f1759748ed167701b321c"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-20T13:51:08.650455694"
},
"with_umi - stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false
},
"test_grouped.log:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "test",
"single_end": false
},
"test_grouped.bam:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
[
{
"id": "test",
"single_end": false
},
"test_grouped.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"3": [
"versions.yml:md5,1f4cec69f12f1759748ed167701b321c"
],
"bam": [
[
{
"id": "test",
"single_end": false
},
"test_grouped.bam:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"log": [
[
{
"id": "test",
"single_end": false
},
"test_grouped.log:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"tsv": [
[
{
"id": "test",
"single_end": false
},
"test_grouped.tsv:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,1f4cec69f12f1759748ed167701b321c"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-16T19:52:11.292296043"
},
"no_umi": {
"content": [
"b01829d27fad55e707745f86311b443e",
[
[
{
"id": "test"
},
"test_grouped.tsv:md5,1a3ccdc00df59fa89c79ad482980a003"
]
],
[
"# UMI-tools version: 1.1.5",
"# output generated by group -I test.paired_end.sorted.bam --output-bam -S test_grouped.bam -L test_grouped.log --group-out test_grouped.tsv --paired --random-seed=100"
],
[
"versions.yml:md5,1f4cec69f12f1759748ed167701b321c"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-17T07:22:24.041871851"
},
"with_umi - create bam and tsv": {
"content": [
[
[
{
"id": "test",
"single_end": false
},
"test_grouped.tsv:md5,d652eb6570057e9e709e8cac5f43d00c"
]
],
"72da540b9a840cf39e3567cc35045143",
[
"# UMI-tools version: 1.1.5",
"# output generated by group -I test.bam --output-bam -S test_grouped.bam -L test_grouped.log --group-out test_grouped.tsv --paired --random-seed=100"
],
[
"versions.yml:md5,1f4cec69f12f1759748ed167701b321c"
]
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.1"
},
"timestamp": "2024-11-20T13:51:34.459633546"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/umitools/group/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: UMITOOLS_EXTRACT {
ext.args = '--bc-pattern="NNNN"'
}
}
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,6 @@ ultra/index:
ultra/pipeline:
- modules/nf-core/ultra/pipeline/**
- tests/modules/nf-core/ultra/pipeline/**
umitools/group:
- modules/nf-core/umitools/group/**
- tests/modules/nf-core/umitools/group/**
universc:
- modules/nf-core/universc/**
- tests/modules/nf-core/universc/**
Expand Down
Loading
Loading