Skip to content

Instantly share code, notes, and snippets.

@widdowquinn
Created January 30, 2013 18:44
Show Gist options
  • Save widdowquinn/4675607 to your computer and use it in GitHub Desktop.
Save widdowquinn/4675607 to your computer and use it in GitHub Desktop.
A worked example of three modes of obtaining KEGG pathways using KGML_scrape: (1) KGML as a string; (2) a stream/handle containing KGML; (3) as a KGMLPathway object.
In [1]: from KGML_scrape import *
In [2]: ex1 = retrieve_kgml('eco00010')
In [3]: ex1[:100]
Out[3]: '<?xml version="1.0"?>\n<!DOCTYPE pathway SYSTEM "http://www.genome.jp/kegg/xml/KGML_v0.7.1_.dtd">\n<!-'
In [4]: ex2 = retrieve_kgml_stream('ype02040')
In [5]: type(ex2)
Out[5]: instance
In [6]: ex2.readline()
Out[6]: '<?xml version="1.0"?>\n'
In [7]: ex3 = retrieve_KEGG_pathway('ara01120')
In [8]: ex3
Out[8]: <KGML_Pathway.Pathway at 0x10f5e7bd0>
In [9]: print ex3
Pathway: Microbial metabolism in diverse environments
KEGG ID: path:ara01120
Image file: http://www.genome.jp/kegg/pathway/ara/ara01120.png
Organism: ara
Entries: 1662
Entry types:
ortholog: 447
gene: 291
compound: 884
map: 39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment