From db92a3e79990d32cbd13bef5fc6b22fd839f5e99 Mon Sep 17 00:00:00 2001 From: Friederike Hanssen Date: Thu, 22 Oct 2026 16:55:28 +0000 Subject: [PATCH 1/6] parabricks/mutectcaller: pass --pon to mutectcaller The panel of normals was prepared with prepon and annotated with postpon, but never passed to mutectcaller via --pon, so PON sites were not filtered during calling. prepon was also silently skipped whenever the index was already named .tbi: the cp onto itself failed, and its && chain short-circuited prepon without failing the task. Only copy the index when its name differs. Re-enable the PON test by reheadering the chr21 Mills VCF to the reference contigs with bcftools/reheader in a setup block. Generated by Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 --- .../nf-core/parabricks/mutectcaller/main.nf | 7 +- .../nf-core/parabricks/mutectcaller/meta.yml | 6 +- .../mutectcaller/tests/main.nf.test | 101 ++++++++++-------- .../mutectcaller/tests/main.nf.test.snap | 27 +++++ .../mutectcaller/tests/nextflow.config | 4 + 5 files changed, 101 insertions(+), 44 deletions(-) diff --git a/modules/nf-core/parabricks/mutectcaller/main.nf b/modules/nf-core/parabricks/mutectcaller/main.nf index 0571a336431a..9e18bdfc14d2 100644 --- a/modules/nf-core/parabricks/mutectcaller/main.nf +++ b/modules/nf-core/parabricks/mutectcaller/main.nf @@ -32,7 +32,10 @@ process PARABRICKS_MUTECTCALLER { def prefix = task.ext.prefix ?: "${meta.id}" def intervals_command = intervals ? (intervals instanceof List ? intervals.collect { interval -> "--interval-file ${interval}" }.join(' ') : "--interval-file ${intervals}") : "" - def prepon_command = panel_of_normals ? "cp -L ${panel_of_normals_index} `readlink -f ${panel_of_normals}`.tbi && pbrun prepon --in-pon-file ${panel_of_normals}" : "" + // prepon and postpon expect the index at .tbi + def pon_index_command = panel_of_normals && panel_of_normals_index.name != "${panel_of_normals.name}.tbi" ? "cp -L ${panel_of_normals_index} ${panel_of_normals}.tbi" : "" + def prepon_command = panel_of_normals ? "pbrun prepon --in-pon-file ${panel_of_normals}" : "" + def pon_command = panel_of_normals ? "--pon ${panel_of_normals}" : "" // pbrun postpon requires uncompressed .vcf input; output uncompressed when PON is provided def mutect_out = panel_of_normals ? "${prefix}.vcf" : "${prefix}.vcf.gz" def stats_rename = panel_of_normals ? "mv ${prefix}.vcf.stats ${prefix}.vcf.gz.stats" : "" @@ -42,6 +45,7 @@ process PARABRICKS_MUTECTCALLER { def normal_bam_flag = normal_bam ? "--in-normal-bam ${normal_bam}" : "" """ # if panel of normals specified, run prepon + ${pon_index_command} ${prepon_command} pbrun \\ @@ -49,6 +53,7 @@ process PARABRICKS_MUTECTCALLER { --ref ${fasta} \\ --in-tumor-bam ${tumor_bam} \\ ${normal_bam_flag} \\ + ${pon_command} \\ --out-vcf ${mutect_out} \\ ${intervals_command} \\ ${num_gpus} \\ diff --git a/modules/nf-core/parabricks/mutectcaller/meta.yml b/modules/nf-core/parabricks/mutectcaller/meta.yml index 1f95467a2531..2b5e5591786a 100644 --- a/modules/nf-core/parabricks/mutectcaller/meta.yml +++ b/modules/nf-core/parabricks/mutectcaller/meta.yml @@ -68,7 +68,11 @@ input: ontologies: [] - panel_of_normals: type: file - description: (Optional) panel of normals file. + description: | + (Optional) bgzipped panel of normals file. When provided, the module runs + prepon, passes it to mutectcaller via --pon and annotates the output with + postpon. Its header must contain only contigs present in the reference + (see `bcftools reheader --fai`). Do not add --pon via ext.args. pattern: "*.vcf.gz" ontologies: - edam: http://edamontology.org/format_3989 # GZIP format diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test index 6f747dd22fb4..dae228b762e5 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test @@ -6,6 +6,7 @@ nextflow_process { tag "modules" tag "parabricks/mutectcaller" + tag "bcftools/reheader" tag "modules_nfcore" tag "parabricks" tag "gpu" @@ -185,50 +186,66 @@ nextflow_process { // } - // test("human - bam - pon") { - // // PON test not passing because the tool expects all chromosomes in the PON file to - // // be present in the reference genome. - - // config "./nextflow.config" + test("human - bam - pon") { + + setup { + run("BCFTOOLS_REHEADER") { + script "../../../bcftools/reheader/main.nf" + process { + """ + input[0] = [ + [ id:'pon' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/mills_and_1000G.indels.hg38.vcf.gz', checkIfExists: true), + [], + [] + ] + input[1] = [ + [ id:'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + """ + } + } + } - // when { - // params { - // module_args = "--pon $panel_of_normals --mutect-low-memory" - // } - // process { - // """ - // input[0] = [ - // [ id:'test' ], - // 'tumour', - // null, - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), - // [], - // [], - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true) - // ] - // input[1] = [ // fasta - // [ id: 'reference' ], - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) - // ] - // input[2] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/mills_and_1000G.indels.hg38.vcf.gz', checkIfExists: true) - // input[3] = file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/mills_and_1000G.indels.hg38.vcf.gz.tbi', checkIfExists: true) - // """ - // } - // } + when { + params { + module_args = "--tumor-name tumour --mutect-low-memory" + } + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), + [], + [], + [], + [] + ] + input[1] = [ // fasta + fasta_fai + [ id: 'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + input[2] = BCFTOOLS_REHEADER.out.vcf.map { meta, vcf -> vcf } + input[3] = BCFTOOLS_REHEADER.out.index.map { meta, tbi -> tbi } + """ + } + } - // then { - // assertAll( - // { assert process.success }, - // { assert snapshot( - // path(process.out.vcf[0][1]).vcf.variantsMD5, - // process.out.stats, - // process.out.versions - // ).match() } - // ) - // } + then { + assertAll( + { assert process.success }, + { assert path(process.out.vcf[0][1]).linesGzip.any { line -> line.startsWith('##GATKCommandLine= key.startsWith('versions') } + ).match() } + ) + } - // } + } test("human - bam - stub") { @@ -277,7 +294,7 @@ nextflow_process { when { params { - module_args = "--pon ${panel_of_normals} --mutect-low-memory" + module_args = "--tumor-name tumour --mutect-low-memory" } process { """ diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap index 92572c5a39c6..625e9918f67c 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap @@ -133,6 +133,33 @@ "nextflow": "26.04.6" } }, + "human - bam - pon": { + "content": [ + "1c7638f2c8861c5491570dc79b36af3b", + [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,a9bfbdd92e86ca832ad6e2dafc561e9f" + ] + ], + { + "versions_parabricks": [ + [ + "PARABRICKS_MUTECTCALLER", + "parabricks", + "4.8.0-1" + ] + ] + } + ], + "timestamp": "2026-10-22T16:37:26.712235152", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.10.3" + } + }, "human - bam": { "content": [ "e9e77b557c40e868547a34dfca4fbd45", diff --git a/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config b/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config index 6376c82c4862..f87ad54778f5 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config +++ b/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config @@ -4,4 +4,8 @@ process { ext.args = { params.module_args } } + withName: 'BCFTOOLS_REHEADER' { + ext.args2 = '--output-type z --write-index=tbi --no-version' + } + } From 349186ed748d590e5273fc952a54385b0d7d4e36 Mon Sep 17 00:00:00 2001 From: Friederike Hanssen Date: Thu, 22 Oct 2026 17:04:18 +0000 Subject: [PATCH 2/6] parabricks/mutectcaller: assert PON effect explicitly, use sanitizeOutput Snapshot all outputs via sanitizeOutput. The PON test now asserts that --pon reaches mutectcaller, that calls overlapping PON deletions are dropped (and present in the tumour-only test), and that postpon flags PON sites, instead of relying on a snapshot recorded from the fix. Generated by Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 --- .../mutectcaller/tests/main.nf.test | 28 ++-- .../mutectcaller/tests/main.nf.test.snap | 122 +++++++----------- 2 files changed, 60 insertions(+), 90 deletions(-) diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test index dae228b762e5..9a69cbab410c 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test @@ -41,13 +41,13 @@ nextflow_process { } then { + def records = path(process.out.vcf[0][1]).linesGzip.findAll { line -> !line.startsWith('#') }.collect { line -> line.split('\t') } + // Calls overlapping PON deletions in the PON test; they must disappear when --pon is used + def pon_overlapping = ['44145050', '44145051', '46156071', '46156077'] assertAll( { assert process.success }, - { assert snapshot( - path(process.out.vcf[0][1]).vcf.variantsMD5, - process.out.stats, - process.out.findAll { key, val -> key.startsWith('versions') } - ).match() } + { assert records.count { record -> record[1] in pon_overlapping } == 4 }, + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } ) } @@ -234,14 +234,16 @@ nextflow_process { } then { + def lines = path(process.out.vcf[0][1]).linesGzip + def records = lines.findAll { line -> !line.startsWith('#') }.collect { line -> line.split('\t') } + def pon_overlapping = ['44145050', '44145051', '46156071', '46156077'] assertAll( { assert process.success }, - { assert path(process.out.vcf[0][1]).linesGzip.any { line -> line.startsWith('##GATKCommandLine= key.startsWith('versions') } - ).match() } + { assert lines.any { line -> line.startsWith('##GATKCommandLine= record[1] in pon_overlapping } == 0 }, + // postpon flags calls at PON positions + { assert records.find { record -> record[1] == '45495715' }[7].split(';').contains('PON') }, + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } ) } @@ -280,7 +282,7 @@ nextflow_process { assertAll( { assert process.success }, { assert snapshot( - process.out, + sanitizeOutput(process.out), path(process.out.compatible_versions.get(0)).yaml ).match() } ) @@ -320,7 +322,7 @@ nextflow_process { then { assertAll( { assert process.success }, - { assert snapshot( process.out ).match() } + { assert snapshot(sanitizeOutput(process.out)).match() } ) } diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap index 625e9918f67c..e7b45ebe8b49 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap @@ -2,32 +2,6 @@ "human - bam - pon - stub": { "content": [ { - "0": [ - [ - { - "id": "test" - }, - "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" - ] - ], - "1": [ - [ - { - "id": "test" - }, - "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "2": [ - "compatible_versions.yml:md5,62a44f82ee1258428b4afc9d67dc1b4b" - ], - "3": [ - [ - "PARABRICKS_MUTECTCALLER", - "parabricks", - "4.8.0-1" - ] - ], "compatible_versions": [ "compatible_versions.yml:md5,62a44f82ee1258428b4afc9d67dc1b4b" ], @@ -56,41 +30,15 @@ ] } ], - "timestamp": "2026-10-22T07:00:22.879955427", + "timestamp": "2026-10-22T17:02:17.346595961", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.6" + "nextflow": "26.10.3" } }, "human - bam - stub": { "content": [ { - "0": [ - [ - { - "id": "test" - }, - "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" - ] - ], - "1": [ - [ - { - "id": "test" - }, - "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" - ] - ], - "2": [ - "compatible_versions.yml:md5,62a44f82ee1258428b4afc9d67dc1b4b" - ], - "3": [ - [ - "PARABRICKS_MUTECTCALLER", - "parabricks", - "4.8.0-1" - ] - ], "compatible_versions": [ "compatible_versions.yml:md5,62a44f82ee1258428b4afc9d67dc1b4b" ], @@ -127,24 +75,34 @@ } } ], - "timestamp": "2026-10-22T07:00:14.180750126", + "timestamp": "2026-10-22T17:02:10.485649575", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.6" + "nextflow": "26.10.3" } }, "human - bam - pon": { "content": [ - "1c7638f2c8861c5491570dc79b36af3b", - [ - [ - { - "id": "test" - }, - "test.vcf.gz.stats:md5,a9bfbdd92e86ca832ad6e2dafc561e9f" - ] - ], { + "compatible_versions": [ + + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,a9bfbdd92e86ca832ad6e2dafc561e9f" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5Variants,1c7638f2c8861c5491570dc79b36af3b" + ] + ], "versions_parabricks": [ [ "PARABRICKS_MUTECTCALLER", @@ -154,7 +112,7 @@ ] } ], - "timestamp": "2026-10-22T16:37:26.712235152", + "timestamp": "2026-10-22T17:02:03.472570747", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -162,16 +120,26 @@ }, "human - bam": { "content": [ - "e9e77b557c40e868547a34dfca4fbd45", - [ - [ - { - "id": "test" - }, - "test.vcf.gz.stats:md5,c58bc062c6f18d38df3892d15548d8c8" - ] - ], { + "compatible_versions": [ + + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,c58bc062c6f18d38df3892d15548d8c8" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5Variants,e9e77b557c40e868547a34dfca4fbd45" + ] + ], "versions_parabricks": [ [ "PARABRICKS_MUTECTCALLER", @@ -181,10 +149,10 @@ ] } ], - "timestamp": "2026-10-22T07:00:06.819566288", + "timestamp": "2026-10-22T17:01:41.259652653", "meta": { "nf-test": "0.9.5", - "nextflow": "26.04.6" + "nextflow": "26.10.3" } } } \ No newline at end of file From 477b2abbaacfb279178642c15a7c1dedfe132a6a Mon Sep 17 00:00:00 2001 From: Friederike Hanssen Date: Thu, 22 Oct 2026 17:19:16 +0000 Subject: [PATCH 3/6] parabricks/mutectcaller: read test VCFs via nft-vcf Replace hand-rolled linesGzip/tab-split parsing with the nft-vcf VcfFile header and VariantContext API. Generated by Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 --- .../mutectcaller/tests/main.nf.test | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test index 9a69cbab410c..1af5377959c6 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test @@ -41,12 +41,12 @@ nextflow_process { } then { - def records = path(process.out.vcf[0][1]).linesGzip.findAll { line -> !line.startsWith('#') }.collect { line -> line.split('\t') } + def variants = path(process.out.vcf[0][1]).vcf.variants // Calls overlapping PON deletions in the PON test; they must disappear when --pon is used - def pon_overlapping = ['44145050', '44145051', '46156071', '46156077'] + def pon_overlapping = [44145050, 44145051, 46156071, 46156077] assertAll( { assert process.success }, - { assert records.count { record -> record[1] in pon_overlapping } == 4 }, + { assert variants.count { variant -> variant.start in pon_overlapping } == 4 }, { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } ) } @@ -234,15 +234,16 @@ nextflow_process { } then { - def lines = path(process.out.vcf[0][1]).linesGzip - def records = lines.findAll { line -> !line.startsWith('#') }.collect { line -> line.split('\t') } - def pon_overlapping = ['44145050', '44145051', '46156071', '46156077'] + def vcf = path(process.out.vcf[0][1]).vcf + def variants = vcf.variants + def mutect_command = vcf.header.otherHeaderLines.find { line -> line.key == 'GATKCommandLine' && line.value.contains('ID=mutectcaller,') } + def pon_overlapping = [44145050, 44145051, 46156071, 46156077] assertAll( { assert process.success }, - { assert lines.any { line -> line.startsWith('##GATKCommandLine= record[1] in pon_overlapping } == 0 }, + { assert mutect_command.value.contains('--pon ') }, + { assert variants.count { variant -> variant.start in pon_overlapping } == 0 }, // postpon flags calls at PON positions - { assert records.find { record -> record[1] == '45495715' }[7].split(';').contains('PON') }, + { assert variants.find { variant -> variant.start == 45495715 }.hasAttribute('PON') }, { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } ) } From 49d1cc3d98f1b69a880cd5d69e975a0a2e951f8b Mon Sep 17 00:00:00 2001 From: Friederike Hanssen Date: Thu, 22 Oct 2026 17:54:39 +0000 Subject: [PATCH 4/6] parabricks/mutectcaller: add intervals and tumour-normal tests Replace the commented-out tests. The intervals test failed only because of the pre-#11647 input structure. For tumour-normal, the chr21 test BAMs share read group ID and PU, so a setup step renames the normal's read group with samtools/addreplacerg. Drop the tumour-normal + intervals test: no somatic calls fall in the interval gaps, so it adds nothing over the two. Generated by Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 --- .../mutectcaller/tests/main.nf.test | 308 ++++++++++-------- .../mutectcaller/tests/main.nf.test.snap | 148 +++++++++ .../mutectcaller/tests/nextflow.config | 4 + 3 files changed, 328 insertions(+), 132 deletions(-) diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test index 1af5377959c6..0c3667e9e7e8 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test @@ -7,6 +7,7 @@ nextflow_process { tag "modules" tag "parabricks/mutectcaller" tag "bcftools/reheader" + tag "samtools/addreplacerg" tag "modules_nfcore" tag "parabricks" tag "gpu" @@ -44,147 +45,114 @@ nextflow_process { def variants = path(process.out.vcf[0][1]).vcf.variants // Calls overlapping PON deletions in the PON test; they must disappear when --pon is used def pon_overlapping = [44145050, 44145051, 46156071, 46156077] + // Gaps between the intervals in the intervals test + def interval_gaps = [23354001..24132499, 24910999..25689497] assertAll( { assert process.success }, { assert variants.count { variant -> variant.start in pon_overlapping } == 4 }, + { assert variants.count { variant -> interval_gaps.any { gap -> variant.start in gap } } == 17 }, { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } ) } } - // test("human - bam - tn") { - // // tumor-normal calling not passing because of issue with readgroups in the test files - // // [PB Error][src/readers.cpp:1314] ID simulation01 maps to tm_simulation01, but PU is nm_simulation01 (different platform), exiting. - - // config "./nextflow.config" - - // when { - // params { - // module_args = "--mutect-low-memory" - // } - // process { - // """ - // input[0] = [ - // [ id:'test' ], - // 'tumour', - // 'normal', - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), - // [] - // ] - // input[1] = [ // fasta - // [ id: 'reference' ], //genomics/homo_sapiens/genome/chr21/sequence/genome.fasta - // // file() - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) - // ] - // input[2] = [] // pon - // input[3] = [] // pon index - // """ - // } - // } - - // then { - // assertAll( - // { assert process.success }, - // { assert snapshot( - // path(process.out.vcf[0][1]).vcf.variantsMD5, - // process.out.stats, - // process.out.versions - // ).match() } - // ) - // } - - // } - - // test("human - bam - intervals") { - // // Invalid tumor sample name input, exiting. - - // when { - // params { - // module_args = "--tumor-name tumour --mutect-low-memory" - // } - // process { - // """ - // input[0] = [ - // [ id:'test' ], - // 'tumor', - // null, - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), - // [], - // [], - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true) - // ] - // input[1] = [ // fasta - // [ id: 'reference' ], - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) - // ] - // input[2] = [] // pon - // input[3] = [] // pon index - // """ - // } - // } - - // then { - // assertAll( - // { assert process.success }, - // { assert snapshot( - // path(process.out.vcf[0][1]).vcf.variantsMD5, - // process.out.stats, - // process.out.versions - // ).match() } - // ) - // } - - // } - - // test("human - bam - tn - intervals") { - // // tumor-normal calling not passing because of issue with readgroups in the test files - // // [PB Error][src/readers.cpp:1314] ID simulation01 maps to tm_simulation01, but PU is nm_simulation01 (different platform), exiting. - - // config "./nextflow.config" - - // when { - // params { - // module_args = "--mutect-low-memory" - // } - // process { - // """ - // input[0] = [ - // [ id:'test' ], - // 'tumor', - // 'normal', - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true) - // ] - // input[1] = [ // fasta - // [ id: 'reference' ], - // file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true) - // ] - // input[2] = [] // pon - // input[3] = [] // pon index - // """ - // } - // } - - // then { - // assertAll( - // { assert process.success }, - // { assert snapshot( - // path(process.out.vcf[0][1]).vcf.variantsMD5, - // process.out.stats, - // process.out.versions - // ).match() } - // ) - // } - - // } + test("human - bam - intervals") { + + when { + params { + module_args = "--tumor-name tumour --mutect-low-memory" + } + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), + [], + [], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true) + ] + input[1] = [ // fasta + fasta_fai + [ id: 'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] // pon + input[3] = [] // pon index + """ + } + } + + then { + def variants = path(process.out.vcf[0][1]).vcf.variants + def interval_gaps = [23354001..24132499, 24910999..25689497] + assertAll( + { assert process.success }, + { assert variants.count { variant -> interval_gaps.any { gap -> variant.start in gap } } == 0 }, + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } + ) + } + + } + + test("human - bam - tn") { + + setup { + // Both test BAMs share read group ID and PU, which Parabricks rejects in tumour-normal mode + run("SAMTOOLS_ADDREPLACERG") { + script "../../../samtools/addreplacerg/main.nf" + process { + """ + input[0] = [ + [ id:'normal' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam', checkIfExists: true), + [], + "\'@RG\\\\tID:normal01\\\\tPU:normal01\\\\tSM:normal\\\\tLB:normal\\\\tPL:illumina\'" + ] + input[1] = [[],[],[],[]] + """ + } + } + } + + when { + params { + module_args = "--tumor-name tumour --normal-name normal --mutect-low-memory" + } + process { + """ + input[0] = SAMTOOLS_ADDREPLACERG.out.bam + .join(SAMTOOLS_ADDREPLACERG.out.index) + .map { meta, bam, index -> [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), + bam, + index, + [] + ] } + input[1] = [ // fasta + fasta_fai + [ id: 'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] // pon + input[3] = [] // pon index + """ + } + } + + then { + def vcf = path(process.out.vcf[0][1]).vcf + assertAll( + { assert process.success }, + { assert vcf.header.genotypeSamples.sort() == ['normal', 'tumour'] }, + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } + ) + } + + } test("human - bam - pon") { @@ -291,6 +259,82 @@ nextflow_process { } + test("human - bam - intervals - stub") { + + options '-stub' + + when { + params { + module_args = "--tumor-name tumour --mutect-low-memory" + } + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), + [], + [], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/multi_intervals.bed', checkIfExists: true) + ] + input[1] = [ // fasta + fasta_fai + [ id: 'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] // pon + input[3] = [] // pon index + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(sanitizeOutput(process.out)).match() } + ) + } + + } + + test("human - bam - tn - stub") { + + options '-stub' + + when { + params { + module_args = "--tumor-name tumour --normal-name normal --mutect-low-memory" + } + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.recalibrated.sorted.bam.bai', checkIfExists: true), + [] + ] + input[1] = [ // fasta + fasta_fai + [ id: 'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + input[2] = [] // pon + input[3] = [] // pon index + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(sanitizeOutput(process.out)).match() } + ) + } + + } + test("human - bam - pon - stub") { options '-stub' diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap index e7b45ebe8b49..d6804857e833 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap @@ -118,6 +118,80 @@ "nextflow": "26.10.3" } }, + "human - bam - tn": { + "content": [ + { + "compatible_versions": [ + + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,33493aaf38103a76df205f22d287b17d" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5Variants,5a75d8a1c59a59ba6e7ffd04b02b204c" + ] + ], + "versions_parabricks": [ + [ + "PARABRICKS_MUTECTCALLER", + "parabricks", + "4.8.0-1" + ] + ] + } + ], + "timestamp": "2026-10-22T17:51:07.84075849", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.10.3" + } + }, + "human - bam - intervals": { + "content": [ + { + "compatible_versions": [ + + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,730b6c6fd6c35aa7752c2455e9e50847" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5Variants,e7a67bdfa88e542bc73b02bce45be059" + ] + ], + "versions_parabricks": [ + [ + "PARABRICKS_MUTECTCALLER", + "parabricks", + "4.8.0-1" + ] + ] + } + ], + "timestamp": "2026-10-22T17:50:15.299575649", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.10.3" + } + }, "human - bam": { "content": [ { @@ -154,5 +228,79 @@ "nf-test": "0.9.5", "nextflow": "26.10.3" } + }, + "human - bam - intervals - stub": { + "content": [ + { + "compatible_versions": [ + "compatible_versions.yml:md5,62a44f82ee1258428b4afc9d67dc1b4b" + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions_parabricks": [ + [ + "PARABRICKS_MUTECTCALLER", + "parabricks", + "4.8.0-1" + ] + ] + } + ], + "timestamp": "2026-10-22T17:51:43.765405891", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.10.3" + } + }, + "human - bam - tn - stub": { + "content": [ + { + "compatible_versions": [ + "compatible_versions.yml:md5,62a44f82ee1258428b4afc9d67dc1b4b" + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940" + ] + ], + "versions_parabricks": [ + [ + "PARABRICKS_MUTECTCALLER", + "parabricks", + "4.8.0-1" + ] + ] + } + ], + "timestamp": "2026-10-22T17:51:50.990920338", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.10.3" + } } } \ No newline at end of file diff --git a/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config b/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config index f87ad54778f5..51ddc1d3deb9 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config +++ b/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config @@ -8,4 +8,8 @@ process { ext.args2 = '--output-type z --write-index=tbi --no-version' } + withName: 'SAMTOOLS_ADDREPLACERG' { + ext.args = '-m overwrite_all --write-index -O bam' + } + } From b4b2c6ee80aae63924cbeb14147561efe0ad1a77 Mon Sep 17 00:00:00 2001 From: Friederike Hanssen Date: Thu, 29 Oct 2026 07:45:23 +0000 Subject: [PATCH 5/6] parabricks/mutectcaller: emit the tabix index Parabricks writes Parabricks writes .vcf.gz.tbi alongside the VCF, from mutectcaller without a PON and from postpon with one. Expose it as a tbi output so pipelines need no separate indexing step. The index is snapshotted by name only, as its content depends on the VCF header and varies between runs. Generated by Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 --- .../nf-core/parabricks/mutectcaller/main.nf | 2 + .../nf-core/parabricks/mutectcaller/meta.yml | 12 +++ .../mutectcaller/tests/main.nf.test | 8 +- .../mutectcaller/tests/main.nf.test.snap | 80 +++++++++++++++++-- 4 files changed, 90 insertions(+), 12 deletions(-) diff --git a/modules/nf-core/parabricks/mutectcaller/main.nf b/modules/nf-core/parabricks/mutectcaller/main.nf index 9e18bdfc14d2..61402b0272c6 100644 --- a/modules/nf-core/parabricks/mutectcaller/main.nf +++ b/modules/nf-core/parabricks/mutectcaller/main.nf @@ -15,6 +15,7 @@ process PARABRICKS_MUTECTCALLER { output: tuple val(meta), path("*.vcf.gz"), emit: vcf + tuple val(meta), path("*.vcf.gz.tbi"), emit: tbi tuple val(meta), path("*.vcf.gz.stats"), emit: stats path "compatible_versions.yml", emit: compatible_versions, optional: true tuple val("${task.process}"), val('parabricks'), eval("pbrun version | grep -m1 '^pbrun:' | sed 's/^pbrun:[[:space:]]*//'"), topic: versions, emit: versions_parabricks @@ -68,6 +69,7 @@ process PARABRICKS_MUTECTCALLER { def prefix = task.ext.prefix ?: "${meta.id}" """ echo "" | gzip > ${prefix}.vcf.gz + touch ${prefix}.vcf.gz.tbi touch ${prefix}.vcf.gz.stats # Capture the full version output once and store it in a variable diff --git a/modules/nf-core/parabricks/mutectcaller/meta.yml b/modules/nf-core/parabricks/mutectcaller/meta.yml index 2b5e5591786a..93878d238e20 100644 --- a/modules/nf-core/parabricks/mutectcaller/meta.yml +++ b/modules/nf-core/parabricks/mutectcaller/meta.yml @@ -95,6 +95,18 @@ output: pattern: "*.vcf.gz" ontologies: - edam: http://edamontology.org/format_3989 # GZIP format + tbi: + - - meta: + type: map + description: | + Groovy Map containing sample information + e.g. [ id:'test' ] + - "*.vcf.gz.tbi": + type: file + description: Tabix index of the compressed variants file. + pattern: "*.vcf.gz.tbi" + ontologies: + - edam: http://edamontology.org/format_3700 # Tabix index file format stats: - - meta: type: map diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test index 0c3667e9e7e8..988a46478093 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test @@ -51,7 +51,7 @@ nextflow_process { { assert process.success }, { assert variants.count { variant -> variant.start in pon_overlapping } == 4 }, { assert variants.count { variant -> interval_gaps.any { gap -> variant.start in gap } } == 17 }, - { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"], unstableKeys: ["tbi"])).match() } ) } @@ -90,7 +90,7 @@ nextflow_process { assertAll( { assert process.success }, { assert variants.count { variant -> interval_gaps.any { gap -> variant.start in gap } } == 0 }, - { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"], unstableKeys: ["tbi"])).match() } ) } @@ -148,7 +148,7 @@ nextflow_process { assertAll( { assert process.success }, { assert vcf.header.genotypeSamples.sort() == ['normal', 'tumour'] }, - { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"], unstableKeys: ["tbi"])).match() } ) } @@ -212,7 +212,7 @@ nextflow_process { { assert variants.count { variant -> variant.start in pon_overlapping } == 0 }, // postpon flags calls at PON positions { assert variants.find { variant -> variant.start == 45495715 }.hasAttribute('PON') }, - { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"])).match() } + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"], unstableKeys: ["tbi"])).match() } ) } diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap index d6804857e833..f94427d28290 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap @@ -13,6 +13,14 @@ "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "vcf": [ [ { @@ -30,7 +38,7 @@ ] } ], - "timestamp": "2026-10-22T17:02:17.346595961", + "timestamp": "2026-10-29T07:29:33.082777472", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -50,6 +58,14 @@ "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "vcf": [ [ { @@ -75,7 +91,7 @@ } } ], - "timestamp": "2026-10-22T17:02:10.485649575", + "timestamp": "2026-10-29T07:28:51.747209946", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -95,6 +111,14 @@ "test.vcf.gz.stats:md5,a9bfbdd92e86ca832ad6e2dafc561e9f" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi" + ] + ], "vcf": [ [ { @@ -112,7 +136,7 @@ ] } ], - "timestamp": "2026-10-22T17:02:03.472570747", + "timestamp": "2026-10-29T07:39:01.433409231", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -132,6 +156,14 @@ "test.vcf.gz.stats:md5,33493aaf38103a76df205f22d287b17d" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi" + ] + ], "vcf": [ [ { @@ -149,7 +181,7 @@ ] } ], - "timestamp": "2026-10-22T17:51:07.84075849", + "timestamp": "2026-10-29T07:38:36.992728475", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -169,6 +201,14 @@ "test.vcf.gz.stats:md5,730b6c6fd6c35aa7752c2455e9e50847" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi" + ] + ], "vcf": [ [ { @@ -186,7 +226,7 @@ ] } ], - "timestamp": "2026-10-22T17:50:15.299575649", + "timestamp": "2026-10-29T07:38:05.331423388", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -206,6 +246,14 @@ "test.vcf.gz.stats:md5,c58bc062c6f18d38df3892d15548d8c8" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi" + ] + ], "vcf": [ [ { @@ -223,7 +271,7 @@ ] } ], - "timestamp": "2026-10-22T17:01:41.259652653", + "timestamp": "2026-10-29T07:37:46.32194125", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -243,6 +291,14 @@ "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "vcf": [ [ { @@ -260,7 +316,7 @@ ] } ], - "timestamp": "2026-10-22T17:51:43.765405891", + "timestamp": "2026-10-29T07:29:05.449895767", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" @@ -280,6 +336,14 @@ "test.vcf.gz.stats:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e" + ] + ], "vcf": [ [ { @@ -297,7 +361,7 @@ ] } ], - "timestamp": "2026-10-22T17:51:50.990920338", + "timestamp": "2026-10-29T07:29:20.436090658", "meta": { "nf-test": "0.9.5", "nextflow": "26.10.3" From b0cbe226a1561d20967516b9baf3135ae8fcee57 Mon Sep 17 00:00:00 2001 From: Friederike Hanssen Date: Thu, 29 Oct 2026 08:17:42 +0000 Subject: [PATCH 6/6] parabricks/mutectcaller: name outputs after the prefix A PON index not named .tbi is copied to that name, and the copy matched the *.vcf.gz.tbi glob, so tbi emitted two files. Name all outputs after the prefix and test a PON with a differently named index. Also accept csi BAM indexes in meta.yml, quote the prepon error for PON headers with extra contigs, and unquote withName selectors in the test config. Generated by Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 --- .../nf-core/parabricks/mutectcaller/main.nf | 14 ++--- .../nf-core/parabricks/mutectcaller/meta.yml | 19 +++--- .../mutectcaller/tests/main.nf.test | 62 +++++++++++++++++++ .../mutectcaller/tests/main.nf.test.snap | 45 ++++++++++++++ .../mutectcaller/tests/nextflow.config | 4 +- 5 files changed, 126 insertions(+), 18 deletions(-) diff --git a/modules/nf-core/parabricks/mutectcaller/main.nf b/modules/nf-core/parabricks/mutectcaller/main.nf index d93d09c3d966..3d662b935bd3 100644 --- a/modules/nf-core/parabricks/mutectcaller/main.nf +++ b/modules/nf-core/parabricks/mutectcaller/main.nf @@ -17,10 +17,10 @@ process PARABRICKS_MUTECTCALLER { path panel_of_normals_index output: - tuple val(meta), path("*.vcf.gz"), emit: vcf - tuple val(meta), path("*.vcf.gz.tbi"), emit: tbi - tuple val(meta), path("*.vcf.gz.stats"), emit: stats - path "compatible_versions.yml", emit: compatible_versions, optional: true + tuple val(meta), path("${prefix}.vcf.gz"), emit: vcf + tuple val(meta), path("${prefix}.vcf.gz.tbi"), emit: tbi + tuple val(meta), path("${prefix}.vcf.gz.stats"), emit: stats + path "compatible_versions.yml", emit: compatible_versions, optional: true tuple val("${task.process}"), val('parabricks'), eval("pbrun version | grep -m1 '^pbrun:' | sed 's/^pbrun:[[:space:]]*//'"), topic: versions, emit: versions_parabricks when: @@ -33,7 +33,7 @@ process PARABRICKS_MUTECTCALLER { } def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" + prefix = task.ext.prefix ?: "${meta.id}" def intervals_command = intervals ? (intervals instanceof List ? intervals.collect { interval -> "--interval-file ${interval}" }.join(' ') : "--interval-file ${intervals}") : "" // prepon and postpon expect the index at .tbi @@ -48,7 +48,7 @@ process PARABRICKS_MUTECTCALLER { def num_gpus = task.accelerator ? "--num-gpus ${task.accelerator.request}" : "" def normal_bam_flag = normal_bam ? "--in-normal-bam ${normal_bam}" : "" """ - # if panel of normals specified, run prepon + # if panel of normals specified, place its index at .tbi and run prepon ${pon_index_command} ${prepon_command} @@ -69,7 +69,7 @@ process PARABRICKS_MUTECTCALLER { """ stub: - def prefix = task.ext.prefix ?: "${meta.id}" + prefix = task.ext.prefix ?: "${meta.id}" """ echo "" | gzip > ${prefix}.vcf.gz touch ${prefix}.vcf.gz.tbi diff --git a/modules/nf-core/parabricks/mutectcaller/meta.yml b/modules/nf-core/parabricks/mutectcaller/meta.yml index 93878d238e20..9a3597df2d9d 100644 --- a/modules/nf-core/parabricks/mutectcaller/meta.yml +++ b/modules/nf-core/parabricks/mutectcaller/meta.yml @@ -29,9 +29,9 @@ input: - edam: "http://edamontology.org/format_2572" # BAM - tumor_bam_index: type: file - description: (Optional) bai index corresponding to tumor bam file. Only required + description: (Optional) bai or csi index corresponding to tumor bam file. Only required if intervals are provided. - pattern: "*.bam.bai" + pattern: "*.{bai,csi}" ontologies: [] - normal_bam: type: file @@ -41,9 +41,9 @@ input: - edam: "http://edamontology.org/format_2572" # BAM - normal_bam_index: type: file - description: (Optional) bai index corresponding to normal bam file. Only required + description: (Optional) bai or csi index corresponding to normal bam file. Only required if intervals are provided. - pattern: "*.bam.bai" + pattern: "*.{bai,csi}" ontologies: [] - intervals: type: file @@ -71,8 +71,9 @@ input: description: | (Optional) bgzipped panel of normals file. When provided, the module runs prepon, passes it to mutectcaller via --pon and annotates the output with - postpon. Its header must contain only contigs present in the reference - (see `bcftools reheader --fai`). Do not add --pon via ext.args. + postpon. Its header must contain only contigs present in the reference, + otherwise prepon fails with "Chromosome number of pon file doesn't match + reference" (see `bcftools reheader --fai`). Do not add --pon via ext.args. pattern: "*.vcf.gz" ontologies: - edam: http://edamontology.org/format_3989 # GZIP format @@ -88,7 +89,7 @@ output: description: | Groovy Map containing sample information e.g. [ id:'test' ] - - "*.vcf.gz": + - "${prefix}.vcf.gz": type: file description: Compressed variants file. Will include an annotated vcf file if panel of normals is used. @@ -101,7 +102,7 @@ output: description: | Groovy Map containing sample information e.g. [ id:'test' ] - - "*.vcf.gz.tbi": + - "${prefix}.vcf.gz.tbi": type: file description: Tabix index of the compressed variants file. pattern: "*.vcf.gz.tbi" @@ -113,7 +114,7 @@ output: description: | Groovy Map containing sample information e.g. [ id:'test' ] - - "*.vcf.gz.stats": + - "${prefix}.vcf.gz.stats": type: file description: Variant statistics. pattern: "*.vcf.gz.stats" diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test index 988a46478093..499b7c225a52 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test @@ -218,6 +218,68 @@ nextflow_process { } + test("human - bam - pon - renamed index") { + + setup { + run("BCFTOOLS_REHEADER") { + script "../../../bcftools/reheader/main.nf" + process { + """ + input[0] = [ + [ id:'pon' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/germlineresources/mills_and_1000G.indels.hg38.vcf.gz', checkIfExists: true), + [], + [] + ] + input[1] = [ + [ id:'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + """ + } + } + } + + when { + params { + module_args = "--tumor-name tumour --mutect-low-memory" + } + process { + """ + input[0] = [ + [ id:'test' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.recalibrated.sorted.bam', checkIfExists: true), + [], + [], + [], + [] + ] + input[1] = [ // fasta + fasta_fai + [ id: 'reference' ], + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta', checkIfExists: true), + file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/chr21/sequence/genome.fasta.fai', checkIfExists: true) + ] + input[2] = BCFTOOLS_REHEADER.out.vcf.map { meta, vcf -> vcf } + input[3] = BCFTOOLS_REHEADER.out.index.map { meta, tbi -> tbi.copyTo(tbi.resolveSibling('pon.tbi')) } + """ + } + } + + then { + def vcf = path(process.out.vcf[0][1]).vcf + def mutect_command = vcf.header.otherHeaderLines.find { line -> line.key == 'GATKCommandLine' && line.value.contains('ID=mutectcaller,') } + assertAll( + { assert process.success }, + { assert mutect_command.value.contains('--pon ') }, + // the index copied to .tbi must not be emitted + { assert !(process.out.tbi[0][1] instanceof List) }, + { assert file(process.out.tbi[0][1]).name == 'test.vcf.gz.tbi' }, + { assert snapshot(sanitizeOutput(process.out, variantsMD5Keys: ["vcf"], unstableKeys: ["tbi"])).match() } + ) + } + + } + test("human - bam - stub") { options '-stub' diff --git a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap index f94427d28290..5eb0aa57ce65 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap +++ b/modules/nf-core/parabricks/mutectcaller/tests/main.nf.test.snap @@ -187,6 +187,51 @@ "nextflow": "26.10.3" } }, + "human - bam - pon - renamed index": { + "content": [ + { + "compatible_versions": [ + + ], + "stats": [ + [ + { + "id": "test" + }, + "test.vcf.gz.stats:md5,a9bfbdd92e86ca832ad6e2dafc561e9f" + ] + ], + "tbi": [ + [ + { + "id": "test" + }, + "test.vcf.gz.tbi" + ] + ], + "vcf": [ + [ + { + "id": "test" + }, + "test.vcf.gz:md5Variants,1c7638f2c8861c5491570dc79b36af3b" + ] + ], + "versions_parabricks": [ + [ + "PARABRICKS_MUTECTCALLER", + "parabricks", + "4.8.0-1" + ] + ] + } + ], + "timestamp": "2026-10-29T08:10:16.044585038", + "meta": { + "nf-test": "0.9.5", + "nextflow": "26.10.3" + } + }, "human - bam - intervals": { "content": [ { diff --git a/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config b/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config index 51ddc1d3deb9..71c8611159cc 100644 --- a/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config +++ b/modules/nf-core/parabricks/mutectcaller/tests/nextflow.config @@ -4,11 +4,11 @@ process { ext.args = { params.module_args } } - withName: 'BCFTOOLS_REHEADER' { + withName: BCFTOOLS_REHEADER { ext.args2 = '--output-type z --write-index=tbi --no-version' } - withName: 'SAMTOOLS_ADDREPLACERG' { + withName: SAMTOOLS_ADDREPLACERG { ext.args = '-m overwrite_all --write-index -O bam' }