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

目录

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

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

正文

导入必须的python包

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官网得到的结果类似。

bioservices.kegg.KEGG.find()方法可以非常方便地搜索不同数据库中的条目。 例如,如果您想知道人体组织中名为ZAP70的基因条目的代码,请键入:

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'

搜索同一基因在不同物种的keggID注释

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通路

请注意,如果没有+号,将获得包含T或CELL的所有路径。

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']

通过基因名搜索kegg通路

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'

通过基因的keggID或者基因名搜索kegg通路

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'}

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值