cobramod.visualization.items ============================ .. py:module:: cobramod.visualization.items .. autoapi-nested-parse:: 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. Attributes ---------- .. autoapisummary:: cobramod.visualization.items.debug_log Exceptions ---------- .. autoapisummary:: cobramod.visualization.items.NodeAttributeError Classes ------- .. autoapisummary:: cobramod.visualization.items.PairDictionary cobramod.visualization.items.Node cobramod.visualization.items.Segment cobramod.visualization.items.Reaction Module Contents --------------- .. py:exception:: NodeAttributeError Bases: :py:obj:`Exception` Simple Error that should be raised when a :func:`cobramod.visualization.Node` cannot identify its type. .. py:class:: PairDictionary(pair = None, **kwargs) Bases: :py:obj:`collections.UserDict` Dictionary that can include a pair (linked) dictionary. Both dictionaries cannot have the same keys. It is posible that only a dictionary is a PairDictionary, while the other a regular dictionary. The method :func:`cobramod.visualization.PairDictionary.set_pair' sets the pair for the dictionary. .. py:method:: set_pair(pair) Set new pair for the dictionary. If will search for conflicts and raise a FoundInPairError if both PairDictionary have common keys. .. py:data:: debug_log .. py:class:: Node(node_type, x, y, label_x = None, label_y = None, bigg_id = '', name = '', node_is_primary = False) Bases: :py:obj:`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 :func:`cobramod.visualization.items.Node.__init__` to see all the corresponding arguments. .. py:method:: marker(node_type, x, y, **kwargs) Sets the attribute of the dictionary if the dictionary belongs to a midmarker or multimarker. Arguments specified in __init__. .. py:method:: metabolite(node_type, x, y, label_x, label_y, bigg_id = '', name = '', node_is_primary = False) Returns a dictionary with the arguments if node_type correspond to metabolite. Arguments specified in __init__, .. py:class:: Segment(*args, **kwargs) Bases: :py:obj:`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 from_node_id: Identifier for the starting node. :kwtype from_node_id: str :keyword to_node_id: identifier for the end node. :kwtype to_node_id: str :keyword b1: dictionary with x and y for the blue dot that shapes the arrow. :kwtype b1: dict, optional :keyword b2: dictionary with x and y for the blue dot that :kwtype b2: dict, optional :keyword shapes the arrow.: .. py:class:: Reaction(*args, **kwargs) Bases: :py:obj:`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 name: Name of the reaction. :kwtype name: str :keyword bigg_id: Identifier of the reactions. It does not have to be from the database BIGG. :kwtype bigg_id: str :keyword reversibility: If reaction is reversible :kwtype reversibility: bool :keyword label_y: Position in y-axis for the label. :kwtype label_y: float :keyword label_x: Position in x-axis for the label. :kwtype label_x: float :keyword gene_reaction_rule: Gene rules that specify involved genes. :kwtype gene_reaction_rule: str, optional :keyword genes: A list with the genes involved for that identifier. Each item has to be a dictionary with the keys 'bigg_id' and 'name' :kwtype genes: list, optional :keyword metabolites: A list with the metabolites involved. Each iteam has to be an dictionary with the keys 'bigg_id' and 'coefficient'. :kwtype metabolites: list, optional :keyword segments: dictionary with :func:`cobramod.visualization.items.Segment`. They represent the connections between nodes. :kwtype segments: PairDictionary, optional .. py:method:: add_metabolite(bigg_id, coefficient) Add the identifier for a metabolite and its corresponding coefficient into the 'metabolite' key. :param bigg_id: identifier of the metabolite. It does not have to be from BIGG. :type bigg_id: str :param coefficient: Coefficient of the metabolite for the reaction. :type coefficient: float .. py:method:: add_segment(identifier, from_node_id, to_node_id) Adds to the Reaction for given identifier a Segment. It will be visualized in Escher. :param identifier: Number-identifier for the Segment, :type identifier: str :param from_node_id: json data identifier, that represents the initial node for the segment. :type from_node_id: str :param to_node_id: json data identifier, that represents the last node for the segment. :type to_node_id: str