Skip to content

feat: generate the animal GEMs from Human-GEM in Python - #1141

Merged
edkerk merged 8 commits into
developfrom
feat/421-generate-animal-gem
Oct 7, 2026
Merged

edkerk merged 8 commits into
developfrom
feat/421-generate-animal-gem

Conversation

@edkerk

@edkerk edkerk commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Main improvements in this PR:

Closes #421. code/animalGEM/generateAnimalGEM.py replaces the five masterScript<Species>GEM.m scripts of the Mouse, Rat, Worm, Fruitfly and Zebrafish GEMs. The species is an argument; everything species-specific is read from the Animal-GEM repository (data/human2<Species>Orthologs.tsv, <species>SpecificRxns.tsv, <species>SpecificMets.tsv).

python code/animalGEM/generateAnimalGEM.py Mouse --repo ../Mouse-GEM --human-repo ../Human-GEM-release [--version 1.9.0] [--solver gurobi]

It takes no input from the terminal and reads and writes only the repositories involved, so a developer and a CI job run the same command (--repo / $ANIMAL_GEM_REPO, --human-repo / $HUMAN_GEM_REPO).

Built on a stable release. The template, the gene and annotation tables and the task list are read from a Human-GEM checkout, normally a release tag (git worktree add ../Human-GEM-release v2.1.0). A model without a version (develop) is refused unless --allow-unreleased is given.

Steps. Rewrite the GPRs through the Alliance of Genome Resources orthologs; add the species-specific network; gap-fill the essential tasks from Human-GEM; stamp version and date into the model metadata (the requirement of Fruitfly-GEM#7); write the yml, mat, xml and annotation tables. The draft uses raven-toolbox's get_model_from_homology (keep_gene_free, preserve_notes) and set_model_metadata, so it needs a raven-toolbox that includes CompMetEng/raven-toolbox#166 and #167 (requirements.txt installs from git). Gene symbols that a GPR cannot hold (E(spl)m3-HLH, dib[m], the Drosophila gene or) get a valid gene id and keep the symbol as the gene name. The previous MATLAB functions are replaced by generateAnimalGEM.m, which follows the same steps and options and gives the same model and annotation tables as the Python generator for all five species (checked on Human-GEM 2.1.0). It needs RAVEN 3 with SysBioChalmers/RAVEN#757 (homology options) and SysBioChalmers/RAVEN#758 (SBML export of gene ids with a dash). cleanGrRules, replaceGrRules and translateGrRules, which other code uses, move to code/GPRs. Both generators resolve gap-filling ties (fewest, lowest-id reactions), so the gap-filled set does not depend on the solver.

MAR00021. The animal GEMs keep MAR00021 as their objective. In Human-GEM 2.0.0-2.1.0 it cannot carry flux on Ham's medium, because its cofactor pool MAR00022 needs [protein]-N6-(lipoyl)lysine, which nothing produces since the lipoylation curation. For those releases the generator swaps it for lipoic acid in memory (as MAR10065 uses), notes it on the reaction and logs it. Curating this in Human-GEM is #1140; remove the swap once it lands. --keep-biomass keeps the human biomass reaction instead.

Versioning. An animal GEM's major.minor follows the Human-GEM release it is built on; the patch number is its own. Without --version the generator keeps a matching version and otherwise uses <major>.<minor>.0; a --version with another major.minor is refused.

Regenerated models. Mouse-GEM, Rat-GEM, Worm-GEM, Fruitfly-GEM and Zebrafish-GEM each have a PR regenerating version 2.1.0 from Human-GEM 2.1.0 with this generator; they depend on this PR.

Tested.

  • Run on Human-GEM v1.18.0, the generator reproduces the committed Mouse-GEM 1.8.0 exactly: the same 12987 reactions and 2846 genes, with identical gene sets on every reaction.
  • Run on v2.1.0, all five species complete (Mouse 0, Rat 0, Worm 37, Fruitfly 39, Zebrafish 1 gap-filled reactions; Gurobi).
  • 55 unit tests pass (ortholog filter, gene ids, species network, annotation merge, metadata, MAR00022 swap) and ruff is clean.

Known issues in the species data (not in this PR). Against v2.1.0, 18 of 60 Worm and 11 of 31 Fruitfly species-specific reactions are not mass or charge balanced, and Worm-GEM uses the old metabolite name H2S2O3 (now thiosulfate). The generator reports unmatched metabolites and unbalanced reactions (not sinks or demands). Fixes are in SysBioChalmers/Worm-GEM#9 and SysBioChalmers/Fruitfly-GEM#13, carried in the regeneration PRs.

I hereby confirm that I have:

  • Tested my changes locally
  • Selected develop as a target branch

generateAnimalGEM.py replaces the five masterScript<Species>GEM.m scripts. The species is an
argument and everything species-specific is read from the Animal-GEM repository, so a
developer and a CI job run the same command. It rewrites the GPRs through the Alliance
orthologs, adds the species-specific network, gap-fills the essential tasks, stamps the
version and date into the model metadata, and writes the model and annotation files.

For Human-GEM 2.0.0-2.1.0 the cofactor pool of MAR00021 is switched from lipoyl-lysine to
lipoic acid in memory, because MAR00021 cannot carry flux otherwise (#1140).
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Model quality report

⚠️ 6 pre-existing finding(s), no regressions vs develop. Non-blocking. Gates: duplicate keys 0 ✅, growth 1.9 ✅.

Section Status
Model & network checks (20) ⚠️ 6 pre-existing
Model file & metabolic tasks (6) ✅ all pass
MEMOTE ✅ 63.8% (core subset)
Full report model_qc_summary.md

Pre-existing:

  • Reactions split across compartments: 26
  • Reactions flagged by MACAW dead-end test: 1111
  • Reactions flagged as MACAW duplicates: 340
  • Mass-imbalanced reactions: 69
  • Charge-imbalanced reactions: 172
  • Structure vs formula/charge inconsistencies: 57

✅ unchanged · ✨ improved vs develop · ⚠️ pre-existing, non-blocking · ❌ regression

Full workflow run · this comment is edited as results come in

edkerk and others added 6 commits October 5, 2026 22:43
…ions

get_model_from_homology (keep_gene_free, preserve_notes) and set_model_metadata replace the
local GPR rewriting and metadata code. Gene symbols that a GPR cannot hold, such as
E(spl)m3-HLH, dib[m] or the Drosophila gene "or", get a valid gene id and keep the symbol as
the gene name; the species-specific metabolites that Human-GEM no longer knows by name are
reported together. The lipoyl-lysine fix also applies to the unversioned develop model.
The template, orthology, annotation tables and task list now come from a Human-GEM checkout
(--human-repo, normally a release tag). A model without a version (develop) is refused unless
--allow-unreleased is given.
…arn on unbalanced species reactions

The raven homology call left homology_source on every reaction and kept rxnFrom/metFrom, which
the previous scripts removed. The lipoic acid swap in MAR00022 is now noted on the reaction, a
template without a model id (older releases) no longer fails, and species-specific reactions
that are not balanced against the template are reported.
Without --version an animal GEM keeps its version when its major.minor matches the Human-GEM
release it is built on, and becomes <major>.<minor>.0 of that release otherwise. A requested
version with another major.minor is refused.
…ator

generateAnimalGEM.m replaces the previous MATLAB animal GEM functions (updateAnimalGEM,
getModelFromOrthology, addMetabolicNetwork, gapfill4EssentialTasks, updateAnimalAnnotations,
extractAllianceGenomeOrthologs, countFrequency). It uses RAVEN 3's getModelFromHomology with
complexPolicy, keepGeneFree and preserveNotes, and gives the same model and annotation tables
as generateAnimalGEM.py for all five species. cleanGrRules, replaceGrRules and
translateGrRules, which other code uses, move to code/GPRs.

Both generators resolve gap-filling ties, so the gap-filled set does not depend on the solver,
and keep the Human-GEM notes of gap-filled reactions.
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