Home Pattern

Galaxy: conditionals patterns

Choose a Galaxy when gate, routed output, fallback, or collection cleanup by what must change downstream.

Revised
2026-09-23
Rev
2

Galaxy: conditionals patterns

Choose by what should happen when the condition is false: skip a step, select one value for a continuing path, or remove unusable collection members. The linked pages give the construction details. The iwc-conditionals-survey records the IWC evidence behind them.

Galaxy steps in the observed patterns receive a boolean through an input named when and declare when: $(inputs.when). If later steps require an output from a skipped branch, give them an explicit merge or fallback. A when gate alone does not provide that value.

Skip work without replacing its output

  • User choice or another available boolean: conditional-run-optional-step gates an optional step or branch whose output need not feed an unconditional downstream step. Gate every step that belongs to the optional branch.
  • Upstream result may be empty: conditional-gate-on-nonempty-result derives a boolean from dataset content or collection emptiness, then gates reporting, visualization, or export. The MGnify collection-to-boolean chain is corpus-backed and verified against Galaxy release_25.1, but takes four shim steps. Use its known-good shape until a shorter one is verified.

Continue with one value

  • Peer alternatives: conditional-route-between-alternative-outputs gates the possible modes and merges their compatible outputs with pick_value. If exactly one mode must produce a value, choose merge behavior that detects zero or multiple live outputs rather than silently taking the first.
  • Optional change to an existing value: conditional-transform-or-pass-through gates the transform and uses pick_value to prefer its output when present, with the original value as the fallback. This preserves one downstream input without duplicating the rest of the workflow.

Clean a collection instead

collection-cleanup-after-mapover-failure drops or replaces empty or failed elements after map-over. It changes collection membership or contents, while a when gate skips a whole step. If dropping elements affects alignment with a sibling collection, see galaxy-collection-patterns for the next choice.

__FILTER_NULL__ can filter null outputs after conditional steps, but the conditionals survey found no IWC use from which to establish a pattern. That absence alone does not make the capability an anti-pattern.

See Also

Incoming References (5)

  • Iwc Conditionals Survey related note — Corpus survey of Galaxy conditional step usage in IWC, covering when-gates, boolean shims, and routed output selection.
  • Iwc Conditionals Survey related pattern — Corpus survey of Galaxy conditional step usage in IWC, covering when-gates, boolean shims, and routed output selection.
  • Iwc Map Over Lifecycle Survey related pattern — Survey of IWC map-over lifecycle recipes, with a Nextflow-to-Galaxy crosswalk for collection construction, cleanup, reshape, reduce, and publish phases.
  • Nextflow: branch, filter, and ifEmpty to Galaxy filters and gates implemented_by_patterns — Route Nextflow branch, filter, and ifEmpty channel idioms to Galaxy collection cleanup, identifier filters, when gates, or review.
  • Nextflow: source pattern map implemented_by_patterns — Use this source-pattern map to route recurring Nextflow channel and operator idioms to Galaxy implementation patterns.