# Gsmm Builder

Build or load a genome-scale metabolic model (GSMM) using COBRApy.

- Repository: https://github.com/aiming-lab/AutoResearchClaw (14798 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-08-19
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add aiming-lab/AutoResearchClaw --skill gsmm-builder -g -a claude-code -y`
Codex: `npx skills add aiming-lab/AutoResearchClaw --skill gsmm-builder -g -a codex -y`
Cursor: `npx skills add aiming-lab/AutoResearchClaw --skill gsmm-builder -g -a cursor -y`
Gemini CLI: `npx skills add aiming-lab/AutoResearchClaw --skill gsmm-builder -g -a gemini-cli -y`

## Description

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.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

## 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**

```python
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**

```python
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})

The rest: https://github.com/aiming-lab/AutoResearchClaw/blob/HEAD/external/agents/Biology-Agent/skills/gsmm-builder/SKILL.md
