cameo reuses and extends model data structures defined by cobrapy (COnstraints-Based Reconstruction and Analysis tool for Python). So, in addition to following this quick start guide and other cameo tutorials, we encourage you to explore cobrapy's documentation as well.
Loading a model is easy. Just import the :class:~cameo.io.load_model
function.
from cameo import load_model
For example, load a genome-scale metabolic reconstruction of Escherichia coli.
model = load_model("iJO1366")
Models, reactions, metabolites, etc., return HTML when evaluated in Jupyter notebooks and can be easily inspected.
model
The model can be simulated by executing optimize
.
solution = model.optimize()
A quick overview of the solution can be obtained in inspecting it.
solution
A data frame representation of the solution is accessible via solution.to_frame()
.
solution.to_frame()
Data frames make it very easy to process results. For example, let's take a look at reactions with flux != 0
solution.to_frame().query('fluxes != 0')
Objects—models, reactions, metabolites, genes—can easily be explored in the Jupyter notebook, taking advantage of tab completion. For example, place your cursor after the period in model.reactions.
and press the TAB key. A dialog will appear that allows you to navigate the list of reactions encoded in the model.
model.reactions.PGK # delete PGK, place your cursor after the period and press the TAB key.
For example, you can access the E4PD (Erythrose 4-phosphate dehydrogenase) reaction in the model.
model.reactions.E4PD
Be aware that, due to variable naming restrictions in Python, dot notation access to reactions (and other objects) might not work in some cases.
# model.reactions.12DGR120tipp # uncommenting and running this cell will produce a syntax error
In those cases you need to use the model.reactions.get_by_id
.
model.reactions.get_by_id('12DGR120tipp')
Metabolites are accessible through model.metabolites
. For example, D-glucose in the cytosol compartment.
model.metabolites.glc__D_c
And it is easy to find the associated reactions
model.metabolites.glc__D_c.reactions
A list of the genes encoded in the model can be accessed via model.genes
.
model.genes[0:10]
Other additional attributes can be accessed to explore the model. For example, exchange reactions that allow certain metabolites to enter or leave the model can be accessed through model.exchanges
.
model.exchanges[0:10]
Or, the current medium can be accessed through model.medium
.
model.medium
It is also possible to get a list of essential reactions ...
from cobra.flux_analysis import find_essential_reactions
list(find_essential_reactions(model))[0:10]
... and essential genes.
from cobra.flux_analysis import find_essential_genes
list(find_essential_genes(model))[0:10]