# Gsmm Validator

Validate a COBRApy genome-scale metabolic model for mass/charge balance, stoichiometric...

- Repository: https://github.com/aiming-lab/AutoResearchClaw (14798 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-08-19
- Runs scripts: no, instructions only

## Install

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

## Description

Validate a COBRApy genome-scale metabolic model for mass/charge balance, stoichiometric consistency, biomass producibility, dead-end metabolites, thermodynamic loops, and GPR rule formatting. Outputs a structured validation report with errors and warnings.

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

## Overview

The `gsmm-validator` skill performs rigorous quality control on a COBRApy
`Model` before it enters any flux analysis pipeline. An invalid model
silently produces biologically meaningless fluxes; validation catches
structural errors early.

Validation covers six categories: (1) mass/charge balance, (2) feasibility
and biomass production, (3) dead-end metabolites, (4) stoichiometric
consistency, (5) thermodynamic loop detection, and (6) GPR rule integrity.

---

## Workflow

### Step 1, Load the Model

```python
import cobra
import cobra.io

model = cobra.io.load_json_model("my_model.json")
print(f"Loaded: {model.id} ({len(model.reactions)} reactions)")
```

### Step 2, Mass and Charge Balance Check

Unbalanced reactions are among the most common modelling errors. COBRApy
computes elemental balance per reaction.

```python
errors = []
warnings = []

print("=== Mass/Charge Balance ===")
for rxn in model.reactions:
    # Returns dict like {"C": -1, "H": 2} if imbalanced; empty dict if OK
    imbalance = rxn.check_mass_balance()
    if imbalance:
        # Exchange and demand reactions are expected to be imbalanced
        if rxn.id.startswith(("EX_", "DM_", "SK_", "BIOMASS")):
            warnings.append(f"WARN  [{rxn.id}] boundary reaction imbalanced "
                            f"(expected): {imbalance}")
        else:
            errors.append(f"ERROR [{rxn.id}] mass/charge imbalance: "
                          f"{imbalance}")

for msg in errors + warnings:
    print(msg)
print(f"  {len(errors)} error(s), {len(warnings)} warning(s)")
```

### Step 3, Biomass Producibility (FBA Feasibility)

```python
print("\n=== Biomass Producibility ===")
solution = model.optimize()

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