Skip to content

fix: keep everything of every model in merge_models; name the subsystem of transport reactions - #180

Merged
edkerk merged 3 commits into
developfrom
fix/merge-models-and-transport-subsystem
Oct 21, 2026
Merged

edkerk merged 3 commits into
developfrom
fix/merge-models-and-transport-subsystem

Conversation

@edkerk

@edkerk edkerk commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Two differences from RAVEN found by a review of the RAVEN and raven-toolbox pairs and confirmed by running the MATLAB side (RAVEN 79a7d8c, R2024b) on a cluster. Related: CompMetEng/raven-gecko-parity#139 (ledger notes) and the review in that repository.

  • manipulation.merge_models: only metabolites and genes that a reaction uses were added, and the objective was dropped. RAVEN's mergeModels keeps every metabolite and gene of every model and concatenates the objective. On MATLAB an unused metabolite and gene survive and both objectives are kept (53 metabolites, 62 genes, two non-zero objective entries for two copies of smallYeast with one extra of each). The objective direction now comes from the first model.
  • manipulation.merge_models: a compartment named in several models took the last model's name (RAVEN: the first). Compartments without metabolites were not carried over (RAVEN keeps them).
  • manipulation.merge_models: new metabolites and genes were added in the order in which reactions reached them. Genes came out in a different order under different PYTHONHASHSEED values, because cobra builds the genes of a rule from a set. They are now added in the order of their source model, before the reactions; a test runs the merge under three hash seeds and requires identical output.
  • manipulation.add_transport_reactions: the subsystem of the new reactions was empty. RAVEN's addTransport sets Transport between <from> and <to> (reversible) or Transport from <from> to <to> (irreversible), using the compartment ids; on MATLAB, a transport between c and m gets Transport between c and m.

Each fix has tests: 13 new tests, 11 of which fail on the previous code and pass now; the other two guard behaviour that was already right. Full suite: 1166 passed, 9 skipped; ruff and mypy are clean for the changed files.

Not checked: the genome-scale parity tests (pytest -m parity) need a full Gurobi licence and were not run. The MATLAB side was run for the behaviour of RAVEN, not for the new Python code.

…em of transport reactions

merge_models added only the metabolites and genes that a reaction uses, dropped the objective, gave a compartment name to the last model that named it, and ordered new metabolites and genes by the reactions that reached them. RAVEN's mergeModels keeps all metabolites, genes and compartments of every model, concatenates the objective, keeps the first model's compartment name, and appends new items in the order of their source model. Confirmed on MATLAB (RAVEN 79a7d8c): an unused metabolite and gene survive and both objectives are kept.

add_transport_reactions left the subsystem empty. RAVEN's addTransport sets "Transport between <from> and <to>" (reversible) or "Transport from <from> to <to>" (irreversible), using the compartment ids; confirmed on MATLAB for c and m.
The test passed -I, which makes Python ignore PYTHONHASHSEED, and replaced the whole environment, which stops Python from starting on Windows (no SYSTEMROOT). It now keeps the environment and sets the seed.
pip 26.2.2 refuses to replace itself on Windows when run as plain pip and exits 1, so every Windows job failed before running any test.
@edkerk
edkerk merged commit d555138 into develop Oct 21, 2026
8 checks passed
@edkerk
edkerk deleted the fix/merge-models-and-transport-subsystem branch October 21, 2026 17:55
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