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 in this module.

  • KGMLParser - Parses KGML file

  • read - Returns a single Pathway object, using KGMLParser internally, 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.

  • 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))
>>> print(len(pathway.reactions))
>>> print(len(pathway.maps))
>>> pathway = read(open('KEGG/ko00010.xml', 'r'))
>>> print(pathway) 
Pathway: Glycolysis / Gluconeogenesis
KEGG ID: path:ko00010
Image file:
Organism: ko
Entries: 99
Entry types:
    ortholog: 61
    compound: 31
    map: 7
__init__(self, elem)

Initialize the class.


Parse the input elements.