diff --git a/subworkflows/msk/netmhcstabandpan/main.nf b/subworkflows/msk/netmhcstabandpan/main.nf index f8f73a9a..603d2005 100644 --- a/subworkflows/msk/netmhcstabandpan/main.nf +++ b/subworkflows/msk/netmhcstabandpan/main.nf @@ -58,16 +58,19 @@ def createNETMHCInput(fastas_and_hla, sv_fastas) { [it[0],it] } + // remainder: true keeps samples that have no SV data (sv_fastas is empty when no SVs provided) def merged_mut = fastas_and_hla_channel - .join(sv_fastas_channel, by:0) + .join(sv_fastas_channel, by:0, remainder: true) .map({ - [it[1][0], it[1][1], it[2][1], it[1][3], "MUT"] + def sv = it[2] ?: [null, [], []] + [it[1][0], it[1][1], sv[1], it[1][3], "MUT"] }) def merged_wt = fastas_and_hla_channel - .join(sv_fastas_channel, by:0) + .join(sv_fastas_channel, by:0, remainder: true) .map({ - [it[1][0], it[1][2], it[2][2], it[1][3], "WT"] + def sv = it[2] ?: [null, [], []] + [it[1][0], it[1][2], sv[2], it[1][3], "WT"] }) def merged = merged_mut.mix(merged_wt) return merged diff --git a/subworkflows/msk/netmhcstabandpan/tests/main.nf.test b/subworkflows/msk/netmhcstabandpan/tests/main.nf.test index 5cf809f1..b66c6e33 100644 --- a/subworkflows/msk/netmhcstabandpan/tests/main.nf.test +++ b/subworkflows/msk/netmhcstabandpan/tests/main.nf.test @@ -162,6 +162,43 @@ nextflow_workflow { } + test("netmhcstabandpan - empty SV channel - fa,hla_str - tsv - stub") { + + // Regression test: when no SV files are provided, the upstream NEOSV process + // doesn't run, so the sv_fasta channel emits zero items. The createNETMHCInput + // helper must still emit MUT and WT tuples for each sample. + + options "-stub" + + when { + workflow { + """ + input[0] = channel.value([ + [ id:'test', single_end:false ], // meta map + file('MUT_sequence_fa', checkIfExists: false), + file('WT_sequence_fa', checkIfExists: false), + "HLA-A24:02,HLA-A24:02,HLA-B39:01,HLA-B39:01,HLA-C07:01,HLA-C06:02", + ]) + + input[1] = channel.empty() + """ + } + } + + then { + assertAll( + { assert workflow.success }, + { assert snapshot(workflow.out.tsv[0][0], + file(workflow.out.tsv[0][1]).name, + workflow.out.tsv[1][0], + file(workflow.out.tsv[1][1]).name + ).match() + } + ) + } + } + + test("netmhcstabandpan - fa,hla_str - tsv - stub") { options "-stub" diff --git a/subworkflows/msk/netmhcstabandpan/tests/main.nf.test.snap b/subworkflows/msk/netmhcstabandpan/tests/main.nf.test.snap index abc199b4..c07459e2 100644 --- a/subworkflows/msk/netmhcstabandpan/tests/main.nf.test.snap +++ b/subworkflows/msk/netmhcstabandpan/tests/main.nf.test.snap @@ -212,5 +212,30 @@ "nextflow": "25.10.2" }, "timestamp": "2025-12-19T14:22:41.854041255" + }, + "netmhcstabandpan - empty SV channel - fa,hla_str - tsv - stub": { + "content": [ + { + "id": "test", + "single_end": false, + "typeMut": false, + "fromStab": false, + "typePan": true + }, + "test.WT.PAN.tsv", + { + "id": "test", + "single_end": false, + "typeMut": false, + "fromStab": true, + "typePan": true + }, + "test.WT.STAB.tsv" + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "24.10.2" + }, + "timestamp": "2026-05-13T22:29:19.315483" } } \ No newline at end of file