10. Python API

class escher.Builder(map_name: str = None, map_json: str = None, model: cobra.core.model.Model = None, model_name: str = None, model_json: str = None, **kwargs)

A Python wrapper for the Escher metabolic map.

This map will also show data on reactions, metabolites, or genes.

The Builder is a Jupyter widget that can be viewed in a Jupyter notebook or in Jupyter Lab. It can also be used to create a standalone HTML file for the map with the save_html() function.

Maps are downloaded from the Escher website if found by name.

Parameters
  • height (int) – The height of the Escher Jupyter widget in pixels.

  • map_name (str) – A string specifying a map to be downloaded from the Escher website.

  • map_json (str) – A JSON string, or a file path to a JSON file, or a URL specifying a JSON file to be downloaded.

  • model – A COBRApy model.

  • model_name – A string specifying a model to be downloaded from the Escher web server.

  • model_json – A JSON string, or a file path to a JSON file, or a URL specifying a JSON file to be downloaded.

  • embedded_css

    The CSS (as a string) to be embedded with the Escher SVG. In Jupyter, if you change embedded_css on an existing builder instance, the Builder must be restarted for this to take effect (e.g. by re-evaluating the widget in a cell). You can use the default embedded css as a starting point:

    https://github.com/zakandrewking/escher/blob/master/src/Builder-embed.css

  • reaction_data – A dictionary with keys that correspond to reaction IDs and values that will be mapped to reaction arrows and labels.

  • metabolite_data – A dictionary with keys that correspond to metabolite IDs and values that will be mapped to metabolite nodes and labels.

  • gene_data – A dictionary with keys that correspond to gene IDs and values that will be mapped to corresponding reactions.

Keyword Arguments

You can also pass in any of the following options as keyword arguments. The details on each of these are provided in the JavaScript API documentation:

  • use_3d_transform

  • menu

  • scroll_behavior

  • use_3d_transform

  • enable_editing

  • enable_keys

  • enable_search

  • zoom_to_element

  • full_screen_button

  • disabled_buttons

  • semantic_zoom

  • starting_reaction

  • never_ask_before_quit

  • primary_metabolite_radius

  • secondary_metabolite_radius

  • marker_radius

  • gene_font_size

  • hide_secondary_metabolites

  • show_gene_reaction_rules

  • hide_all_labels

  • canvas_size_and_loc

  • reaction_data

  • reaction_styles

  • reaction_compare_style

  • reaction_scale

  • reaction_no_data_color

  • reaction_no_data_size

  • gene_data

  • and_method_in_gene_reaction_rule

  • metabolite_data

  • metabolite_styles

  • metabolite_compare_style

  • metabolite_scale

  • metabolite_no_data_color

  • metabolite_no_data_size

  • identifiers_on_map

  • highlight_missing

  • allow_building_duplicate_reactions

  • cofactors

  • enable_tooltips

  • enable_keys_with_tooltip

  • reaction_scale_preset

  • metabolite_scale_preset

  • primary_metabolite_radius

  • secondary_metabolite_radius

  • marker_radius

  • gene_font_size

  • reaction_no_data_size

  • metabolite_no_data_size

If any of these is set to None, the default (or most-recent) value is used. To turn off a setting, use False instead.

All arguments can also be set by assigning the property of an an existing Builder object, e.g.:

my_builder.map_name = 'iJO1366.Central metabolism'
display_in_browser(*args, **kwargs)

Deprecated.

We recommend using the Jupyter Widget (which now supports all Escher features) or the save_html option to generate a standalone HTML file that loads the map.

display_in_notebook(*args, **kwargs)

Deprecated.

The Builder is now a Jupyter Widget, so you can return the Builder object from a cell to display it, or you can manually call the IPython display function:

from IPython.display import display from escher import Builder b = Builder(…) display(b)

save_html(filepath)

Save an HTML file containing the map.

Parameters

filepath (string) – The name of the HTML file.

10.1. Map Server

escher.list_available_maps()

Return a list of all maps available on the server

escher.list_available_models()

Return a list of all models available on the server