From 8d71ac482cf425f148d5f7e5fab7cd328f138b40 Mon Sep 17 00:00:00 2001 From: John Orgera <65687576+johnoooh@users.noreply.github.com> Date: Wed, 13 May 2026 22:32:14 -0400 Subject: [PATCH] Fix NETMHCSTABANDPAN to support samples without SV data The createNETMHCInput helper used an inner .join() on the SV fasta channel. When the upstream NEOSV process does not run (no structural variants provided in the samplesheet, a common case), the SV channel emits zero items and the inner join silently produces an empty channel, causing NETMHCSTABPAN, NETMHCPAN4, and all downstream subworkflow steps to be skipped. Switch to a left join with remainder: true and default to empty file lists when there is no SV match, so MUT/WT tuples are still emitted per sample whether or not SV data is present. Adds a regression test that drives input[1] = channel.empty() to lock in the SV-less code path. --- subworkflows/msk/netmhcstabandpan/main.nf | 11 ++++-- .../msk/netmhcstabandpan/tests/main.nf.test | 37 +++++++++++++++++++ .../netmhcstabandpan/tests/main.nf.test.snap | 25 +++++++++++++ 3 files changed, 69 insertions(+), 4 deletions(-) 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