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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions modules/nf-core/umitools/group/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ output:
type: file
description: Flatfile describing the read groups, see docs for complete info of all columns
pattern: "*.{tsv}"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@Joon-Klaps"
maintainers:
Expand Down
168 changes: 168 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,168 @@
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 - bam") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test("with_umi - bam") {
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 - tsv") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test("with_umi - tsv") {
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
process.out.tsv,
process.out.tsv,
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() }
)
}

}

}
140 changes: 140 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,140 @@
{
"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"
},
"with_umi - tsv": {
"content": [
[
[
{
"id": "test",
"single_end": false
},
"test_grouped.tsv:md5,d652eb6570057e9e709e8cac5f43d00c"
]
],
[
"# 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.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-16T20:01:27.19796961"
},
"with_umi - 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.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-09-17T07:22:56.250821809"
},
"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"
}
}
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 @@ -798,9 +798,6 @@ ultra/pipeline:
ultraplex:
- modules/nf-core/ultraplex/**
- tests/modules/nf-core/ultraplex/**
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