Skip to content

Commit

Permalink
port gatk4/calculatecontamination to nf-test (#5603)
Browse files Browse the repository at this point in the history
* port to nf-test update stub

* prettier

* prettier

* add assertion for segmentation
  • Loading branch information
famosab authored May 15, 2024
1 parent 7d81481 commit 77ffba9
Show file tree
Hide file tree
Showing 9 changed files with 252 additions and 76 deletions.
12 changes: 12 additions & 0 deletions modules/nf-core/gatk4/calculatecontamination/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,16 @@ process GATK4_CALCULATECONTAMINATION {
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""

stub:
prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.contamination.table
touch ${prefix}.segmentation.table
cat <<-END_VERSIONS > versions.yml
"${task.process}":
gatk4: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
END_VERSIONS
"""
}
106 changes: 106 additions & 0 deletions modules/nf-core/gatk4/calculatecontamination/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
nextflow_process {

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

tag "modules"
tag "modules_nfcore"
tag "gatk4"
tag "gatk4/calculatecontamination"

test("human - pileup-table") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test2.pileups.table', checkIfExists: true),
[] ]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match("versions") },
{ assert snapshot(file(process.out.contamination.get(0).get(1)).readLines()[0]).match() }
)
}

}

test("human - pileup-table - matched-pair") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test2.pileups.table', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test.pileups.table', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match("versions_pair") },
{ assert snapshot(file(process.out.contamination.get(0).get(1)).readLines()[0]).match() }
)
}

}

test("human - pileup-table - segmentation") {

config "./nextflow.config"

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test2.pileups.table', checkIfExists: true),
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test.pileups.table', checkIfExists: true)
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.versions).match("versions_segmentation") },
{ assert snapshot(file(process.out.contamination.get(0).get(1)).readLines()[0]).match("contamination") },
{ assert snapshot(file(process.out.segmentation.get(0).get(1)).readLines()[0]).match("segmentation") }
)
}

}

test("human - pileup-table - stub") {

options "-stub"

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/gatk/test2.pileups.table', checkIfExists: true),
[] ]
"""
}
}

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

}

}
127 changes: 127 additions & 0 deletions modules/nf-core/gatk4/calculatecontamination/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"versions_pair": {
"content": [
[
"versions.yml:md5,4a72b1da18f7045d470225881e7266a6"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T11:08:17.057861"
},
"versions": {
"content": [
[
"versions.yml:md5,4a72b1da18f7045d470225881e7266a6"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T11:08:07.193762"
},
"versions_segmentation": {
"content": [
[
"versions.yml:md5,4a72b1da18f7045d470225881e7266a6"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T11:08:26.99069"
},
"segmentation": {
"content": [
"#<METADATA>SAMPLE=tumour"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T12:57:38.845287"
},
"human - pileup-table": {
"content": [
"sample\tcontamination\terror"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T11:09:16.292509"
},
"human - pileup-table - stub": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.contamination.table:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"1": [
[
{
"id": "test"
},
"test.segmentation.table:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
"versions.yml:md5,4a72b1da18f7045d470225881e7266a6"
],
"contamination": [
[
{
"id": "test"
},
"test.contamination.table:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"segmentation": [
[
{
"id": "test"
},
"test.segmentation.table:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"versions": [
"versions.yml:md5,4a72b1da18f7045d470225881e7266a6"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T12:56:14.817045"
},
"human - pileup-table - matched-pair": {
"content": [
"sample\tcontamination\terror"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T11:09:26.408848"
},
"contamination": {
"content": [
"sample\tcontamination\terror"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.0"
},
"timestamp": "2024-05-15T12:57:38.840651"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: GATK4_CALCULATECONTAMINATION {
ext.args = { "--tumor-segmentation ${meta.id}.segmentation.table" }
}
}
2 changes: 2 additions & 0 deletions modules/nf-core/gatk4/calculatecontamination/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gatk4/calculatecontamination:
- "modules/nf-core/gatk4/calculatecontamination/**"
3 changes: 0 additions & 3 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,6 @@ gatk/unifiedgenotyper:
gatk4/applyvqsr:
- modules/nf-core/gatk4/applyvqsr/**
- tests/modules/nf-core/gatk4/applyvqsr/**
gatk4/calculatecontamination:
- modules/nf-core/gatk4/calculatecontamination/**
- tests/modules/nf-core/gatk4/calculatecontamination/**
gatk4/calibratedragstrmodel:
- modules/nf-core/gatk4/calibratedragstrmodel/**
- tests/modules/nf-core/gatk4/calibratedragstrmodel/**
Expand Down
33 changes: 0 additions & 33 deletions tests/modules/nf-core/gatk4/calculatecontamination/main.nf

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions tests/modules/nf-core/gatk4/calculatecontamination/test.yml

This file was deleted.

0 comments on commit 77ffba9

Please sign in to comment.