Repository navigation
Conversation
The builder refactor (f2de5f2) renamed the old build() to build_base_model() and added a new build(model_or_id, gapfill_media, ...) that runs ATP correction and gapfilling and returns a tuple. build_metabolic_model kept calling build() with the old positional arguments, so index went in as gapfill_media, allow_all_non_grp_reactions as index, and so on; the call fails (e.g. compartment ids like "cFalse", then a TypeError in build_biomass). Call build_base_model with the same arguments, which is what this function did before the refactor; gapfill_model then gapfills as before. Test: build_metabolic_model passes its arguments to build_base_model and returns the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters in our workflow
MSBuilder.build_metabolic_modelcannot build any model on dev. The example notebookexamples/Model Reconstruction/build_metabolic_model.ipynband the API docs (docs/source/core/msbuilder_api.rst)both use it. We call
build()andbuild_base_modeldirectly, so our own builds are not affected. We found thiswhile reviewing dev's builder.
What happens
The builder refactor (f2de5f2, Sep 2025) renamed the old
build(model_or_id, index, allow_all_non_grp_reactions, annotate_with_rast, biomass_classic, biomass_gc, ...)tobuild_base_model. It added a newbuild(model_or_id, gapfill_media, index, ...), which runs ATP correction andgap-fill and returns a 4-tuple.
build_metabolic_modelstill calls
build()with the old positional arguments:So every argument lands one slot off:
indexgoes in asgapfill_media,allow_all_non_grp_reactionsasindex,and so on. The base model then gets compartment index
False(reactions named likerxn05294_cFalse), andbuild_biomassraisesTypeError: can only concatenate str (not "bool") to str. If that step passed,build()wouldrun ATP correction and gap-fill with
"0"as the medium and return a tuple, whichbuild_metabolic_modelwould thenpass to
gapfill_modelas a model.How to reproduce
The reproduction is a three-gene genome built on the public GramNeg template (ModelSEEDTemplates v7.0):
dev:
On this branch, the call returns a model with 48 reactions.
The fix
The fix calls
build_base_modelwith the same arguments. They are already inbuild_base_model's order, which is thepre-refactor
build()signature, so this restores the behaviour from before f2de5f2.gapfill_modelthen gap-fillsas before.
Not changed here:
build_from_annotaton_ontology. It has the same staleself.build(...)call(L791),
but fixing that call alone would not make it work. Right after it:
rxn.genes(), but cobra'sReaction.genesis a frozenset, so this raisesTypeError: 'frozenset' object is not callable;anno_ont.get_feature(...), butAnnotationOntologyhas no such method;gene_term_hashwith cobra genes, but the keys are annotation-ontology features.That needs its own change and a decision on how the function should work.
No package code calls
build_metabolic_model. The example notebook calls it with keywords, and they work after the fix.Tests
tests/core/test_msbuilder.py::test_build_metabolic_model_builds_base_modelmonkeypatchesbuild_base_modeltorecord its arguments. It checks that
build_metabolic_modelpasses(model_id, index, allow_all_non_grp_reactions, annotate_with_rast, classic_biomass)and returns the model.Against dev's code, the stub's empty model reaches
add_atpminsidebuild():With the fix, it passes. Full suite (Python 3.10, cobra 0.32.1, CPLEX 22.1.1):
tests/coregoes from 56 to 57passed, and
tests/from 58 to 59.black22.8.0 and the other pre-commit hooks pass.Real-model check
We ran this on a genome-scale E. coli K-12 genome (RAST annotations, GramNeg template v7.1):
gapfill_model=False, the result (1,828 reactions) is identical tobuild_base_model("Keio", "0", False, False, False)in reaction ids, bounds, GPRs and equations.gapfill_model=Trueon minimal glucose, dev raises the sameTypeError. This branch returns1,834 reactions, and the model grows on glucose (0.7685). That growth comes from
gapfill_model's simple gap-fill,without ATP tests, as before the refactor.
Related
build_metabolic_model; thebuild_from_annotaton_ontologypart stays open.🤖 Generated with Claude Code