Skip to content

feat: add human_gem Python package with load_model() - #1069

Open
edkerk wants to merge 2 commits into
developfrom
feat/human-gem-python-package
Open

feat: add human_gem Python package with load_model()#1069
edkerk wants to merge 2 commits into
developfrom
feat/human-gem-python-package

Conversation

@edkerk

Copy link
Copy Markdown
Member

Main improvements in this PR:

First increment towards a pip-installable Python interface to Human-GEM (dual-language support). human_gem.load_model() loads Human-GEM as a fully annotated cobra model — reading the YAML via raven-toolbox and merging the cross-references + SBO terms from the annotation tables, which a bare cobra.io.load_yaml_model does not do:

importhuman_gemmodel=human_gem.load_model() # annotated cobra.Model
  • pyproject.toml — package human-gem (deps: cobra, pandas, raven-toolbox)
  • human_gem/io.pyload_model(model_dir=None, annotate=True)
  • human_gem/annotation.py — the TSV → MIRIAM/SBO merge (packaged home of the logic currently in code/annotateGEM.py)

Verified locally (raven-toolbox 0.3.0): load_model() attaches cross-references to 12698/12877 reactions, 8449/8460 metabolites and all 2848 genes; annotate=False returns the bare model.

This increment is deliberately small and non-disruptive — it adds new files and imports nothing existing, so it does not touch the current MATLAB or Python CI. Planned next increments:

  1. reduce code/annotateGEM.py to a thin shim importing from human_gem.annotation (single source of truth) + install the package in the Python CI;
  2. promote the ftINIT gene-essentiality and metabolic-task helpers into the package;
  3. bundle/resolve the model files for a true pip install distribution.

No model changes.

I hereby confirm that I have:

  • Any removed reactions and metabolites have been moved to the corresponding deprecated identifier lists in data/deprecatedIdentifiers/.
  • This PR has develop as target branch, and will be resolved with a squash-merge.
  • This PR has main as target branch, and will be resolved with a merge commit.

First step towards a pip-installable Python interface to Human-GEM, on
raven-toolbox + cobrapy. human_gem.load_model() loads Human-GEM as a fully
annotated cobra model - reading the YAML via raven-toolbox and merging the
cross-references and SBO terms from the annotation tables, which a bare
cobra.io.load_yaml_model does not do:
import human_gem
model = human_gem.load_model() # 12877 rxns, 8460 mets, cross-refs attached
- pyproject.toml (deps: cobra, pandas, raven-toolbox)
- human_gem/io.py load_model(model_dir=None, annotate=True)
- human_gem/annotation.py TSV -> MIRIAM/SBO merge (packaged home of the logic
currently duplicated in code/annotateGEM.py)
Verified locally: load_model() attaches cross-references to 12698/12877
reactions and 8449/8460 metabolites; annotate=False returns the bare model.
Next increments: reduce code/annotateGEM.py to a shim importing from human_gem
(single source of truth) + install the package in CI; then promote the ftINIT
essentiality and task helpers into the package.
@github-actions

github-actionsBot commented Jul 17, 2026

Copy link
Copy Markdown

Model quality report

⚠️6 pre-existing finding(s), no regressions vs develop. Non-blocking.

Each check name links to its explanation in the testResults README.

Model checks

Duplicate keys (model unloadable) and no growth block the merge; every other row is a non-blocking report.

CheckResultΔ vs develop
Duplicate !!omap keys00
Growth (biomass producible)1250
Reactions with no metabolites00
Model / annotation-table inconsistencies00
Removed reactions or metabolites not deprecated00
Metabolites missing formula00
Metabolites missing charge00
Reaction bound / GPR issues00
Exact-duplicate reaction groups00
Unused metabolites00
Unused genes00
Malformed cross-references00
Cross-refs inconsistent across compartments30⚠️

MACAW and mass/charge balance

CheckResultΔ vs develop
Reactions flagged by MACAW dead-end test25100⚠️
Reactions flagged as MACAW duplicates3770⚠️
Mass-imbalanced reactions870⚠️
Charge-imbalanced reactions2340⚠️
Structure vs formula/charge inconsistencies3970⚠️

Model file and metabolic tasks

CheckResult
YAML round-trip (cobrapy)pass
YAML round-trip (RAVEN)pass
YAML lintpass
Essential metabolic tasks57 passed
Verification metabolic tasks21 passed

MEMOTE

Total score: 63.2% (core subset) 0

SectionScoreΔ vs base
consistency42.4%0
annotation_met73.0%0
annotation_rxn72.7%0
annotation_gene46.7%0
annotation_sbo81.7%0
Per-test scores
SectionTestScore
ConsistencyStoichiometric Consistency100.0%
ConsistencyMass Balance0.8%
ConsistencyCharge Balance2.1%
ConsistencyMetabolite Connectivity0.0%
ConsistencyUnbounded Flux In Default Medium100.0%
Annotation - MetabolitesPresence of Metabolite Annotation0.0%
Annotation - MetabolitesMetabolite Annotations Per Database62.3%
Annotation - MetabolitesMetabolite Annotation Conformity Per Database45.8%
Annotation - MetabolitesUniform Metabolite Identifier Namespace0.0%
Annotation - ReactionsPresence of Reaction Annotation0.0%
Annotation - ReactionsReaction Annotations Per Database75.9%
Annotation - ReactionsReaction Annotation Conformity Per Database33.3%
Annotation - ReactionsUniform Reaction Identifier Namespace0.0%
Annotation - GenesPresence of Gene Annotation0.0%
Annotation - GenesGene Annotations Per Database80.0%
Annotation - GenesGene Annotation Conformity Per Database80.0%
Annotation - SBO TermsMetabolite General SBO Presence0.0%
Annotation - SBO TermsMetabolite SBO:0000247 Presence0.1%
Annotation - SBO TermsReaction General SBO Presence0.0%
Annotation - SBO TermsMetabolic Reaction SBO:0000176 Presence0.0%
Annotation - SBO TermsTransport Reaction SBO:0000185 Presence0.7%
Annotation - SBO TermsExchange Reaction SBO:0000627 Presence0.0%
Annotation - SBO TermsDemand Reaction SBO:0000628 Presence100.0%
Annotation - SBO TermsSink Reactions SBO:0000632 Presence100.0%
Annotation - SBO TermsGene General SBO Presence0.0%
Annotation - SBO TermsGene SBO:0000243 Presence0.0%
Annotation - SBO TermsBiomass Reactions SBO:0000629 Presence0.0%

Full suite: 64.2% 0 · from the last/run memote.

The score above is the fast core subset. Comment/run memoteto run the full suite on this pull request; the score updates here when it finishes.

Gene essentiality (Hart 2015)

Not run automatically (it takes hours). Comment/run gene-essentialityto run it on this pull request; the result posts as its own comment.

❌ = a count rose vs the target branch (regression) · ⚠️ = a pre-existing non-zero finding (non-blocking) · ⏳ = still running. Counts link to the CSV listing the exact entries.

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

@edkerkedkerk added this to the 2.1.0 milestone Jul 18, 2026
Sign up for freeto 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

@edkerk