Skip to content

Guard against running on an empty per-sample input list in tximport/quantify_rsem#12378

Open
pinin4fjords wants to merge 2 commits into
nf-core:masterfrom
pinin4fjords:fix/empty-collect-guard
Open

Guard against running on an empty per-sample input list in tximport/quantify_rsem#12378
pinin4fjords wants to merge 2 commits into
nf-core:masterfrom
pinin4fjords:fix/empty-collect-guard

Conversation

@pinin4fjords

Copy link
Copy Markdown
Member

Description

Follow-up to #12377, caught by downstream CI on the nf-core/rnaseq consuming PR (nf-core/rnaseq#1885).

#12377 swapped collect() for toSortedList() on the per-sample inputs feeding TXIMETA_TXIMPORT and CUSTOM_RSEMMERGECOUNTS, to make the staged input order (and therefore the task hash) deterministic. That swap has a side effect: toSortedList() always emits exactly one value, even [], on an empty upstream, whereas the collect() it replaced emits nothing at all when the upstream is empty.

In a pipeline run where every sample is filtered out before reaching this point (e.g. all samples fail a trim-length threshold), the per-sample channel closes with zero elements. With the old collect(), that meant TXIMETA_TXIMPORT/CUSTOM_RSEMMERGECOUNTS were never invoked at all - a queue channel with no matching emission on one side means no invocation. With toSortedList(), the channel now emits a single [] value, so the process fires once with zero staged files, producing empty output files instead of being skipped.

Changes

Add .filter { sorted -> sorted.size() > 0 } after each toSortedList() in both subworkflows, matching the guard already used for CUSTOM_TX2GENE's input in the same subworkflow. Restores the original no-op-on-empty behaviour while keeping the ordering deterministic for the non-empty case.

PR checklist

  • This comment contains a description of changes (with reason).
  • nf-core subworkflows test quant_tximport_summarizedexperiment --profile docker passes, snapshot unchanged.
  • nf-core subworkflows test quantify_rsem --profile docker passes, snapshot unchanged.

toSortedList() always emits (even []) on an empty upstream, unlike the
collect() it replaced which emits nothing at all. Without a guard, that
turns a channel that previously never triggered its downstream process
into one that always does, running CUSTOM_RSEMMERGECOUNTS/TXIMETA_TXIMPORT
once with zero staged files whenever no samples reach this point (e.g.
all samples filtered out upstream). Filter to size() > 0 to restore the
original no-op-on-empty behaviour.
pinin4fjords added a commit to pinin4fjords/rnaseq that referenced this pull request Jul 15, 2026
toSortedList() always emits (even []) on an empty upstream, unlike the
collect() it replaced which emits nothing at all. Without a guard, a
channel that previously never triggered its downstream process now
always does, running CUSTOM_RSEMMERGECOUNTS/TXIMETA_TXIMPORT once with
zero staged files whenever no samples reach this point (e.g. all
samples filtered out upstream). Filter to size() > 0 to restore the
original no-op-on-empty behaviour.

Applied here ahead of the modules.json bump; nf-core/modules#12378
carries the same fix upstream. Once that merges, only the pinned
git_sha needs updating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants