FEV_KEGG.lib.Biopython.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
class FEV_KEGG.lib.Biopython.KEGG.KGML.KGML_parser.KGMLParser(elem)[source]

Bases: object

Parses a KGML XML Pathway entry into a Pathway object.

Example: Read and parse large metabolism file

>>> from FEV_KEGG.lib.Biopython.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) #doctest: +NORMALIZE_WHITESPACE
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

Initialize the class.

parse()[source]

Parse the input elements.

FEV_KEGG.lib.Biopython.KEGG.KGML.KGML_parser.parse(handle)[source]

Return an iterator over Pathway elements.

Parameters:handle - file handle to a KGML file for parsing, or a KGML string (-) –

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

FEV_KEGG.lib.Biopython.KEGG.KGML.KGML_parser.read(handle)[source]

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.