5.1.3.1.3. cobramod.visualization.items

Escher JSON-schema objects

This modules has all the JSON objects that can be seen in the original JSON schema for Escher.

The classes retain their original JSON names and attributes. - Node: Represents the nodes. They can be a metabolite or markers. They give the position of all dots in the canvas. - Segment: Represents the connections between nodes. - Reaction: Represents a reaction. They contain the needed segments for the visualization of the pathway.

5.1.3.1.3.1. Module Contents

5.1.3.1.3.1.1. Classes

Node

Simple class that represent a node for the JSON schema of Escher. The

Segment

Build a segment for th reaction object for JsonCobramod, which can be

Reaction

Simple class that represent a reaction for the JSON schema for Escher. A

class cobramod.visualization.items.Node(node_type: str, x: float, y: float, label_x: float = None, label_y: float = None, bigg_id: str = '', name: str = '', node_is_primary: bool = False)

Bases: collections.UserDict

Simple class that represent a node for the JSON schema of Escher. The node type can be either a ‘metabolite’, ‘midmarker’ or a ‘multimarker’. Markers only need the arguments x and y. Check method cobramod.visualization.items.Node.__init__() to see all the corresponding arguments.

marker(self, node_type: str, x: float, y: float, **kwargs)

Sets the attribute of the dictionary if the dictionary belongs to a midmarker or multimarker. Arguments specified in __init__.

metabolite(self, node_type: str, x: float, y: float, label_x: float, label_y: float, bigg_id: str = '', name: str = '', node_is_primary: bool = False)

Returns a dictionary with the arguments if node_type correspond to metabolite. Arguments specified in __init__,

class cobramod.visualization.items.Segment(*args, **kwargs)

Bases: collections.UserDict

Build a segment for th reaction object for JsonCobramod, which can be later parsed into a proper JSON for Escher. A segment needs a starting position and and end-position. Additionally, the dots for the modification of the arrows (b1, b2) can be included.

Keyword Arguments
  • from_node_id (str) – Identifier for the starting node.

  • to_node_id (str) – identifier for the end node.

  • b1 (dict, optional) – dictionary with x and y for the blue dot that shapes the arrow.

  • b2 (dict, optional) – dictionary with x and y for the blue dot that

  • arrow. (shapes the) –

class cobramod.visualization.items.Reaction(*args, **kwargs)

Bases: collections.UserDict

Simple class that represent a reaction for the JSON schema for Escher. A Reaction have the Segment that give the position of the reaction in the canvas.

Keyword Arguments
  • name (str) – Name of the reaction.

  • bigg_id (str) – Identifier of the reactions. It does not have to be from the database BIGG.

  • reversibility (bool) – If reaction is reversible

  • label_y (float) – Position in y-axis for the label.

  • label_x (float) – Position in x-axis for the label.

  • gene_reaction_rule (str, optional) – Gene rules that specify involved genes.

  • genes (list, optional) – A list with the genes involved for that identifier. Each item has to be a dictionary with the keys ‘bigg_id’ and ‘name’

  • metabolites (list, optional) – A list with the metabolites involved. Each iteam has to be an dictionary with the keys ‘bigg_id’ and ‘coefficient’.

  • segments (PairDictionary, optional) – dictionary with cobramod.visualization.items.Segment(). They represent the connections between nodes.

add_metabolite(self, bigg_id: str, coefficient: float)

Add the identifier for a metabolite and its corresponding coefficient into the ‘metabolite’ key.

Parameters
  • bigg_id (str) – identifier of the metabolite. It does not have to be from BIGG.

  • coefficient (float) – Coefficient of the metabolite for the reaction.

add_segment(self, identifier: str, from_node_id: str, to_node_id: str)

Adds to the Reaction for given identifier a Segment. It will be visualized in Escher.

Parameters
  • identifier (str) – Number-identifier for the Segment,

  • from_node_id (str) – json data identifier, that represents the initial node for the segment.

  • to_node_id (str) – json data identifier, that represents the last node for the segment.