# Cobrapy

Performs constraint-based metabolic modeling with COBRApy, including FBA, pFBA, FVA...

- Repository: https://github.com/K-Dense-AI/scientific-agent-skills (55651 stars)
- Category: Marketing
- License: GPL-2.0 license
- Last updated: 2026-10-26
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add K-Dense-AI/scientific-agent-skills --skill cobrapy -g -a claude-code -y`
Codex: `npx skills add K-Dense-AI/scientific-agent-skills --skill cobrapy -g -a codex -y`
Cursor: `npx skills add K-Dense-AI/scientific-agent-skills --skill cobrapy -g -a cursor -y`
Gemini CLI: `npx skills add K-Dense-AI/scientific-agent-skills --skill cobrapy -g -a gemini-cli -y`

## Description

Performs constraint-based metabolic modeling with COBRApy, including FBA, pFBA, FVA, gene knockouts, flux sampling, growth media, production envelopes, gap filling, and SBML model validation for systems biology and metabolic engineering.

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

# COBRApy - Constraint-Based Reconstruction and Analysis

## When to use

Use for loading/building metabolic networks, optimizing their steady-state fluxes,
knockout screens, medium design, feasible-space sampling, and gap-filling hypotheses.
FBA is a constraint-based prediction; it does not infer kinetic rates or establish
experimental growth, thermodynamic feasibility, or flux identifiability.

## Setup and reproducibility

Targets **cobra 0.32.1** (import `cobra`), checked against its released source and
[current documentation](https://cobrapy.readthedocs.io/en/latest/).

```bash
uv pip install "cobra==0.32.1"
# Optional SciPy support for MATLAB I/O and array operations:
uv pip install "cobra[array]==0.32.1"
```

Plotting examples additionally require matplotlib, pandas, and seaborn. The
`cobra[chrr]` extra supplies hopsy for the new CHRR sampler; that optional backend
was documentation-reviewed, not executed in this refresh. In 0.32.1, `sample()`
defaults to `method="auto"` (CHRR when hopsy is installed, otherwise OptGP).
Choose the method explicitly to avoid environment-dependent changes.

Record model source/version/checksum, cobra and solver versions, objective,
medium, bounds, tolerances, and any random seed with each analysis. GLPK handles
the examples below; inspect `cobra.util.solver.solvers` before choosing an
optional solver. Use `"hybrid"` for its HiGHS/OSQP interface when installed;
the legacy `"osqp"` alias is deprecated. QP methods require a suitable backend.
Start with `processes=1`; scripts using multiprocessing need a guarded entry point.

## Workflow

### 1. Load, inspect, and validate a model

```python
from cobra.io import load_model

The rest: https://github.com/K-Dense-AI/scientific-agent-skills/blob/HEAD/skills/cobrapy/SKILL.md
