Visbio and cobrapy

cobrapy integrates well with the visbio package. If it has been installed, viewing maps is extremely simple. The default map is the E. coli core map, but other maps can be viewed by passing the correct map_name. The maps are then downloaded from a map repository.


In [1]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import clear_output, display, HTML


:0: FutureWarning: IPython widgets are experimental and may change in the future.

In [2]:
from escher import Builder
import cobra.test
model = cobra.test.create_test_model(cobra.test.ecoli_pickle)

In [3]:
import escher

In [5]:
stuff = Builder('iJO1366.Central metabolism')


---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-5-bd32b5172df5> in <module>()
----> 1 stuff = Builder('iJO1366.central_metabolism')

/Users/joao/.virtualenvs/cameo-env/lib/python2.7/site-packages/escher/plots.pyc in __init__(self, map_name, map_json, model, model_name, model_json, embedded_css, reaction_data, metabolite_data, gene_data, local_host, id, safe, **kwargs)
    306         if map_name and map_json:
    307             warn('map_json overrides map_name')
--> 308         self._load_map()
    309         # load the model
    310         self.model = model

/Users/joao/.virtualenvs/cameo-env/lib/python2.7/site-packages/escher/plots.pyc in _load_map(self)
    403                                                   safe=self.safe)
    404         elif self.map_name is not None:
--> 405             self.loaded_map_json = map_json_for_name(self.map_name)
    406 
    407     def _embedded_css(self, url_source):

/Users/joao/.virtualenvs/cameo-env/lib/python2.7/site-packages/escher/plots.pyc in map_json_for_name(map_name, cache_dir)
    148 
    149 def map_json_for_name(map_name, cache_dir=get_cache_dir()):
--> 150     return _json_for_name(map_name, 'map', cache_dir)
    151 
    152 # helper functions

/Users/joao/.virtualenvs/cameo-env/lib/python2.7/site-packages/escher/plots.pyc in _json_for_name(name, kind, cache_dir)
    124         match = match_in_index(name, server_index(), kind)
    125         if len(match) == 0:
--> 126             raise Exception('Could not find the %s %s in the cache or on the server' % (kind, name))
    127         org, name = match[0]
    128         url = (get_url(kind + '_download', source='web', protocol='https') +

Exception: Could not find the map iJO1366.central_metabolism in the cache or on the server

In [ ]:
display(HTML(stuff._get_html()))

In [34]:
def show(bound=20.):
    model.reactions.get_by_id('EX_o2_e').lower_bound = -1*bound
    model.optimize()
    wt_solution = model.solution.x_dict
    display(wt_solution['Ec_biomass_iJO1366_core_53p95M'])
    display(HTML(Builder('iJO1366_central_metabolism',reaction_data=wt_solution)._get_html()))
#     display(Map(flux={'ENO':upper_obj_bound,'PGK':2}))

In [35]:
i = interact(show, bound=widgets.FloatSliderWidget(min=0.0, max=20.0, step=0.1, value=1.0))


0.6045324581789818

In [42]:
i.widget





In [2]:
# mutant flux has PGI knocked out
model.reactions.PGI.lower_bound = 0
model.reactions.PGI.upper_bound = 0
model.optimize()
mutant_solution = model.solution.x_dict

In [4]:
wt_map = Map(flux=wt_solution)
wt_map


Out[4]:

In [5]:
Map(flux=model.solution.x_dict)


Out[5]:

In [ ]: