Basic Usage

1. Basic Usage#

[19]:
from biggr_maps import map, pathway
from functools import partial
from pprint import pprint
[20]:
m = map.Map(name="test", description="Test map", canvas=(-1000, -1000, 2000, 2000))
[21]:
n1 = map.MetaboliteNode(
    bigg_id="mal__L_c",
    name="L-Malate",
    node_is_primary=True,
    x=0,
    y=500,
)
n2 = map.MetaboliteNode(
    bigg_id="oaa_c",
    name="Oxaloacetate",
    node_is_primary=True,
    x=0,
    y=-500,
)
[22]:
m.add_node(n1)
m.add_node(n2)
[23]:
n3 = map.MetaboliteNode(
    bigg_id="nad_c",
    name="Nicotinamide adenine dinucleotide",
    node_is_primary=False,
)
n4 = map.MetaboliteNode(
    bigg_id="nadh_c",
    name="Nicotinamide adenine dinucleotide - reduced",
    node_is_primary=False,
)
n5 = map.MetaboliteNode(
    bigg_id="h_c",
    name="H+",
    node_is_primary=False,
)
[24]:
n6 = map.MetaboliteNode(
    bigg_id="q8_c",
    name="q8_c",
    node_is_primary=False,
)
n7 = map.MetaboliteNode(
    bigg_id="q8h2_c",
    name="q8h2_c",
    node_is_primary=False,
)
[25]:
placement_opts = map.PlacementOptions(placement_f=map.AutoReaction.same_side_placement)
[26]:
reaction = pathway.place_reaction_on_backbone(
    map=m,
    name="Malate dehydrogenase",
    bigg_id="MDH",
    reaction_info=[(-1, n1), (1, n2), (-1, n3), (1, n4), (1, n5)],
    placement_f=partial(pathway.alternating_pathways_sides, centered=False),
    add_metabolite_opts=dict(placement_opts=placement_opts),
)
m.add_reaction(reaction)
[27]:
reaction = pathway.place_reaction_on_backbone(
    map=m,
    name="Malate dehydrogenase 2",
    bigg_id="MDH2",
    reaction_info=[(1, n1), (-1, n2), (1, n6), (-1, n7)],
    placement_f=partial(pathway.alternating_pathways_sides, centered=False),
    add_metabolite_opts=dict(placement_opts=placement_opts),
)
m.add_reaction(reaction)
[28]:
pprint(m.to_escher())
[{'homepage': 'https://escher.github.io',
  'map_description': 'Test map',
  'map_name': 'test',
  'schema': 'https://escher.github.io/escher/jsonschema/1-0-0#'},
 {'canvas': {'height': 2000, 'width': 2000, 'x': -1000, 'y': -1000},
  'nodes': {'0': {'bigg_id': 'mal__L_c',
                  'label_x': 20.0,
                  'label_y': 506.0,
                  'name': 'L-Malate',
                  'node_is_primary': True,
                  'node_type': 'metabolite',
                  'x': 0,
                  'y': 500},
            '1': {'bigg_id': 'oaa_c',
                  'label_x': 20.0,
                  'label_y': -494.0,
                  'name': 'Oxaloacetate',
                  'node_is_primary': True,
                  'node_type': 'metabolite',
                  'x': 0,
                  'y': -500},
            '10': {'node_type': 'midmarker', 'x': -100.0, 'y': 0.0},
            '11': {'node_type': 'multimarker',
                   'x': -100.00000000000001,
                   'y': -50.0},
            '12': {'node_type': 'multimarker', 'x': -100.0, 'y': 50.0},
            '2': {'bigg_id': 'nad_c',
                  'label_x': 174.47885996874564,
                  'label_y': 162.92078290260417,
                  'name': 'Nicotinamide adenine dinucleotide',
                  'node_is_primary': False,
                  'node_type': 'metabolite',
                  'x': 154.47885996874564,
                  'y': 156.92078290260417},
            '3': {'bigg_id': 'nadh_c',
                  'label_x': 174.47885996874564,
                  'label_y': -150.92078290260417,
                  'name': 'Nicotinamide adenine dinucleotide - reduced',
                  'node_is_primary': False,
                  'node_type': 'metabolite',
                  'x': 154.47885996874564,
                  'y': -156.92078290260417},
            '4': {'bigg_id': 'h_c',
                  'label_x': 209.80088637561914,
                  'label_y': -109.24416300446451,
                  'name': 'H+',
                  'node_is_primary': False,
                  'node_type': 'metabolite',
                  'x': 189.80088637561914,
                  'y': -115.24416300446451},
            '5': {'node_type': 'midmarker', 'x': 100.0, 'y': 0.0},
            '6': {'node_type': 'multimarker', 'x': 100.0, 'y': 50.0},
            '7': {'node_type': 'multimarker', 'x': 100.0, 'y': -50.0},
            '8': {'bigg_id': 'q8_c',
                  'label_x': -25.52114003125437,
                  'label_y': 162.92078290260417,
                  'name': 'q8_c',
                  'node_is_primary': False,
                  'node_type': 'metabolite',
                  'x': -45.52114003125437,
                  'y': 156.92078290260417},
            '9': {'bigg_id': 'q8h2_c',
                  'label_x': -25.52114003125441,
                  'label_y': -150.92078290260417,
                  'name': 'q8h2_c',
                  'node_is_primary': False,
                  'node_type': 'metabolite',
                  'x': -45.52114003125441,
                  'y': -156.92078290260417}},
  'reactions': {'0': {'bigg_id': 'MDH',
                      'gene_reaction_rule': '',
                      'genes': [],
                      'label_x': 116.0,
                      'label_y': 7.999999999999998,
                      'metabolites': [{'bigg_id': 'mal__L_c', 'coeficient': -1},
                                      {'bigg_id': 'oaa_c', 'coeficient': 1},
                                      {'bigg_id': 'nad_c', 'coeficient': -1},
                                      {'bigg_id': 'nadh_c', 'coeficient': 1},
                                      {'bigg_id': 'h_c', 'coeficient': 1}],
                      'name': 'Malate dehydrogenase',
                      'reversibility': True,
                      'segments': {'0': {'b1': None,
                                         'b2': None,
                                         'from_node_id': '6',
                                         'to_node_id': '5'},
                                   '1': {'b1': None,
                                         'b2': None,
                                         'from_node_id': '5',
                                         'to_node_id': '7'},
                                   '2': {'b1': {'x': -1.693602841383068e-14,
                                                'y': 407.80455542707114},
                                         'b2': {'x': 100.00000000000001,
                                                'y': 188.2931668593933},
                                         'from_node_id': '0',
                                         'to_node_id': '6'},
                                   '3': {'b1': {'x': 100.00000000000001,
                                                'y': -188.2931668593933},
                                         'b2': {'x': 5.645342804610227e-15,
                                                'y': -407.80455542707114},
                                         'from_node_id': '7',
                                         'to_node_id': '1'},
                                   '4': {'b1': {'x': 143.58308797499652,
                                                'y': 135.53662632208335},
                                         'b2': {'x': 100.0, 'y': 86.0},
                                         'from_node_id': '2',
                                         'to_node_id': '6'},
                                   '5': {'b1': {'x': 100.0, 'y': -86.0},
                                         'b2': {'x': 143.58308797499652,
                                                'y': -135.53662632208335},
                                         'from_node_id': '7',
                                         'to_node_id': '3'},
                                   '6': {'b1': {'x': 100.0, 'y': -83.3},
                                         'b2': {'x': 171.8407091004953,
                                                'y': -102.1953304035716},
                                         'from_node_id': '7',
                                         'to_node_id': '4'}}},
                '1': {'bigg_id': 'MDH2',
                      'gene_reaction_rule': '',
                      'genes': [],
                      'label_x': -84.0,
                      'label_y': 8.0,
                      'metabolites': [{'bigg_id': 'mal__L_c', 'coeficient': 1},
                                      {'bigg_id': 'oaa_c', 'coeficient': -1},
                                      {'bigg_id': 'q8_c', 'coeficient': 1},
                                      {'bigg_id': 'q8h2_c', 'coeficient': -1}],
                      'name': 'Malate dehydrogenase 2',
                      'reversibility': True,
                      'segments': {'10': {'b1': {'x': 2.8226714023051136e-14,
                                                 'y': -407.80455542707114},
                                          'b2': {'x': -100.00000000000004,
                                                 'y': -188.2931668593933},
                                          'from_node_id': '1',
                                          'to_node_id': '11'},
                                   '11': {'b1': {'x': -100.0, 'y': 86.0},
                                          'b2': {'x': -56.4169120250035,
                                                 'y': 135.53662632208335},
                                          'from_node_id': '12',
                                          'to_node_id': '8'},
                                   '12': {'b1': {'x': -56.41691202500355,
                                                 'y': -135.53662632208335},
                                          'b2': {'x': -100.00000000000001,
                                                 'y': -86.0},
                                          'from_node_id': '9',
                                          'to_node_id': '11'},
                                   '7': {'b1': None,
                                         'b2': None,
                                         'from_node_id': '11',
                                         'to_node_id': '10'},
                                   '8': {'b1': None,
                                         'b2': None,
                                         'from_node_id': '10',
                                         'to_node_id': '12'},
                                   '9': {'b1': {'x': -99.99999999999999,
                                                'y': 188.2931668593933},
                                         'b2': {'x': -1.693602841383068e-14,
                                                'y': 407.80455542707114},
                                         'from_node_id': '12',
                                         'to_node_id': '0'}}}},
  'text_labels': {}}]