#!/usr/bin/env python # coding: utf-8 # # Production envelopes # Production envelopes (aka phenotype phase planes) will show distinct phases of optimal growth with different use of two different substrates. For more information, see [Edwards et al.](http://dx.doi.org/10.1002/bit.10047) # # Cobrapy supports calculating these production envelopes and they can easily be plotted using your favorite plotting package. Here, we will make one for the "textbook" _E. coli_ core model and demonstrate plotting using [matplotlib](http://matplotlib.org/). # In[1]: from cobra.io import load_model from cobra.flux_analysis import production_envelope model = load_model("textbook") # We want to make a phenotype phase plane to evaluate uptakes of Glucose and Oxygen. # In[2]: prod_env = production_envelope(model, ["EX_glc__D_e", "EX_o2_e"]) # In[3]: prod_env.head() # If we specify the carbon source, we can also get the carbon and mass yield. For example, temporarily setting the objective to produce acetate instead we could get production envelope as follows and pandas to quickly plot the results. # In[4]: prod_env = production_envelope( model, ["EX_o2_e"], objective="EX_ac_e", carbon_sources="EX_glc__D_e") # In[5]: prod_env.head() # In[6]: get_ipython().run_line_magic('matplotlib', 'inline') # In[7]: prod_env.plot( kind='line', x='EX_o2_e', y='carbon_yield_maximum'); # Previous versions of cobrapy included more tailored plots for phase planes which have now been dropped in order to improve maintainability and enhance the focus of cobrapy. Plotting for cobra models is intended for another package.