skillfed

cobra

COBRApy is a package for constraint-based modeling of metabolic networks.

cobra v0.32.1 91.1K downloads/30d#13,535 on PyPI579
Copyleft license LGPL-2.0-or-later OR GPL-2.0-or-later Active released

What it is and what it does

COBRApy is a Python framework for building and analyzing constraint-based models of metabolic networks at genome scale. It provides infrastructure for creating metabolic models, managing reactions and metabolites, and accessing mathematical solvers (CPLEX, Gurobi, GLPK) through the optlang interface. The package implements standard COBRA methods including flux balance analysis (FBA), flux variability analysis (FVA), and gene deletion simulations to predict metabolic behavior and gene essentiality.

The package is designed as both a standalone tool and a foundation for building specialized COBRA-related Python packages. It depends on numpy for numerical computation, pandas for data manipulation, pydantic for model validation, and python-libsbml for reading SBML model files. Solvers are accessed through optlang, with GLPK automatically available via swiglpk. The package targets researchers in systems biology, metabolic engineering, and computational biology who need to model and analyze organism metabolism at scale.

Use it for:

  • Predict metabolic flux distributions and growth rates under different nutrient conditions using flux balance analysis.
  • Identify essential genes by simulating single and multiple gene knockouts to assess impact on growth.
  • Perform flux variability analysis to determine the range of possible reaction rates consistent with optimal growth.
  • Load, modify, and validate genome-scale metabolic models in SBML format for strain design workflows.
  • Build custom analysis pipelines by extending COBRApy classes for domain-specific metabolic research.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

COBRApy is a constraint-based modeling package for genome-scale metabolic network analysis, providing flux balance analysis, flux variability analysis, gene deletion analysis, and access to mathematical solvers.

Yes. COBRApy is production-stable (active maintenance, release 3 days old, 579 GitHub stars) with low install friction and no known vulnerabilities. The dual GPL/LGPL copyleft license requires source disclosure but is standard for academic bioinformatics. Install if you need genome-scale metabolic modeling; the twelve runtime dependencies are justified by the package's scope and are well-maintained.

Install

cobra on PyPI

pip

pip install cobra

uv

uv add cobra

poetry

poetry add cobra

Installing cobra

Before you install

Low install friction with a pure-wheel distribution. Active maintenance with a release 3 days old and recent commits. Twelve runtime dependencies including numpy, pandas, optlang, and swiglpk introduce some complexity, but the package is production-stable.

License in practice

Dual-licensed under LGPL-2.0-or-later or GPL-2.0-or-later (copyleft). You may choose which license to use, but either choice requires source disclosure and derivative work licensing under the same terms.

Quickstart

pip install cobra

import cobra
model = cobra.io.read_sbml_model('model.xml')
solution = model.optimize()

Requires a compatible mathematical solver (CPLEX, Gurobi, or GLPK via swiglpk) to be installed or configured for optimization to work.

Verify before relying

  • Whether all 12 runtime dependencies are required for basic usage or only for specific features (e.g., array support for MATLAB models).
  • Performance characteristics and scalability limits for large genome-scale models.
  • Compatibility with specific solver versions beyond the general optlang interface.

Package facts

License LGPL-2.0-or-later OR GPL-2.0-or-later (copyleft)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 12 — appdirs, depinfo, future, httpx, numpy, optlang, pandas, pydantic, python-libsbml, rich, ruamel.yaml, swiglpk
Maintenance actively maintained — 3 days since the last release
Last repo commit
First released
Downloads 91,149/month — #13,535 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: cobra-0.32.1-py2.py3-none-any.whl

Keywords: metabolism, biology, constraint-based, linear programming, mixed-integer, optimization, flux-balance analysis, reconstruction

Development Status :: 5 - Production/StableIntended Audience :: Science/ResearchLicense :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)Natural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Scientific/Engineering :: Bio-Informatics

Tags

metabolic network modelingflux balance analysisconstraint-based reconstructiongenome-scale metabolismFBA optimizationgene knockout analysismetabolic pathway simulation
systems-biologymetabolic-modelingconstraint-optimization

More Bio-Informatics packages