Skip to content
naulon

No retraction, correction or concern found when last checked on Oct 15, 2026.

COBRApy: COnstraints-Based Reconstruction and Analysis for Python

Ali Ebrahim, Joshua A Lerman, Bernhard O Palsson and 1 more

BMC Systems Biology · 2013

doi:10.1186/1752-0509-7-74

Abstract

Background. COnstraint-Based Reconstruction and Analysis (COBRA) methods are widely used for genome-scale modeling of metabolic networks in both prokaryotes and eukaryotes. Due to the successes with metabolism, there is an increasing effort to apply COBRA methods to reconstruct and analyze integrated models of cellular processes. The COBRA Toolbox for MATLAB is a leading software package for genome-scale analysis of metabolism; however, it was not designed to elegantly capture the complexity inherent in integrated biological networks and lacks an integration framework for the multiomics data used in systems biology. The openCOBRA Project is a community effort to promote constraints-based research through the distribution of freely available software.

Results. Here, we describe COBRA for Python (COBRApy), a Python package that provides support for basic COBRA methods. COBRApy is designed in an object-oriented fashion that facilitates the representation of the complex biological processes of metabolism and gene expression. COBRApy does not require MATLAB to function; however, it includes an interface to the COBRA Toolbox for MATLAB to facilitate use of legacy codes. For improved performance, COBRApy includes parallel processing support for computationally intensive processes.

Conclusion. COBRApy is an object-oriented framework designed to meet the computational challenges associated with the next generation of stoichiometric constraint-based models and high-density omics data sets.

Availability. http://opencobra.sourceforge.net/

Full text

From PubMed Central, U.S. National Library of Medicine, as current on Oct 16, 2026. Paragraph numbers are ours, so an answer can point at one.

Background

Constraint based modeling approaches have been widely applied in the field of microbial metabolic engineering and have been employed in the analysis and, to a lesser extent, modeling of transcriptional and signaling networks. And, we’ve recently developed a method for integrated modeling of gene expression and metabolism on the genome scale.

The popularity of these approaches is due, in part, to the fact that they facilitate analysis of biological systems in the absence of a comprehensive set of parameters. Constraints-based approaches focus on employing data-driven physicochemical and biological constraints to enumerate the set of feasible phenotypic states of a reconstructed biological network in a given condition. These constraints include compartmentalization, mass conservation, molecular crowding, thermodynamic directionality, and transcription factor activity. More recently, transcriptome data have been used to reduce the size of the set of computed feasible states. Because constraints-based models are often underdetermined they may provide multiple mathematically-equivalent solutions to a specific question – these equivalent solutions must be assessed with experimental data for biological relevance.

We have previously published the COBRA Toolbox for MATLAB to provide systems biology researchers with a high-level interface to a variety of methods for constraint-based modeling of genome-scale stoichiometric models of cellular biochemistry. The COBRA Toolbox is being increasingly recognized as a standard framework for constraint-based modeling of metabolism. While the COBRA Toolbox has gained widespread use and become a powerful piece of software, it was not designed to cope with modeling complex biological processes outside of metabolism or for integrated analyses of omics data, and requires proprietary software to function. To drive COBRA research through this avalanche of omics and model increasingly complex biological processes, we have developed an object-oriented implementation of core COBRA Toolbox functions using the Python programming language. COBRA for Python (COBRApy) provides access to commonly used COBRA methods in a MATLAB-free fashion.

Implementation

The core capabilities of COBRApy are enabled by a set of classes (Figure 1) that represent organisms (Model), biochemical reactions (Reaction), and biomolecules (Metabolite and Gene). The core code is accessible through either Python or Jython (Python for Java). COBRApy contains: (1) cobra.io: an input/output package for reading / writing SBML models and reading / writing COBRA Toolbox MATLAB structures. (2) cobra.flux_analysis: a package for performing common FBA operations, including gene deletion and flux variability analysis. (3) cobra.topology: a package for performing structural analysis – the current version contains the reporter metabolites algorithm of Patil & Nielsen. (4) cobra.test: a suite of unit tests and test data. (5) cobra.solvers: interfaces to linear optimization packages. And, (6) cobra.mlab: an interface to the COBRA Toolbox for MATLAB.

Results and discussion

COBRApy is a software package for constraints-based modeling that is designed to accommodate the increasing complexity of biological processes represented with COBRA methods. Like the COBRA Toolbox, COBRApy provides core COBRA modeling capabilities in an extendible and accessible fashion. However, COBRApy employs an object oriented programming approach that is more amenable to representing increasingly complex models of biological networks. Moreover, COBRApy inherits numerous benefits from the Python language, and allows the integration of models with databases and other sources of high-throughput data. Additionally, COBRApy does not require commercial software for commonly used COBRA operations whereas the COBRA Toolbox depends on MATLAB. As the COBRA Toolbox is in wide use, it will likely be used as a development and analysis platform for years to come. To take advantage of legacy and future modules written for the COBRA Toolbox, COBRApy includes a module for directly interacting with the COBRA Toolbox (cobra.mlab) and support for reading and writing COBRA Toolbox MATLAB structures (cobra.io.mat).

In recent years, a number of software packages have been developed that employ stoichiometric constraint-based modeling approaches, such as Cell Net Analyzer, FASIMU, PySCeS-CBM, the Raven Toolbox, and the Systems Biology Research Tool. While there is overlap in functionality between some of packages and COBRApy (Table 1), the other packages do not currently support the next generation models of metabolism and expression (ME-Models) nor integration with the COBRA Toolbox for MATLAB. It is worth noting that the other software packages often contain a rich variety of functionality that is targeted towards other research topics, such as modeling signaling networks. COBRApy continues the COBRA Toolbox’s tradition of providing an interactive / programmable framework for constraints-based modeling and is a new initiative of The openCOBRA Project. Software downloads, tutorials, forums, and detailed documentation are available at http://opencobra.sourceforge.net.

Core classes: model, metabolite, reaction, & gene

The core classes of COBRApy are Model, Metabolite, Reaction, and Gene. The Model class serves as a container for a set of chemical Reactions, including associated Metabolites and Gene products (Figure 2a). Within a Model, Metabolites are modified by one or more Reactions that may be spontaneous or catalyzed by one or more Genes (Figure 2b). The underlying genetic requirements for a Reaction to be active in a Model are supplied as a Boolean relationship, where each gene is referred to by a unique identifier. During the construction of a Model, the Model and the Reactions, Metabolites, and Genes are explicitly aware of each other. For example, given a Metabolite, it is possible to use the get_reaction method to determine in which Reactions this Metabolite participates. Then the genes associated with these Reactions may be accessed by the Reaction.get_gene method.

The object-based design of COBRApy provides the user with the ability to directly access attributes for each object (Figure 1), whereas with the COBRA Toolbox for MATLAB biological entities and their attributes are each contained within separate lists. For example, with COBRApy, a Metabolite object provides information about its chemical Formula and associated biochemical Reactions, whereas, with the COBRA Toolbox for MATLAB, one must query multiple tables to access these values and modify multiple tables to update these values.

Key capabilities

COBRApy comes with variants of the published metabolic network models (M-Models) for Salmonella enterica Typhimurium LT2 and Escherichia coli K-12 MG1655. These models can be loaded with the cobra.test.create_test_model function; with S. Typhimurium LT2 being the default model. Additionally, COBRApy can read SBML-formatted models downloaded from a variety of sources, such as the Model SEED and the BioModels database.

A common operation performed with M-Models is to optimize for the maximum flux through a specific reaction in a defined growth medium. The S. Typhimurium LT2 model comes with a variety of media whose compositions are specified in the model’s media_compositions attribute. Here, we initialize the Model’s boundary conditions to mimic the minimal MgM medium and then perform a linear optimization to calculate the maximal flux through the Reaction biomass_iRR1083_metals. Biomass_iRR1083_metals is a reaction that approximates the materials required to support S. Typhimurium LT2 growth in a minimal medium where approximately 0.3 grams dry weight S. Typhimurium LT2 are produced per hour. It is important to note that cellular composition can vary as a function of growth rate, therefore, for biological accuracy it may be necessary to construct a new biomass reaction if the simulated, or experimentally-observed, growth rate is substantially different.

Flux balance analysis of M-Models has enjoyed substantial success in qualitative analyses of gene essentiality. These studies used simulations to identify which genes or synthetic lethal gene-pairs are essential for biomass production in a given condition. The lists of essential genes and synthetic lethal gene-pairs may then be targeted to inhibit microbial growth or excluded from manipulation when constructing designer strains. COBRApy provides functions for automating single and double gene deletion studies in the cobra.flux_analysis module.

Because of the presence of equivalent alternative optima in constraint based-simulations of metabolism, many reactions may theoretically be able to carry a wide range of flux for a given simulation objective. Flux variability analysis (FVA) is often used to calculate the amount of flux a reaction can carry while still simulating the maximum flux through the objective function subject to a specified tolerance. Flux variability analyses can be used to identify problems in model structure or ‘pinch-points’ in a metabolic network. COBRApy provides automated functions for FVA in the cobra.flux_analysis.variability module.

Advanced capabilities

Because whole genome double deletion and FVA simulations can be time intensive with a single CPU, we have provided a function that uses Parallel Python to split the simulation across multiple CPUs for multicore machines. Additionally, there are a wide range of legacy operations that are present in the COBRA Toolbox that can be accessed using mlabwrap. MATLAB is only necessary for accessing codes written in the COBRA Toolbox for MATLAB; it is not necessary to run the majority of COBRApy functions.

Conclusions

COBRApy is a constraint-based modeling package that is designed to accommodate the biological complexity of the next generation of COBRA models and provides access to commonly used COBRA methods, such as flux balance analysis, flux variability analysis, and gene deletion analyses. Through the mlabwrap module it is possible to use COBRApy to call many additional COBRA methods present in the COBRA Toolbox for MATLAB. As part of The openCOBRA Project, COBRApy serves as an enabling framework for which the community can develop and contribute application specific modules.

Availability and requirements

Project name: COBRApy version 0.2.1

Project home page:http://opencobra.sourceforge.net

Operating systems: Platform independent, including Java

Programming language: Python (≥2.6) / Jython (≥2.5)

Other requirements:

Python: libSBML ≥ 5.5.0. Currently supported linear programming solvers: GLPK through PyGLPK 0.3, IBM ILOG/CPLEX Optimization Studio ≥ 12.4 (IBM Corporation, Armonk, New York), and Gurobi ≥ 5.0 (Gurobi Optimization, Inc., Houston, TX, USA).

• [Optional] Numpy ≥ 1.6.1 & Scipy ≥ 0.10.1 for ArrayBasedModel, MoMA, and double_deletion analysis.

• [Optional] Parallel python for parallel processing.

• [Optional] To directly interface with the COBRA Toolbox for MATLAB it is necessary to install mlabwrap, the COBRA Toolbox, and a version of MATLAB (Mathworks, Natick, Massachusetts, U.S.A.) that is compatible with the COBRA Toolbox.

Jython: JSBML ≥ 0.8.

•Currently supported linear programming solvers: GLPK for Java 1.0.22, IBM ILOG/CPLEX Optimization Studio ≥ 12.4, and Gurobi ≥ 5.0.

•The COBRA Toolbox for MATLAB and ArrayBasedModel are not currently accessible from Jython.

License: GNU GPL version 3 or later.

Abbreviations

COBRA: COnstraint-Based Reconstruction and Analysis; FBA: Flux balance analysis; FVA: Flux variability analysis; M-Model: Metabolic network model.

Competing interests

This software was used by DRH, JAL, and BOP to develop the method that is the subject of a provisional patent application U.S. Provisional Application Serial No. 61/644,924 filed on May 9, 2012 entitled “Method for in silico modeling of gene product expression and metabolism”.

Authors’ contributions

DRH conceived COBRA for Python. AE, JAL, and DRH contributed to various aspects of development and testing. All authors read and approved the final manuscript.

References 48

  1. 1.

    Feist AM Palsson BO The growing scope of applications of genome-scale metabolic reconstructions using Escherichia coliNat Biotechnol2008 26659667

    Not in our library10.1038/nbt1401

  2. 2.

    Kim IK Roldao A Siewers V Nielsen J A systems-level approach for metabolic engineering of yeast cell factoriesFEMS Yeast Res2012 12228248

    Not in our library10.1111/j.1567-1364.2011.00779.x

  3. 3.

    Liao JC Boscolo R Yang YL Tran LM Sabatti C Roychowdhury VP Network component analysis: reconstruction of regulatory signals in biological systemsProc Natl Acad Sci USA2003 1001552215527

    Not in our library10.1073/pnas.2136632100

  4. 4.

    Hyduke DR Jarboe LR Tran LM Chou KJ Liao JC Integrated network analysis identifies nitric oxide response networks and dihydroxyacid dehydratase as a crucial target in Escherichia coliProc Natl Acad Sci USA2007 10484848489

    Not in our library10.1073/pnas.0610888104

  5. 5.
  6. 6.

    Covert MW Palsson BO Transcriptional regulation in constraints-based metabolic models of Escherichia coliJ Biol Chem2002 2772805828064

    Not in our library10.1074/jbc.m201691200

  7. 7.

    Gianchandani EP Joyce AR Palsson BO Papin JA Functional states of the genome-scale Escherichia coli transcriptional regulatory systemPLoS Comput Biol2009 5e1000403

    Not in our library10.1371/journal.pcbi.1000403

  8. 8.
  9. 9.

    Hyduke DR Palsson BO Towards genome-scale signalling-network reconstructionsNat Rev Genet2010 11297307

    Not in our library10.1038/nrg2750

  10. 10.

    Lerman JA Hyduke DR Latif H Portnoy VA Lewis NE Orth JD Schrimpe-Rutledge AC Smith RD Adkins JN Zengler K Palsson BO In silico method for modelling metabolism and gene product expression at genome scaleNat Commun2012 3929

    Not in our library10.1038/ncomms1928

  11. 11.

    Vazquez A Beg QK Demenezes MA Ernst J Bar-Joseph Z Barabasi AL Barabasi AL Boros LG Oltvai ZN Impact of the solvent capacity constraint on E. coli metabolismBMC Syst Biol2008 27

    Not in our library10.1186/1752-0509-2-7

  12. 12.

    Henry CS Broadbelt LJ Hatzimanikatis V Thermodynamics-based metabolic flux analysisBiophys J2007 9217921805

    Not in our library10.1529/biophysj.106.093138

  13. 13.

    Gama-Castro S Jimenez-Jacinto V Peralta-Gil M Santos-Zavaleta A Penaloza-Spinola MI Contreras-Moreira B Segura-Salazar J Muniz-Rascado L Martinez-Flores I Salgado H Bonavides-Martinez C Abreu-Goodger C Rodriguez-Penagos C Miranda-Rios J Morett E Merino E Huerta AM Trevino-Quintanilla L Collado-Vides J RegulonDB (version 6.0): gene regulation model of Escherichia coli K-12 beyond transcription, active (experimental) annotated promoters and Textpresso navigationNucleic Acids Res2008 36D120D124

    Not in our library10.1093/nar/gkn491

  14. 14.
  15. 15.

    Frezza C Zheng L Folger O Rajagopalan KN MacKenzie ED Jerby L Micaroni M Chaneton B Adam J Hedley A Kalna G Tomlinson IP Pollard PJ Watson DG Deberardinis RJ Shlomi T Ruppin E Gottlieb E Haem oxygenase is synthetically lethal with the tumour suppressor fumarate hydrataseNature2011 477225228

    Not in our library10.1038/nature10363

  16. 16.

    Bordbar A Mo ML Nakayasu ES Schrimpe-Rutledge AC Kim YM Metz TO Jones MB Frank BC Smith RD Peterson SN Hyduke DR Adkins JN Palsson BO Model-driven multi-omic data analysis elucidates metabolic immunomodulators of macrophage activationMol Syst Biol2012 8558

    Not in our library10.1038/msb.2012.21

  17. 17.

    Hyduke DR Lewis NE Palsson BO Analysis of omics data with genome-scale models of metabolismMol Biosyst2013 9167174

    Not in our library10.1039/c2mb25453k

  18. 18.

    Mahadevan R Schilling CH The effects of alternate optimal solutions in constraint-based genome-scale metabolic modelsMetab Eng2003 5264276

    Not in our library10.1016/j.ymben.2003.09.002

  19. 19.

    Schellenberger J Que R Fleming RM Thiele I Orth JD Feist AM Zielinski DC Bordbar A Lewis NE Rahmanian S Kang J Hyduke DR Palsson BO Quantitative prediction of cellular metabolism with constraint-based models: the COBRA toolbox v2.0Nat Protoc2011 612901307

    Not in our library10.1038/nprot.2011.308

  20. 20.

    Medema MH van Raaphorst R Takano E Breitling R Computational tools for the synthetic design of biochemical pathwaysNat Rev Microbiol2012 10191202

    Not in our library10.1038/nrmicro2717

  21. 21.

    Hucka M Finney A Bornstein BJ Keating SM Shapiro BE Matthews J Kovitz BL Schilstra MJ Funahashi A Doyle JC Kitano H Evolving a lingua franca and associated software infrastructure for computational systems biology: the Systems Biology Markup Language (SBML) projectSyst Biol (Stevenage)2004 14153

    Not in our library10.1049/sb:20045008

  22. 22.

    Patil KR Nielsen J Uncovering transcriptional regulation of metabolism by using metabolic network topologyProc Natl Acad Sci USA2005 10226852689

    Not in our library10.1073/pnas.0406811102

  23. 23.

    Lakshmanan M Koh G Chung BK Lee DY Software applications for flux balance analysisBrief Bioinform2012

    Not in our library10.1093/bib/bbs069

  24. 24.

    Klamt S von Kamp A An application programming interface for Cell NetAnalyzerBiosystems2011 105162168

    Not in our library10.1016/j.biosystems.2011.02.002

  25. 25.

    Hoppe A Hoffmann S Gerasch A Gille C Holzhutter HG FASIMU: flexible software for flux-balance computation series in large metabolic networksBMC Bioinforma2011 1228

    Not in our library10.1186/1471-2105-12-28

  26. 26.

    Olivier BG Rohwer JM Hofmeyr JH Modelling cellular systems with PySCeSBioinformatics2005 21560561

    Not in our library10.1093/bioinformatics/bti046

  27. 27.
  28. 28.

    Wright J Wagner A The systems biology research tool: evolvable open-source softwareBMC Syst Biol2008 255

    Not in our library10.1186/1752-0509-2-55

  29. 29.

    The openCOBRA Projecthttp://opencobra.sourceforge.net

    Not in our library

  30. 30.
  31. 31.

    Orth JD Conrad TM Na J Lerman JA Nam H Feist AM Palsson BO A comprehensive genome-scale reconstruction of Escherichia coli metabolism–2011Mol Syst Biol2011 7535

    Not in our library10.1038/msb.2011.65

  32. 32.

    Bornstein BJ Keating SM Jouraku A Hucka M LibSBML: an API library for SBMLBioinformatics2008 24880881

    Not in our library10.1093/bioinformatics/btn051

  33. 33.

    Henry CS Dejongh M Best AA Frybarger PM Linsay B Stevens RL High-throughput generation, optimization and analysis of genome-scale metabolic modelsNat Biotechnol2010 28977982

    Not in our library10.1038/nbt.1672

  34. 34.
  35. 35.

    Orth JD Thiele I Palsson BO What is flux balance analysis?Nat Biotechnol2010 28245248

    Not in our library10.1038/nbt.1614

  36. 36.

    Beuzon CR Banks G Deiwick J Hensel M Holden DW pH-dependent secretion of SseB, a product of the SPI-2 type III secretion system of Salmonella typhimuriumMol Microbiol1999 33806816

    Not in our library10.1046/j.1365-2958.1999.01527.x

  37. 37.

    Schaechter M Maaloe O Kjeldgaard NO Dependency on medium and temperature of cell size and chemical composition during balanced grown of Salmonella typhimuriumJ Gen Microbiol1958 19592606

    Not in our library10.1099/00221287-19-3-592

  38. 38.

    Pramanik J Keasling JD Stoichiometric model of Escherichia coli metabolism: incorporation of growth-rate dependent biomass composition and mechanistic energy requirementsBiotechnol Bioeng1997 56398421

    Not in our library10.1002/(sici)1097-0290(19971120)56:4<398::aid-bit6>3.0.co;2-j

  39. 39.

    Burgard AP Pharkya P Maranas CD Optknock: a bilevel programming framework for identifying gene knockout strategies for microbial strain optimizationBiotechnol Bioeng2003 84647657

    Not in our library10.1002/bit.10803

  40. 40.

    Schellenberger J Lewis NE Palsson BO Elimination of thermodynamically infeasible loops in steady-state metabolic modelsBiophys J2011 100544553

    Not in our library10.1016/j.bpj.2010.12.3707

  41. 41.

    Parallel Pythonhttp://parallelpython.com

    Not in our library

  42. 42.

    mlabwraphttp://mlabwrap.sourceforge.net

    Not in our library

  43. 43.

    Lewis NE Nagarajan H Palsson BO Constraining the metabolic genotype-phenotype relationship using a phylogeny of in silico methodsNat Rev Microbiol2012 10291305

    Not in our library10.1038/nrmicro2737

  44. 44.

    GLPKhttp://www.gnu.org/software/glpk

    Not in our library

  45. 45.

    PyGLPK (not python-glpk)http://www.tfinley.net/software/pyglpk

    Not in our library

  46. 46.

    SciPy / NumPyhttp://scipy.org

    Not in our library

  47. 47.

    Drager A Rodriguez N Dumousseau M Dorr A Wrzodek C Le Novere N Zell A Hucka M JSBML: a flexible Java library for working with SBMLBioinformatics2011 2721672168

    Not in our library10.1093/bioinformatics/btr361

  48. 48.

    GLPK for Javahttp://glpk-java.sourceforge.net

    Not in our library

Cited by papers we hold 25

and 5 more

Reads

Read by people on this page

None yet.

Checked or read by AI through naulon

None yet.

A person counts once a day per paper. We keep no cookie and no address: a reader is a hash that changes every day. Any month under five reads shows no number.

Are you an author?

Is this your paper?

Claim it to add your note and be paid when agents cite it. Free.