呆鸟的Python数据分析生物信息学与算法Python新世界

Python从零开始第五章生物信息学③kegg查询

2018-12-09  本文已影响758人  柳叶刀与小鼠标

目录

Python从零开始第五章生物信息学①提取差异基因

Python从零开始第五章生物信息学②热图及火山图

Python从零开始第五章生物信息学③kegg查询

==================================================

正文

from bioservices.kegg import KEGG
s = KEGG()

KEGG拥有许多数据库。 该列表可以在属性bioservices.kegg.KEGG.databases中找到。 可以使用bioservices.kegg.KEGG.list()方法查询每个数据库:

s.list("organism")

通常,方法需要访问在线KEGG数据库,因此需要时间。 例如,上面的命令需要几秒钟。 但是,有些是缓冲的,所以下次调用它时会更快。另一个有用的别名是检索所有通路ID的通道ID。 但是,必须首先指定您感兴趣的生物体。从上面的命令我们知道hsa(人类)是有效的生物体ID,所以让我们设置它然后获取路径列表:

s.organism = "hsa"
s.pathwayIds

根据上图可以看出,共计统计三百三十个人类的kegg通路

KEGG API提供的另一个功能是bioservices.kegg.KEGG.get()查询特定条目。 在这里,我们对人类基因感兴趣,代码为7535:

b = s.get("hsa:7535")    #hsa:7535 is also known as ZAP70

上图与我们从kegg官网得到的结果类似。

s.find("hsa", "zap70")
Out[6]: 'hsa:7535\tZAP70, ADMIO2, IMD48, SRK, STCD, STD, TZK, ZAP-70; zeta chain of T cell receptor associated protein kinase 70\n'
s.lookfor_organism("droso")
Out[8]: 
['T00030 dme Drosophila melanogaster (fruit fly) Eukaryotes;Animals;Arthropods;Insects',
 'T01032 dpo Drosophila pseudoobscura pseudoobscura Eukaryotes;Animals;Arthropods;Insects',
 'T01059 dan Drosophila ananassae Eukaryotes;Animals;Arthropods;Insects',
 'T01060 der Drosophila erecta Eukaryotes;Animals;Arthropods;Insects',
 'T01063 dpe Drosophila persimilis Eukaryotes;Animals;Arthropods;Insects',
 'T01064 dse Drosophila sechellia Eukaryotes;Animals;Arthropods;Insects',
 'T01065 dsi Drosophila simulans Eukaryotes;Animals;Arthropods;Insects',
 'T01067 dwi Drosophila willistoni Eukaryotes;Animals;Arthropods;Insects'.....]

寻找途径非常相似。 您可以使用上面的find方法:

print(s.find("pathway", "T+cell"))
path:map04110   Cell cycle
path:map04111   Cell cycle - yeast
path:map04658   Th1 and Th2 cell differentiation
path:map04659   Th17 cell differentiation
path:map04660   T cell receptor signaling pathway
path:map04662   B cell receptor signaling pathway

可以通过这种搜索方式搜索包含T 以及 cell的kegg通路

print(s.find("pathway", "T cell"))
path:map04110   Cell cycle
path:map04111   Cell cycle - yeast
path:map04112   Cell cycle - Caulobacter
path:map04218   Cellular senescence
path:map04514   Cell adhesion molecules (CAMs)
path:map04550   Signaling pathways regulating pluripotency of stem cells
path:map04640   Hematopoietic cell lineage
path:map04650   Natural killer cell mediated cytotoxicity
path:map04658   Th1 and Th2 cell differentiation
path:map04659   Th17 cell differentiation
s.lookfor_pathway("B cell")
Out[13]: ['path:map04662 B cell receptor signaling pathway']
s.find("hsa", "zap70")
Out[14]: 'hsa:7535\tZAP70, ADMIO2, IMD48, SRK, STCD, STD, TZK, ZAP-70; zeta chain of T cell receptor associated protein kinase 70\n'
res = s.get_pathway_by_gene("7535", "hsa")
res
Out[16]: 
{'hsa04014': 'Ras signaling pathway',
 'hsa04064': 'NF-kappa B signaling pathway',
 'hsa04650': 'Natural killer cell mediated cytotoxicity',
 'hsa04658': 'Th1 and Th2 cell differentiation',
 'hsa04659': 'Th17 cell differentiation',
 'hsa04660': 'T cell receptor signaling pathway',
 'hsa05340': 'Primary immunodeficiency'}
s.get_pathway_by_gene("zap70", "hsa")
Out[17]: 
{'hsa04014': 'Ras signaling pathway',
 'hsa04064': 'NF-kappa B signaling pathway',
 'hsa04650': 'Natural killer cell mediated cytotoxicity',
 'hsa04658': 'Th1 and Th2 cell differentiation',
 'hsa04659': 'Th17 cell differentiation',
 'hsa04660': 'T cell receptor signaling pathway',
 'hsa05340': 'Primary immunodeficiency'}
上一篇下一篇

猜你喜欢

热点阅读