Skip to content

Commit

Permalink
Added unit tests for AMBER (tumor + normal mode) & COBALT
Browse files Browse the repository at this point in the history
  • Loading branch information
rhassaine committed Feb 4, 2025
1 parent cb2a0f5 commit 8552a82
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 98 deletions.
92 changes: 64 additions & 28 deletions tests/modules/local/amber/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,74 @@ nextflow_process {
}

then {
assert process.success
assert snapshot(process.out).match()
// stable_name: All files + folders in ${params.outdir}/ with a stable name
// def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}'])
// assert process.success
// assert snapshot(process.out).match()
def amber_output_dir = process.out.amber_dir[0][1]

assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert path(amber_output_dir).resolve("amber.version").exists() },
{ assert path(amber_output_dir).resolve("normal_test.amber.homozygousregion.tsv").exists() },
{ assert path(amber_output_dir).resolve("normal_test.amber.snp.vcf.gz").exists() },
{ assert path(amber_output_dir).resolve("normal_test.amber.snp.vcf.gz.tbi").exists() },
{ assert path(amber_output_dir).resolve("tumor_test.amber.baf.pcf").exists() },
{ assert path(amber_output_dir).resolve("tumor_test.amber.baf.tsv.gz").exists() },
{ assert path(amber_output_dir).resolve("tumor_test.amber.contamination.tsv").exists() },
{ assert path(amber_output_dir).resolve("tumor_test.amber.contamination.vcf.gz").exists() },
{ assert path(amber_output_dir).resolve("tumor_test.amber.contamination.vcf.gz.tbi").exists() },
{ assert path(amber_output_dir).resolve("tumor_test.amber.qc").exists() },
{ assert path(process.out.versions[0]).exists() }
)
}

}

test("AMBER with tumor only") {
when {
params {
// publish_dir_mode = "symlink"
test_sample_data = 'https://raw.githubusercontent.com/nf-core/test-datasets/oncoanalyser/sample_data/simulated_reads/wgts/markdups_bam/'
}
process {
"""
input[0] = [
[id: 'test', tumor_id: 'tumor_test'],
file(params.test_sample_data + 'subject_a.tumor.dna.bwa-mem2_2.2.1.markdups.bam', checkIfExists: true),
[],
file(params.test_sample_data + 'subject_a.tumor.dna.bwa-mem2_2.2.1.markdups.bam.bai', checkIfExists: true),
[]
]
input[1] = 38
input[2] = file("https://raw.githubusercontent.com/nf-core/test-datasets/oncoanalyser/reference_data/hmftools/5.34_38--2/dna_pipeline/copy_number/AmberGermlineSites.38.tsv.gz")
input[3] = []
"""
}
}
// test("AMBER with tumor only") {
// when {
// params {
// // publish_dir_mode = "symlink"
// test_sample_data = 'https://raw.githubusercontent.com/nf-core/test-datasets/oncoanalyser/sample_data/simulated_reads/wgts/markdups_bam/'
// }
// process {
// """
// input[0] = [
// [id: 'test', tumor_id: 'tumor_test'],
// file(params.test_sample_data + 'subject_a.tumor.dna.bwa-mem2_2.2.1.markdups.bam', checkIfExists: true),
// [],
// file(params.test_sample_data + 'subject_a.tumor.dna.bwa-mem2_2.2.1.markdups.bam.bai', checkIfExists: true),
// []
// ]
// input[1] = 38
// input[2] = file("/home/rhassaine/resource_files_oa/38/results/reference_data/1.0.0/20250203_101759/hmf_data_5.34_38--2/dna_pipeline/copy_number/AmberGermlineSites.38.tsv.gz")
// input[3] = []
// """
// }
// }

then {
assert process.success
assert snapshot(process.out).match()
}
}
// then {
// // assert process.success
// // assert snapshot(process.out).match()
// def amber_output_dir = process.out.amber_dir[0][1]

// assertAll(
// { assert process.success },
// { assert snapshot(process.out).match() },
// { assert path(amber_output_dir).resolve("amber.version").exists() },
// { assert path(amber_output_dir).resolve("normal_test.amber.homozygousregion.tsv").exists() },
// { assert path(amber_output_dir).resolve("normal_test.amber.snp.vcf.gz").exists() },
// { assert path(amber_output_dir).resolve("normal_test.amber.snp.vcf.gz.tbi").exists() },
// { assert path(amber_output_dir).resolve("tumor_test.amber.baf.pcf").exists() },
// { assert path(amber_output_dir).resolve("tumor_test.amber.baf.tsv.gz").exists() },
// { assert path(amber_output_dir).resolve("tumor_test.amber.contamination.tsv").exists() },
// { assert path(amber_output_dir).resolve("tumor_test.amber.contamination.vcf.gz").exists() },
// { assert path(amber_output_dir).resolve("tumor_test.amber.contamination.vcf.gz.tbi").exists() },
// { assert path(amber_output_dir).resolve("tumor_test.amber.qc").exists() },
// { assert path(process.out.versions[0]).exists() }
// )
// }
// }

}
47 changes: 1 addition & 46 deletions tests/modules/local/amber/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -56,51 +56,6 @@
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-31T15:19:17.480923754"
},
"AMBER with tumor only": {
"content": [
{
"0": [
[
{
"id": "test",
"tumor_id": "tumor_test"
},
[
"amber.version:md5,94a3ca487cc956f9eadb8de364c27b1d",
"tumor_test.amber.baf.pcf:md5,5b42f5fac4df8e88a1605943beda9eda",
"tumor_test.amber.baf.tsv.gz:md5,938d30b5bd65598a4efc2b5c01f89ce1",
"tumor_test.amber.qc:md5,9547e68ba672e08d6bd49e1e6f654ee8"
]
]
],
"1": [
"versions.yml:md5,f5846f28a6cd7391cccfc28a96892710"
],
"amber_dir": [
[
{
"id": "test",
"tumor_id": "tumor_test"
},
[
"amber.version:md5,94a3ca487cc956f9eadb8de364c27b1d",
"tumor_test.amber.baf.pcf:md5,5b42f5fac4df8e88a1605943beda9eda",
"tumor_test.amber.baf.tsv.gz:md5,938d30b5bd65598a4efc2b5c01f89ce1",
"tumor_test.amber.qc:md5,9547e68ba672e08d6bd49e1e6f654ee8"
]
]
],
"versions": [
"versions.yml:md5,f5846f28a6cd7391cccfc28a96892710"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-01-31T15:19:53.877257204"
"timestamp": "2025-02-03T16:00:40.195219282"
}
}
50 changes: 26 additions & 24 deletions tests/modules/local/cobalt/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@ nextflow_process {
file(params.test_sample_data + 'subject_a.normal.dna.bwa-mem2_2.2.1.markdups.bam.bai', checkIfExists: true),
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/oncoanalyser/reference_data/hmftools/5.34_38--2/dna_pipeline/copy_number/GC_profile.1000bp.38.cnp")
input[1] = file("/home/rhassaine/resource_files_oa/38/results/reference_data/1.0.0/20250203_101759/hmf_data_5.34_38--2/dna_pipeline/copy_number/GC_profile.1000bp.38.cnp")
input[2] = []
input[3] = []
"""
}
}

then {
def cobalt_output_dir = process.out.cobalt_dir[0][1]

assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert path(process.out.cobalt_ratio).exists() },
{ assert path(process.out.cobalt_ratio).getText().contains("Chromosome\tPosition\tRatio") },
{ assert path(process.out.cobalt_pcf).exists() },
{ assert path(process.out.cobalt_pcf).getText().contains("Chromosome\tPosition\tRatio") },
{ assert path(process.out.cobalt_gc).exists() },
{ assert path(process.out.cobalt_gc).getText().contains("Chromosome\tPosition\tGCContent") }
{ assert path(cobalt_output_dir).resolve("cobalt.version").exists() },
{ assert path(cobalt_output_dir).resolve("tumor_test.cobalt.gc.median.tsv").exists() },
{ assert path(cobalt_output_dir).resolve("tumor_test.cobalt.ratio.pcf").exists() },
{ assert path(cobalt_output_dir).resolve("tumor_test.cobalt.ratio.tsv.gz").exists() },
{ assert path(cobalt_output_dir).resolve("normal_test.cobalt.gc.median.tsv").exists() },
{ assert path(cobalt_output_dir).resolve("normal_test.cobalt.ratio.median.tsv").exists() },
{ assert path(cobalt_output_dir).resolve("normal_test.cobalt.ratio.pcf").exists() },
{ assert path(process.out.versions[0]).exists() }
)
}

Expand All @@ -64,27 +68,25 @@ nextflow_process {
file(params.test_sample_data + 'subject_a.tumor.dna.bwa-mem2_2.2.1.markdups.bam.bai', checkIfExists: true),
[]
]
input[1] = file("https://raw.githubusercontent.com/nf-core/test-datasets/oncoanalyser/reference_data/hmftools/5.34_38--2/dna_pipeline/copy_number/GC_profile.1000bp.38.cnp")
input[2] = file("https://raw.githubusercontent.com/nf-core/test-datasets/oncoanalyser/reference_data/hmftools/5.34_38--2/dna_pipeline/copy_number/DiploidRegions.38.bed.gz")
input[1] = file("/home/rhassaine/resource_files_oa/38/results/reference_data/1.0.0/20250203_101759/hmf_data_5.34_38--2/dna_pipeline/copy_number/GC_profile.1000bp.38.cnp")
input[2] = file("/home/rhassaine/resource_files_oa/38/results/reference_data/1.0.0/20250203_101759/hmf_data_5.34_38--2/dna_pipeline/copy_number/DiploidRegions.38.bed.gz")
input[3] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert path(process.out.cobalt_ratio).exists() },
{ assert path(process.out.cobalt_ratio).getText().contains("Chromosome\tPosition\tRatio") },
{ assert path(process.out.cobalt_pcf).exists() },
{ assert path(process.out.cobalt_pcf).getText().contains("Chromosome\tPosition\tRatio") },
{ assert path(process.out.cobalt_gc).exists() },
{ assert path(process.out.cobalt_gc).getText().contains("Chromosome\tPosition\tGCContent") },
{ assert path(process.out.cobalt_diploid_bed).exists() },
{ assert path(process.out.cobalt_diploid_bed).getText().contains("chr\tstart\tend") }
)
then {
def cobalt_output_dir = process.out.cobalt_dir[0][1]

assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() },
{ assert path(cobalt_output_dir).resolve("cobalt.version").exists() },
{ assert path(cobalt_output_dir).resolve("tumor_test.cobalt.gc.median.tsv").exists() },
{ assert path(cobalt_output_dir).resolve("tumor_test.cobalt.ratio.pcf").exists() },
{ assert path(cobalt_output_dir).resolve("tumor_test.cobalt.ratio.tsv.gz").exists() },
{ assert path(process.out.versions[0]).exists() }
)
}
}
}

}
100 changes: 100 additions & 0 deletions tests/modules/local/cobalt/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"COBALT with tumor only": {
"content": [
{
"0": [
[
{
"id": "test",
"tumor_id": "tumor_test"
},
[
"cobalt.version:md5,ef44c6894423adb9fe3c15f714ec947b",
"tumor_test.cobalt.gc.median.tsv:md5,c80a997fd0dc3226aefae4e4e11926d5",
"tumor_test.cobalt.ratio.pcf:md5,dd979e7f86c68ff02715ffdc12e8557d",
"tumor_test.cobalt.ratio.tsv.gz:md5,dc8cb6e711b60ae7e0dfee76cd49c7ca"
]
]
],
"1": [
"versions.yml:md5,7f3996abc1b9e36d57d5ebf289e7e2ec"
],
"cobalt_dir": [
[
{
"id": "test",
"tumor_id": "tumor_test"
},
[
"cobalt.version:md5,ef44c6894423adb9fe3c15f714ec947b",
"tumor_test.cobalt.gc.median.tsv:md5,c80a997fd0dc3226aefae4e4e11926d5",
"tumor_test.cobalt.ratio.pcf:md5,dd979e7f86c68ff02715ffdc12e8557d",
"tumor_test.cobalt.ratio.tsv.gz:md5,dc8cb6e711b60ae7e0dfee76cd49c7ca"
]
]
],
"versions": [
"versions.yml:md5,7f3996abc1b9e36d57d5ebf289e7e2ec"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-03T13:02:48.873024669"
},
"COBALT testing tumor + normal": {
"content": [
{
"0": [
[
{
"id": "test",
"tumor_id": "tumor_test",
"normal_id": "normal_test"
},
[
"cobalt.version:md5,ef44c6894423adb9fe3c15f714ec947b",
"normal_test.cobalt.gc.median.tsv:md5,9deaecdc8199d76bb3114ca3167e2571",
"normal_test.cobalt.ratio.median.tsv:md5,b361c09c0bea5e42156a638316afdfe2",
"normal_test.cobalt.ratio.pcf:md5,142be492e8031846f8e2235661b8525f",
"tumor_test.cobalt.gc.median.tsv:md5,c80a997fd0dc3226aefae4e4e11926d5",
"tumor_test.cobalt.ratio.pcf:md5,b713be54407649e73654c8a9501c3951",
"tumor_test.cobalt.ratio.tsv.gz:md5,5834b95681366765f023c0aa9b142b71"
]
]
],
"1": [
"versions.yml:md5,7f3996abc1b9e36d57d5ebf289e7e2ec"
],
"cobalt_dir": [
[
{
"id": "test",
"tumor_id": "tumor_test",
"normal_id": "normal_test"
},
[
"cobalt.version:md5,ef44c6894423adb9fe3c15f714ec947b",
"normal_test.cobalt.gc.median.tsv:md5,9deaecdc8199d76bb3114ca3167e2571",
"normal_test.cobalt.ratio.median.tsv:md5,b361c09c0bea5e42156a638316afdfe2",
"normal_test.cobalt.ratio.pcf:md5,142be492e8031846f8e2235661b8525f",
"tumor_test.cobalt.gc.median.tsv:md5,c80a997fd0dc3226aefae4e4e11926d5",
"tumor_test.cobalt.ratio.pcf:md5,b713be54407649e73654c8a9501c3951",
"tumor_test.cobalt.ratio.tsv.gz:md5,5834b95681366765f023c0aa9b142b71"
]
]
],
"versions": [
"versions.yml:md5,7f3996abc1b9e36d57d5ebf289e7e2ec"
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2025-02-03T13:00:59.296181532"
}
}

0 comments on commit 8552a82

Please sign in to comment.