基于关键字的python蛋白质FASTA序列提取

2024-03-29 08:50:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python2.7从Entrez收集蛋白质FASTA序列。我在寻找名字中有“末端酶”和“大”关键字的任何蛋白质。到目前为止我得到的密码是:

from Bio import Entrez
Entrez.email = "example@example.org"


searchResultHandle = Entrez.esearch(db="protein", term="terminase large", retmax=1000)
searchResult = Entrez.read(searchResultHandle)
ids = searchResult["IdList"]

handle = Entrez.efetch(db="protein", id=ids, rettype="fasta", retmode="text")
record = handle.read()

out_handle = open('myfasta.fasta', 'w')
out_handle.write(record.rstrip('\n'))

然而,它可以从不同的有机体中得到几种末端酶,而我只需要噬菌体形式的末端酶(特别是病毒[taxid 10239],宿主细菌)。我已经设法从我感兴趣的病毒的NCBI中获得了nuccore登录id,但是我不知道如何将这两个信息结合起来。 id文件如下所示:

^{pr2}$

我需要访问每个ID的每个gb文件并在其中搜索我想要的蛋白质吗?在


Tags: ididsreaddbexampleentrez蛋白质out
1条回答
网友
1楼 · 发布于 2024-03-29 08:50:01

找到了我要找的东西。在:

searchResultHandle = Entrez.esearch(db="protein", term="terminase large", retmax=1000)

我补充道:

^{pr2}$

这使得我没有搜索到想要的病毒。当然,它不是按主机筛选的,而是按分类法组筛选的,但这对我的工作来说已经足够了。在

感谢@Llopis提供额外帮助

相关问题 更多 >