
Gsmm Builder
Build or load a genome-scale metabolic model (GSMM) using COBRApy.
Install
npx skills add aiming-lab/AutoResearchClaw --skill gsmm-builder -g -a claude-code -y- Repository
- aiming-lab/AutoResearchClaw14.8k
- Category
- Engineering
- Updated
- 3mo ago
- License
- MIT
- Context cost
- Lightabout 1,290 tokens
- Runs scripts
- Yes, review before use
What it does
Build or load a genome-scale metabolic model (GSMM) using COBRApy. Covers loading from BIGG, constructing minimal models from scratch, setting medium constraints, and exporting validated .json model files.
Overview
The gsmm-builder skill constructs or loads genome-scale metabolic models
(GSMMs) in the COBRApy framework. It is the entry point for every metabolic
flux analysis pipeline. Output is a validated COBRApy Model object
serialized to a JSON file ready for downstream FBA and flux analysis.
GSMMs encode every known metabolic reaction in an organism as a stoichiometric matrix. Constraints (reaction bounds, medium composition, objective function) turn the model into a solvable linear program.
Workflow
Step 1, Decide: Load Existing or Build from Scratch
Option A: Load a curated BIGG model
import cobra
import cobra.io
# Load E. coli iJO1366 from a local SBML file
model = cobra.io.read_sbml_model("iJO1366.xml")
# Or load from a pre-downloaded JSON file
model = cobra.io.load_json_model("iJO1366.json")
print(f"Loaded {model.id}: {len(model.reactions)} reactions, "
f"{len(model.metabolites)} metabolites, {len(model.genes)} genes")
Key BIGG model IDs:
iJO1366, E. coli K-12 MG1655 (2583 reactions)Recon3D, Homo sapiens (13543 reactions)iMM904, S. cerevisiae (1577 reactions)iNJ661, M. tuberculosis (1049 reactions)
Option B: Build a minimal model from scratch
from cobra import Model, Metabolite, Reaction
model = Model("toy_glycolysis")
# Define metabolites with compartments and formula
glc_e = Metabolite("glc__D_e", formula="C6H12O6", name="D-Glucose",
compartment="e")
glc_c = Metabolite("glc__D_c", formula="C6H12O6", name="D-Glucose",
compartment="c")
atp_c = Metabolite("atp_c", formula="C10H12N5O13P3", name="ATP",
compartment="c")
biomass = Metabolite("biomass", formula="", name="Biomass", compartment="c")
# Build reactions
ex_glc = Reaction("EX_glc__D_e")
ex_glc.lower_bound = -10.0 # uptake (negative = import)
ex_glc.upper_bound = 0.0
ex_glc.add_metabolites({glc_e: 1.0})
