4. Escher in Python and Jupyter

In addition to the web application, Escher has a Python package that allows you to generate maps from within Python and embed them in a Jupyter Notebook. The Python package for Escher can be installed using pip:

pip install escher

Depending on your installation of Python, you may need sudo:

sudo pip install escher

Alternatively, one can download the source files and install the package directly:

python setup.py install

Dependencies should install automatically, but they are:

4.1. Launching Escher in Python

The main entrypoint for Escher in Python is the Builder class. You can create a new map by calling Builder:

from escher import Builder
b = Builder(map_name="iJO1366.Central metabolism")

These commands will create a new builder instance, download a map from our server, then launch a new browser tab to display the map.

The specific arguments available for Builder are described in the Python API.

You can also pass a COBRApy model directly into the Builder:

import cobra
from escher import Builder
my_cobra_model = cobra.io.read_sbml_model('model.xml')
b = Builder(model=my_cobra_model)

4.2. Escher in the Jupyter Notebook

Once you have installed Escher locally, you can interact with Escher maps in a Jupyter Notebook. The commands are the same as above, but instead of calling display_in_browser(), call display_in_notebook()

Here are example notebooks to get started with:

4.3. Running the local server

You can run your own local server if you want to use Escher offline or explore your own maps with the homepage browser. To get started, install the Python package and run from any directory by calling:

python -m escher.server

This starts a server at http://localhost:7778. You can also choose another port:

python -m escher.server --port=8005