cobrapy
Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.
Author
Category
Development ToolsInstall
Hot:21
Download and extract to your skills directory
Copy command and send to AI Agent for auto-install:
Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-skills-cobrapy&locale=en&source=copy
COBRApy – Python Metabolic Modeling and Flux Analysis
Skill Overview
COBRApy is a Python library for constraint-based reconstruction and analysis (COBRA) of genome-scale metabolic models. It supports loading SBML models, performing FBA/FVA analyses, simulating gene knockouts, and optimizing metabolic engineering designs. It is a core computational tool in systems biology and metabolic engineering research.
Applicable Scenarios
Load and manipulate genome-scale metabolic models (in SBML/JSON/YAML formats), obtain models from local files or remote repositories such as BiGG and BioModels, and inspect model structures and the relationships among metabolites, reactions, and genes.
Perform standard FBA, parsimonious FBA, and geometric FBA optimization to predict bacterial growth rates; conduct flux variability analysis (FVA) to determine reaction flux ranges; and use flux sampling to explore the feasible solution space.
Screen single/double gene or reaction knockouts, evaluate essential genes and metabolic bottlenecks, calculate minimal medium components, generate production envelopes to optimize pathway designs, and perform gap filling to repair infeasible models.
Core Features
Load metabolic models in SBML/JSON/YAML formats from files or remote repositories such as BiGG and BioModels; export models in standard formats for long-term storage or exchange; use built-in textbook models (
textbook/e_coli_core) and gene-level E. coli models such as iJO1366 and iML1515.Optimize objective functions using flux balance analysis (FBA); explore flux bounds within a specified optimality range using flux variability analysis (FVA); study single/double gene or reaction deletions; use geometric FBA and parsimonious FBA to identify central solutions; and perform flux sampling with the OptGP or ACHR methods.
Build custom metabolic networks from scratch using
Model, Reaction, and Metabolite objects; set boundary and exchange reactions; configure gene–protein–reaction (GPR) Boolean logic; use context managers to temporarily modify models and automatically roll back changes; and perform optimization with the GLPK, CPLEX, or Gurobi solvers.Frequently Asked Questions
Which Python versions and solvers does COBRApy require?
COBRApy 0.31.1 requires Python 3.9 or later (Python 3.8 is no longer supported). It uses the GLPK solver by default, which is installed automatically through
swiglpk. CPLEX or Gurobi can optionally be used for large-scale problems. Installation command: uv pip install "cobra==0.31.1".How do I load a model and run an FBA analysis?
Use
from cobra.io import load_model to load a model (the built-in textbook or e_coli_core tutorial models are available locally; remote models require network access), then call solution = model.optimize() to perform FBA. Use solution.objective_value to obtain the optimal objective value, such as the growth rate, and solution.fluxes to access the fluxes of individual reactions.From which sources can metabolic models be obtained?
COBRApy supports three sources: local SBML/JSON/YAML files (using functions such as
read_sbml_model()); built-in textbook models (textbook, iJO1366, and salmonella); and remote model repositories such as BiGG Models and BioModels (load_model("iML1515") requires network access the first time and uses a cache thereafter). SBML is the recommended exchange format.