metascape是一个比较好的进行基因聚类分析的网站。
聚类后会发现有一些基因聚集到了KEGG通路中,但是这些基因具体在通路中的哪一个位置起作用,。
具体的基因可以通过点击图片中的Web得到对应的基因
KEGG通路可以通过点击ath04075得到kegg
当然是可以通过手动查询的。
但是一个一个的动手去搜索很累,就想到到了通过python 辅助查询
脚本如下:
from splinter import Browser
import re
b=Browser('chrome')
url1=input('请输入metascape上heatonecluster网页网址:')
number=input('请输入该聚类中需要查看的基因的个数:')
url2=input('请输入KEGG对应聚类的网页网址:')
b.visit(url1)
text=b.find_by_xpath('//*[@id="chart"]').text
ress=text.split('\n')[:int(number)]
res=[]
pa='\(.+?\)'
for gene in ress:
r=re.findall(pa,gene)[0].lstrip('(').rstrip(')')
res.append(r)
b.visit(url2)
i=1
for gene in res:
b.fill('query',gene+'\n')
print('已经查询%d/%s个基因'%(i,number))
input1=input('继续查询请按enter键(终止请输入stop):')
i+=1
if input1!='stop':
continue
else:
break
然后按enter键就可以了。