From 8552a82860545f4ca00a5a7ca3a5cb44fde4ec33 Mon Sep 17 00:00:00 2001 From: rhassaine Date: Mon, 3 Feb 2025 16:02:22 +0000 Subject: [PATCH] Added unit tests for AMBER (tumor + normal mode) & COBALT --- tests/modules/local/amber/main.nf.test | 92 +++++++++++------ tests/modules/local/amber/main.nf.test.snap | 47 +-------- tests/modules/local/cobalt/main.nf.test | 50 +++++----- tests/modules/local/cobalt/main.nf.test.snap | 100 +++++++++++++++++++ 4 files changed, 191 insertions(+), 98 deletions(-) create mode 100644 tests/modules/local/cobalt/main.nf.test.snap diff --git a/tests/modules/local/amber/main.nf.test b/tests/modules/local/amber/main.nf.test index 647aa5b3..765b6106 100644 --- a/tests/modules/local/amber/main.nf.test +++ b/tests/modules/local/amber/main.nf.test @@ -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() } +// ) +// } +// } } diff --git a/tests/modules/local/amber/main.nf.test.snap b/tests/modules/local/amber/main.nf.test.snap index 5044a753..05ef5c82 100644 --- a/tests/modules/local/amber/main.nf.test.snap +++ b/tests/modules/local/amber/main.nf.test.snap @@ -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" } } \ No newline at end of file diff --git a/tests/modules/local/cobalt/main.nf.test b/tests/modules/local/cobalt/main.nf.test index c6a508bd..771b524e 100644 --- a/tests/modules/local/cobalt/main.nf.test +++ b/tests/modules/local/cobalt/main.nf.test @@ -27,7 +27,7 @@ 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] = [] """ @@ -35,15 +35,19 @@ nextflow_process { } 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() } ) } @@ -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() } + ) +} } } - -} diff --git a/tests/modules/local/cobalt/main.nf.test.snap b/tests/modules/local/cobalt/main.nf.test.snap new file mode 100644 index 00000000..57a9acb9 --- /dev/null +++ b/tests/modules/local/cobalt/main.nf.test.snap @@ -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" + } +} \ No newline at end of file