5.1. KEGG module example

Histogram of KEGG pathways relations

number of relations per pathways

Out:

Creating directory /home/docs/.cache/bioservices
Welcome to Bioservices
======================
It looks like you do not have a configuration file.
We are creating one with default values in /home/docs/.config/bioservices/bioservices.cfg .
Done
/home/docs/checkouts/readthedocs.org/user_builds/bioservices/envs/latest/lib/python3.7/site-packages/bs4/builder/__init__.py:546: XMLParsedAsHTMLWarning: It looks like you're parsing an XML document using an HTML parser. If this really is an HTML document (maybe it's XHTML?), you can ignore or filter this warning. If it's XML, you should know that using an XML parser will be more reliable. To parse this document as XML, make sure you have the lxml package installed, and pass the keyword argument `features="xml"` into the BeautifulSoup constructor.
  XMLParsedAsHTMLWarning.MESSAGE, XMLParsedAsHTMLWarning

from pylab import *


# extract all relations from all pathways
from bioservices.kegg import KEGG
s = KEGG()
s.organism = "hsa"

# retrieve more than 260 pathways so it takes time
max_pathways = 10
results = [s.parse_kgml_pathway(x) for x in s.pathwayIds[0:max_pathways]]
relations = [x['relations'] for x in results]

# plot
hist([len(this) for this in relations], 20)
xlabel('number of relations')
ylabel('#')
title("number of relations per pathways")
grid(True)

Total running time of the script: ( 0 minutes 11.857 seconds)

Gallery generated by Sphinx-Gallery