Skip to content

Add modelSummary, walkFluxes, traceFluxPath#660

Merged
edkerk merged 7 commits into
develop3from
feat/flux-navigation
Jun 18, 2026
Merged

Add modelSummary, walkFluxes, traceFluxPath#660
edkerk merged 7 commits into
develop3from
feat/flux-navigation

Conversation

@edkerk

@edkerk edkerk commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Three new analysis functions for exploring and summarising flux distributions:

  • modelSummary(model) — COBRApy-inspired model overview: prints dimensions, objective definition, and — when a flux vector is supplied — the objective value plus uptake/secretion tables for all active exchange reactions
  • walkFluxes(model, fluxes, startRxn) — interactive command-line flux navigator: shows flux-carrying reactions connected through shared metabolites, grouped by metabolite with role labels; type a number to step, b to go back, q to quit
  • traceFluxPath(model, fluxes, fromRxn, toRxn) — best-first search for the highest-flux-fraction path between two reactions; returns pathRxns, pathMets, and cumFrac

All three use parseRAVENargs for name-value argument handling. Tests added in tQueries (modelSummaryNoFluxRuns, modelSummaryWithFluxRuns) and tAnalysis (traceFluxPathReturnsCells, traceFluxPathSameReactionIsIdentity).

modelSummary (queries/): COBRApy-style model overview — prints model
dimensions, objective, and when a flux vector is supplied, the objective
value and exchange fluxes partitioned into uptake and secretion.

walkFluxes (analysis/): interactive CLI flux navigator. Starting from a
chosen reaction, shows all flux-carrying neighbours grouped by shared
metabolite. The user steps to any neighbour by number; a history stack
supports going back with 'b'. Useful for manually tracing how flux flows
through the network without knowing the full topology.

traceFluxPath (analysis/): finds the highest-flux-fraction path between
two reactions. At each metabolite junction flux is split proportionally
among consuming reactions; the path maximising the cumulative fraction is
returned via best-first search. Returns pathRxns, pathMets, cumFrac and
prints an annotated one-line path with per-junction percentages.
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Function test results

211 tests   190 ✅  37s ⏱️
 22 suites   21 💤
  1 files      0 ❌

Results for commit d07e8ca.

♻️ This comment has been updated with latest results.

edkerk added 6 commits June 18, 2026 22:24
col = model.S(:,j) is sparse, so col(m) is a sparse scalar; cellfun
cannot collect sparse values into a double array. full() converts it
before multiplication so the cell stores a plain double.
model.S is sparse, so col(m) and row(n) yield sparse scalars.
fprintf/sprintf reject sparse inputs; arithmetic propagates the
sparsity. Convert column/row extractions from model.S to full
arrays at the point of extraction so all downstream math is dense.
- Add gene-protein-reaction rules (grRules) to the reaction header
- Always show a reaction number, even when the same reaction appears under
  multiple metabolites; drop the "(same as #N)" cross-reference line
- Label each neighbour as 'produces' or 'consumes' relative to the shared
  metabolite, making flux direction immediately readable
- Simplify metabolite header: drop "here" and the redundant sign; show
  absolute net flux magnitude alongside consumed/produced
- Rewrite prompt to explicit action labels (1-N: step, b: back, q: quit)
- Skip metabolites with net flux below cutoff to avoid zero-flux noise
- Apply full() to S column/row extractions to avoid sparse-scalar errors
By default (traceMaterial=true) the path search now skips common currency
and cofactor metabolites (ATP/ADP, NAD/NADH, CoA, H2O, Pi, CO2, redox
carriers, …) so the returned path represents carbon-skeleton flow rather
than energy-carrier shortcuts.

Three new name-value parameters:
  traceMaterial (default true)  — enable the built-in currency exclusion
  carbonOnly    (default false) — additionally require C≥1 from metFormulas
  excludeMets   (default {})    — user-supplied additions to the list

The exclusion is applied at metabolite-selection time in the best-first
search, so ATP→ADP shortcuts are simply never explored. When no material
path exists the verbose output suggests trying traceMaterial=false.
Bare comment-only lines inside a {} literal act as row separators in MATLAB,
creating a ragged cell array that fails vertcat when rows have different
element counts. Replaced section-header comments inside the cell with
inline comments after ... on data lines.
@edkerk edkerk merged commit e6081fa into develop3 Jun 18, 2026
4 checks passed
@edkerk edkerk deleted the feat/flux-navigation branch June 18, 2026 22:06
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.

1 participant