Skip to content

Flowchart

Moumard Corentin edited this page May 22, 2026 · 5 revisions

This flowchart details all execution paths through BubbleFinder, from input parsing to output, for each available command.

flowchart TD
  A["Start: ./BubbleFinder COMMAND -g GRAPH -o OUT"] --> A0["Parse options<br>-j THREADS, -T, output flags"]
  A0 --> B["Read input file (option -g).<br>Auto-detect compression: .gz / .bz2 / .xz"]
  B --> C{"Input format?"}
  C -->|"--gfa or *.gfa / *.gfa1"| D["Parse GFA as bidirected graph"]
  C -->|"*.gbz"| Z["Load GBZ topology<br>skip GBWT metadata not needed for enumeration"]
  C -->|"--gfa-directed"| E["Parse GFA as directed graph"]
  C -->|"--graph or *.graph"| F["Parse .graph as directed graph"]

  D --> G{"Command"}
  Z --> G
  E --> G
  F --> G

  %% SNARLS
  G -->|snarls| S0["Build undirected counterpart<br>of the bidirected graph"]
  S0 -->|"For each connected component"| S1["Compute BC-tree + SPQR trees<br>with the spqr-rust backend"]
  S1 --> S_comp{"--sp-compress mode?"}
  S_comp -->|"off"| S2a["Use full SPQR skeletons"]
  S_comp -->|"on / instrument / macro-direct"| S2b["Use compressed SPQR cores<br>for large degree-2 regions"]
  S2a --> S3["Traverse SPQR trees.<br>Enumerate ALL snarls (linear time)"]
  S2b --> S3
  S3 --> S_triv{"-T flag?"}
  S_triv -->|"yes (include trivial)"| S4a["Keep clique-lines"]
  S_triv -->|"no (default: exclude trivial)"| S4b["Expand cliques to pairs<br>and filter trivial snarls"]
  S4a --> O0
  S4b --> O0

  %% SUPERBUBBLES
  G -->|superbubbles| SB_mode{"--directed flag?"}

  SB_mode -->|"no (default: bidirected)"| SB0["Build doubled directed graph<br>with oriented copies v+ / v- for each segment v"]
  SB0 -->|"For each connected component"| SB1["Compute BC-tree + SPQR trees<br>with the spqr-rust backend"]
  SB1 --> SB2["Traverse SPQR trees with DP on skeletons.<br>Enumerate ALL superbubbles<br>on the doubled graph"]
  SB2 --> SB3["Orientation projection.<br>Merge mirror bubbles, drop +/- , sort endpoints"]
  SB3 --> SB_triv{"-T flag?"}
  SB_triv -->|"yes (include trivial)"| SB4a["Keep all segment ID pairs"]
  SB_triv -->|"no (default: exclude trivial)"| SB4b["Filter trivial superbubbles"]
  SB4a --> O0
  SB4b --> O0

  SB_mode -->|"yes (--directed)"| DSB0["Use directed input as-is"]
  DSB0 -->|"For each connected component"| DSB1["Compute BC-tree + SPQR trees<br>with the spqr-rust backend"]
  DSB1 --> DSB2["Traverse SPQR trees with DP on skeletons.<br>Enumerate ALL directed superbubbles"]
  DSB2 --> DSB_triv{"-T flag?"}
  DSB_triv -->|"yes (include trivial)"| DSB3a["Keep all oriented ID pairs"]
  DSB_triv -->|"no (default: exclude trivial)"| DSB3b["Filter trivial superbubbles"]
  DSB3a --> O0
  DSB3b --> O0

  %% ULTRABUBBLES
  G -->|ultrabubbles| U_mode{"Backend option?"}

  U_mode -->|"default oriented backend"| U0{"At least 1 tip or 1 cut vertex<br>per connected component?"}
  U0 -->|no| Ufail["Fail: need at least 1 tip or cut vertex per CC"]
  U0 -->|yes| U1["Orient each CC via DFS<br>starting from a tip or cut vertex"]
  U1 --> U2["Resolve same-sign conflicts<br>by adding auxiliary tips (linear size)"]
  U2 --> U3["Run CLSD directed weak superbubble decomposition"]
  U3 --> U4["Map weak superbubbles back to ultrabubbles.<br>Discard bubbles with auxiliary endpoints"]
  U4 --> U_tree{"--clsd-trees FILE?"}
  U_tree -->|yes| U8["Also write ultrabubble hierarchy"]
  U_tree -->|no| U_triv
  U8 --> U_triv

  U_mode -->|"--doubled"| UD0["Build doubled directed graph<br>(no CC restriction)"]
  UD0 -->|"For each connected component"| UD1["Run CLSD directed weak superbubble decomposition<br>on doubled graph"]
  UD1 --> UD2["Map back to ultrabubbles.<br>Discard auxiliary endpoints"]
  UD2 --> U_triv

  U_mode -->|"--spqr-weak-superbubbles"| US0["Use SPQR-tree weak superbubble backend"]
  US0 --> US1["Run weak-superbubble SPQR solver<br>and map results to ultrabubble incidences"]
  US1 --> U_triv

  U_triv{"-T flag?"}
  U_triv -->|"yes (include trivial)"| U5a["Keep all oriented incidence pairs"]
  U_triv -->|"no (default: exclude trivial)"| U5b["Filter trivial ultrabubbles"]
  U5a --> O0
  U5b --> O0

  %% SPQR-TREE OUTPUT
  G -->|spqr-tree| P0{"GFA / GBZ input?"}
  P0 -->|no| Pfail["Fail: spqr-tree requires GFA/GBZ input"]
  P0 -->|yes| P1["Compute components + BC-tree + SPQR decomposition"]
  P1 --> P2["Output .spqr v0.4 file"]
  P2 --> End

  %% COMMON OUTPUT
  O0{"--compact-output-chains?"}
  O0 -->|yes| O1["Compact consecutive output pairs<br>into maximal chains"]
  O0 -->|no| O2["Write N + result lines to OUT"]
  O1 --> O2
  O2 --> End["Done"]
Loading

Clone this wiki locally