Skip to content

Instantly share code, notes, and snippets.

@widdowquinn
Created February 1, 2013 17:45
Show Gist options
  • Save widdowquinn/4692854 to your computer and use it in GitHub Desktop.
Save widdowquinn/4692854 to your computer and use it in GitHub Desktop.
Example code to generate three metabolic maps with different rendering options.
import KGML_parser
from KGML_scrape import retrieve_KEGG_pathway
from KGML_vis import KGMLCanvas
# Get the ko01110 map from KEGG, and write it out to file, visualised as
# the .png, and as the elements from the KGML file
pathway = retrieve_KEGG_pathway('ko01110')
kgml_map = KGMLCanvas(pathway, show_maps=True)
# Default settings are for the KGML elements only
kgml_map.draw('ex1_kgml_render.pdf')
# We need to use the image map, and turn off the KGML elements, to see
# only the .png base map. We could have set these values on canvas
# instantiation
kgml_map.import_imagemap = True
kgml_map.show_maps = False
kgml_map.show_orthologs = False
kgml_map.draw_relations = False
kgml_map.show_compounds = False
kgml_map.show_genes = False
kgml_map.draw('ex1_png_render.pdf')
# And rendering elements as an overlay
kgml_map.show_compounds = True
kgml_map.show_genes = True
kgml_map.show_orthologs = True
kgml_map.draw('ex1_overlay_render.pdf')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment