Bio.KEGG.KGML.KGML_parser module

Classes and functions to parse a KGML pathway map.

The KGML pathway map is parsed into the object structure defined in KGML_Pathway.py in this module.

Classes:
  • KGMLParser - Parses KGML file

Functions:
  • read - Returns a single Pathway object, using KGMLParser internally

Bio.KEGG.KGML.KGML_parser.read(handle, debug=0)

Parse a single KEGG Pathway from given file handle.

Returns a single Pathway object. There should be one and only one pathway in each file, but there may well be pathological examples out there.

Bio.KEGG.KGML.KGML_parser.parse(handle, debug=0)

Return an iterator over Pathway elements.

Arguments:
  • handle - file handle to a KGML file for parsing

  • debug - integer for amount of debug information to print

This is a generator for the return of multiple Pathway objects.

class Bio.KEGG.KGML.KGML_parser.KGMLParser(elem)

Bases: object

Parses a KGML XML Pathway entry into a Pathway object.

Example: Read and parse large metabolism file

>>> from Bio.KEGG.KGML.KGML_parser import read
>>> pathway = read(open('KEGG/ko01100.xml', 'r'))
>>> print(len(pathway.entries))
3628
>>> print(len(pathway.reactions))
1672
>>> print(len(pathway.maps))
149
>>> pathway = read(open('KEGG/ko00010.xml', 'r'))
>>> print(pathway) 
Pathway: Glycolysis / Gluconeogenesis
KEGG ID: path:ko00010
Image file: http://www.kegg.jp/kegg/pathway/ko/ko00010.png
Organism: ko
Entries: 99
Entry types:
    ortholog: 61
    compound: 31
    map: 7
__init__(self, elem)

Initialize the class.

parse(self)

Parse the input elements.