User:Jarle Pahr/CobraPy

From OpenWetWare
Jump to navigationJump to search

Notes on the Python version of OpenCOBRA:

https://groups.google.com/forum/#!forum/cobra-pie

http://sourceforge.net/projects/opencobra/files/python/cobra/0.2.1/

Documentation: http://cobrapy.readthedocs.org/en/latest/

https://media.readthedocs.org/pdf/cobrapy/latest/cobrapy.pdf

CobraPy @ Github: https://github.com/opencobra/cobrapy

https://github.com/opencobra/cobrapy/releases

Implemented features

Flux analysis package:

  • Double deletion
  • MOMA
  • Essentiality (assess_medium_component_essentiality)
  • Objective (assess objective, update objective)
  • Single deletion
  • Variability (find blocked reactions, FVA)
  • I/O: Load Matlab model, save matlab model.
  • SBML: Create Cobra model from SBML, write Cobra model to SBML
  • Manipulate: Prune unused metabolites, prune unused reactions.
  • Modify: Initalize growth medium
  • mlab:
  • Solvers: cplex, glpk, gurobi.
  • Stats

MATLAB Cobra Toolbox Features

Cobra

  • MOMA
  • OMNI
  • Detect dead ends (metabolites which either participate in only one reaction or can only be produced or consumed)
  • Double robustness analysis
  • Dynamic FBA
  • Extract subnetwork
  • Find synthetic lethals
  • Find metabolic junctions
  • Find neighbor reactions
  • FVA
  • Geometric FBA
  • Linear MOMA
  • Optimize two models (minimize difference between flux vectors)
  • PhenotypePhasePlanes
  • Random objective FBA solution
  • Robustness analysis
  • Gap filling

Cobra/Design

  • Genetic Design Through Local Search
  • OptKnock
  • OptGene
  • Random KO
  • Simple OptKnock

Fluxomics

Gap-filling

  • Find orphan reactions
  • GapFind

I/O

  • Output Cytoscape network

Reconstruction

  • Add sink reactions
  • Check biomass precursor synthesis

CobraPy Missing features

Cobra Toolbox documentation for reference: http://opencobra.sourceforge.net/openCOBRA/opencobra_documentation/cobra_toolbox_2/index.html


  • OptKnock?
  • Fluxomics?
  • rFBA?

addRatioReaction? http://opencobra.sourceforge.net/openCOBRA/opencobra_documentation/cobra_toolbox_2/cobra/reconstruction/addRatioReaction.html

Basic commands

Import model create and write routines:

from cobra.io.sbml import create_cobra_model_from_sbml_file
from cobra.io.sbml import write_cobra_model_to_sbml_file

Tests:

from cobra.test import test_all
test_all()

Import sbml routines:

from cobra.io.sbml import create_cobra_model_from_sbml_file
from cobra.io.sbml import write_cobra_model_to_sbml_file

Create cobra model from SBML file:

cobra_model = create_cobra_model_from_sbml_file(sbml_file, print_time = True)

Save Cobra model as SBML file:

write_cobra_model_to_sbml_file(cobra_model, sbml_out_file, sbml_level, sbml_version, print_time = True)

Run optimization:

cobra_model.optimize(solver="gurobi")

Display result:

print '\nSimulated growth rate is %1.3f' % cobra_model.solution.f


Set growth medium:

from cobra.manipulation import initialize_growth_medium
initialize_growth_medium(cobra_model, 'LB')


Test effect of gene deletion on growth rates:

from cobra.flux_analysis import single_deletion
from cPickle import load
from time import time
from cobra.test import salmonella_pickle #This is the name of the test file
with open(salmonella_pickle) as in_file:
   cobra_model = load(in_file)
target_genes =  ['STM4081', 'STM0247', 'STM3867', 'STM2952']
rates, statuses, problems = single_deletion(cobra_model, target_genes)

Change objective function:

new_objective = cobra_model.reactions.get_by_id('3OAS140')
cobra_model.optimize(new_objective)


Add a reaction:

from cobra import Reaction
reaction = Reaction('My_reaction')
reaction.name = 'Testreaction'
reaction.subsystem = 'Central carbon metabolism'
reaction.lower_bound = 0. 
reaction.upper_bound = 1000.
reaction.reversibility = 0
reaction.objective_coefficient =0.

Creating metabolite:

from cobra import Metabolite
ACP_c = Metabolite('ACP_c', formula = 'C11H21N2O9PRS',name='acyl-carrier-protein', compartment='c')

Add metabolites to reaction:

reaction.add_metabolites({malACP_c: -1.0,h_c: -1.0}

Display reaction formula:

print reaction.reaction

Subpackages

See http://cobrapy.readthedocs.org/en/latest/cobra.html#

Core package

Metabolite module:

  • get_model()
  • get_reactions()
  • remove_from_model()


Model module:

  • add_metabolites(metabolite_list) #Adds metabolites to the model and expands the stoichiometric matrix.
  • add_reaction(reaction)
  • add_reactions(reaction_list)


Reaction module:

add_gene_reaction_rule(the_rule)

Adds a boolean gene requirement rule. See Schellenberger et al 2011 Nature Protocols 6(9):1290-307.

add_metabolites(the_metabolites, combine=True, add_to_container_model=True)

  • the_metabolites: dict of metabolites and stoichiometric coefficients
  • combine: If the metabolite already exists in the reaction, and combine = True, coefficients will be added together. If False, the old value is discarded.
  • add_to_container: If true and the reaction exists within a model object, the metabolite is added to the model.
get_products()
get_reactants()


optimize:

optimize(new_objective=None, objective_sense='maximize', the_problem=None, solver='glpk', error_reporting=None, quadratic_component=None, tolerance_optimality=1e-06, tolerance_feasibility=1e-06, tolerance_barrier=1e-10, **kwargs)


Flux analysis package

io package

manipulation package

Bibliography

Ebrahim A, Lerman JA, Palsson BO, Hyduke DR✝. COBRApy: COnstraints-Based Reconstruction and Analysis for Python. BMC Syst Bio.: http://www.biomedcentral.com/1752-0509/7/74/abstract


Applications

GIM3E: http://bioinformatics.oxfordjournals.org/content/early/2013/08/22/bioinformatics.btt493.abstract

Todo

https://cobrapy.readthedocs.org/en/latest/_modules/cobra/core/Model.html?highlight=objective

8.2.5.2. delete Module

Mailing lists

https://groups.google.com/forum/#!forum/cobra-pie

https://groups.google.com/forum/#!forum/cobra-toolbox