gxwf-layout#

gxwf-layout computes node positions for a Galaxy workflow (Format 2 .gxwf.yml or native .ga) and merges {left, top} position records back into the document, replacing the degenerate diagonal layout Galaxy applies when positions are absent. For Format 2 YAML the original comments, key order, and quoting are preserved; only position records are added or updated.

It gives hand-authored and machine-generated workflows sensible, stable coordinates without opening them in the Galaxy workflow editor.

Cyclic workflows are invalid in Galaxy and are rejected with an error rather than laid out.

Strategies#

topological (default)

Strict layering: column is the longest path from any input, row is declaration order within the column. Dependency-free and identical to gxwf-viz –layout topological (a cross-language layout shared with the TypeScript port). Legible but applies no crossing reduction, so wide workflows can show more edge crossings.

layered

Sugiyama-style layered layout: the same longest-path layering plus a barycenter crossing-reduction pass that reorders rows to align each node with its neighbors. Fewer edge crossings on wide/real workflows. The exact coordinates are not a cross-language contract; both strategies satisfy the same structural properties (every edge points rightward, roots are leftmost, no overlapping nodes).

Comparing the strategies#

Both strategies assign the same columns; layered only reorders the rows within each column to pull connected nodes into line. On dense, real-world graphs this removes most edge crossings. The figures below lay out the amr_gene_detection IWC workflow (13 nodes, 28 edges, 4 layers) both ways – positions stripped, recomputed by each strategy, and rendered with gxwf-viz –layout preset (which honors the baked positions). Layered cuts the crossings from 13 to 2:

amr_gene_detection laid out with the topological strategy

gxwf-layout --strategy topological – 13 edge crossings.#

amr_gene_detection laid out with the layered strategy

gxwf-layout --strategy layered – 2 edge crossings.#

Both layouts satisfy the same structural properties (every edge points rightward, roots are leftmost, no overlapping nodes); the workflow ships as the real-amr-gene-detection.ga example fixture.

Subworkflows#

By default gxwf-layout recurses into subworkflows defined within the same file, giving each its own coordinate space:

  • Format 2 steps with an embedded run: GalaxyWorkflow block

  • native steps carrying an inline subworkflow: block

  • every workflow in a $graph multi-workflow document

Subworkflows referenced by file path, URL, or $graph #id are not followed – at each level such a step is treated as a single node, matching the Cytoscape builder. Pass --no-recursive to lay out only the top-level document.

This script computes node positions for a Galaxy workflow (Format 2 .gxwf.yml or native .ga) and merges them back into the document, replacing the degenerate diagonal layout applied when positions are absent.

For Format 2 YAML the original file’s comments and formatting are preserved; only position records are added or updated. Steps/inputs with an explicit position are left untouched unless –overwrite is given; a “position: auto” marker is always replaced.

usage: gxwf-layout [-h] [--strategy {topological,layered}] [--overwrite]
                   [--no-recursive]
                   INPUT [OUTPUT]

Positional Arguments#

INPUT

input workflow path (.ga/.gxwf.yml)

OUTPUT

output path (defaults to updating INPUT in place)

Named Arguments#

--strategy

Possible choices: topological, layered

layout strategy (default: topological). ‘topological’ is the dependency-free, cross-language layering; ‘layered’ adds barycenter crossing reduction for fewer edge crossings on wide workflows.

Default: 'topological'

--overwrite

overwrite existing explicit positions (default: only fill missing / ‘auto’)

Default: False

--no-recursive

do not lay out embedded in-file subworkflows (default: recurse into Format2 ‘run:’ blocks, native ‘subworkflow:’ blocks, and $graph entries)

Default: True