Bio.KEGG.KGML.KGML_pathway module

Classes to represent a KGML Pathway Map.

The KGML definition is as of release KGML v0.7.2 (http://www.kegg.jp/kegg/xml/docs/)

Classes:
  • Pathway - Specifies graph information for the pathway map

  • Relation - Specifies a relationship between two proteins or KOs, or protein and compound. There is an implied direction to the relationship in some cases.

  • Reaction - A specific chemical reaction between a substrate and a product.

  • Entry - A node in the pathway graph

  • Graphics - Entry subelement describing its visual representation

class Bio.KEGG.KGML.KGML_pathway.Pathway

Bases: object

Represents a KGML pathway from KEGG.

Specifies graph information for the pathway map, as described in release KGML v0.7.2 (http://www.kegg.jp/kegg/xml/docs/)

Attributes:
  • name - KEGGID of the pathway map

  • org - ko/ec/[org prefix]

  • number - map number (integer)

  • title - the map title

  • image - URL of the image map for the pathway

  • link - URL of information about the pathway

  • entries - Dictionary of entries in the pathway, keyed by node ID

  • reactions - Set of reactions in the pathway

The name attribute has a restricted format, so we make it a property and enforce the formatting.

The Pathway object is the only allowed route for adding/removing Entry, Reaction, or Relation elements.

Entries are held in a dictionary and keyed by the node ID for the pathway graph - this allows for ready access via the Reaction/Relation etc. elements. Entries must be added before reference by any other element.

Reactions are held in a dictionary, keyed by node ID for the path. The elements referred to in the reaction must be added before the reaction itself.

__init__(self)

Initialize the class.

get_KGML(self)

Return the pathway as a string in prettified KGML format.

add_entry(self, entry)

Add an Entry element to the pathway.

remove_entry(self, entry)

Remove an Entry element from the pathway.

add_reaction(self, reaction)

Add a Reaction element to the pathway.

remove_reaction(self, reaction)

Remove a Reaction element from the pathway.

add_relation(self, relation)

Add a Relation element to the pathway.

remove_relation(self, relation)

Remove a Relation element from the pathway.

__str__(self)

Return a readable summary description string.

property name

The KEGGID for the pathway map.

property number

The KEGG map number.

property compounds

Get a list of entries of type compound.

property maps

Get a list of entries of type map.

property orthologs

Get a list of entries of type ortholog.

property genes

Get a list of entries of type gene.

property reactions

Get a list of reactions in the pathway.

property reaction_entries

List of entries corresponding to each reaction in the pathway.

property relations

Get a list of relations in the pathway.

property element

Return the Pathway as a valid KGML element.

property bounds

Coordinate bounds for all Graphics elements in the Pathway.

Returns the [(xmin, ymin), (xmax, ymax)] coordinates for all Graphics elements in the Pathway

class Bio.KEGG.KGML.KGML_pathway.Entry

Bases: object

Represent an Entry from KGML.

Each Entry element is a node in the pathway graph, as described in release KGML v0.7.2 (http://www.kegg.jp/kegg/xml/docs/)

Attributes:
  • id - The ID of the entry in the pathway map (integer)

  • names - List of KEGG IDs for the entry

  • type - The type of the entry

  • link - URL of information about the entry

  • reaction - List of KEGG IDs of the corresponding reactions (integer)

  • graphics - List of Graphics objects describing the Entry’s visual representation

  • components - List of component node ID for this Entry (‘group’)

  • alt - List of alternate names for the Entry

NOTE: The alt attribute represents a subelement of the substrate and product elements in the KGML file

__init__(self)

Initialize the class.

__str__(self)

Return readable descriptive string.

add_component(self, element)

Add an element to the entry.

If the Entry is already part of a pathway, make sure the component already exists.

remove_component(self, value)

Remove the entry with the passed ID from the group.

add_graphics(self, entry)

Add the Graphics entry.

remove_graphics(self, entry)

Remove the Graphics entry with the passed ID from the group.

property name

List of KEGG identifiers for the Entry.

property reaction

List of reaction KEGG IDs for this Entry.

property id

The pathway graph node ID for the Entry.

property element

Return the Entry as a valid KGML element.

property bounds

Coordinate bounds for all Graphics elements in the Entry.

Return the [(xmin, ymin), (xmax, ymax)] co-ordinates for the Entry Graphics elements.

property is_reactant

Return true if this Entry participates in any reaction in its parent pathway.

class Bio.KEGG.KGML.KGML_pathway.Component(parent)

Bases: object

An Entry subelement used to represents a complex node.

A subelement of the Entry element, used when the Entry is a complex node, as described in release KGML v0.7.2 (http://www.kegg.jp/kegg/xml/docs/)

The Component acts as a collection (with type ‘group’, and typically its own Graphics subelement), having only an ID.

__init__(self, parent)

Initialize the class.

property id

The pathway graph node ID for the Entry

property element

Return the Component as a valid KGML element.

class Bio.KEGG.KGML.KGML_pathway.Graphics(parent)

Bases: object

An Entry subelement used to represents the visual representation.

A subelement of Entry, specifying its visual representation, as described in release KGML v0.7.2 (http://www.kegg.jp/kegg/xml/docs/)

Attributes:
  • name Label for the graphics object

  • x X-axis position of the object (int)

  • y Y-axis position of the object (int)

  • coords polyline co-ordinates, list of (int, int) tuples

  • type object shape

  • width object width (int)

  • height object height (int)

  • fgcolor object foreground color (hex RGB)

  • bgcolor object background color (hex RGB)

Some attributes are present only for specific graphics types. For example, line types do not (typically) have a width. We permit non-DTD attributes and attribute settings, such as

dash List of ints, describing an on/off pattern for dashes

__init__(self, parent)

Initialize the class.

property x

The X coordinate for the graphics element.

property y

The Y coordinate for the graphics element.

property width

The width of the graphics element.

property height

The height of the graphics element.

property coords

Polyline coordinates for the graphics element.

property fgcolor

Foreground color.

property bgcolor

Background color.

property element

Return the Graphics as a valid KGML element.

property bounds

Coordinate bounds for the Graphics element.

Return the bounds of the Graphics object as an [(xmin, ymin), (xmax, ymax)] tuple. Co-ordinates give the centre of the circle, rectangle, roundrectangle elements, so we have to adjust for the relevant width/height.

property centre

Return the centre of the Graphics object as an (x, y) tuple.

class Bio.KEGG.KGML.KGML_pathway.Reaction

Bases: object

A specific chemical reaction with substrates and products.

This describes a specific chemical reaction between one or more substrates and one or more products.

Attributes:
  • id Pathway graph node ID of the entry

  • names List of KEGG identifier(s) from the REACTION database

  • type String: reversible or irreversible

  • substrate Entry object of the substrate

  • product Entry object of the product

__init__(self)

Initialize the class.

__str__(self)

Return an informative human-readable string.

add_substrate(self, substrate_id)

Add a substrate, identified by its node ID, to the reaction.

add_product(self, product_id)

Add a product, identified by its node ID, to the reaction.

property id

Node ID for the reaction.

property name

List of KEGG identifiers for the reaction.

property substrates

Return list of substrate Entry elements.

property products

Return list of product Entry elements.

property entry

Return the Entry corresponding to this reaction.

property reactant_ids

Return a list of substrate and product reactant IDs.

property element

Return KGML element describing the Reaction.

class Bio.KEGG.KGML.KGML_pathway.Relation

Bases: object

A relationship between to products, KOs, or protein and compound.

This describes a relationship between two products, KOs, or protein and compound, as described in release KGML v0.7.2 (http://www.kegg.jp/kegg/xml/docs/)

Attributes:
  • entry1 - The first Entry object node ID defining the relation (int)

  • entry2 - The second Entry object node ID defining the relation (int)

  • type - The relation type

  • subtypes - List of subtypes for the relation, as a list of (name, value) tuples

__init__(self)

Initialize the class.

__str__(self)

Return a useful human-readable string.

property entry1

Entry1 of the relation.

property entry2

Entry2 of the relation.

property element

Return KGML element describing the Relation.