我有GI(genbank标识符)编号列表。如何为每个GI编号获取序列描述(作为' mus musculus hypothetical protein X'),以便我可以将其存储在变量中并将其写入文件? 谢谢你的帮助!
答案 0 :(得分:2)
这是我写的一个脚本,用于为文件中的每个genbank标识符提取整个GenBank文件。应该很容易为您的应用程序进行更改。
#This program will open a file containing NCBI sequence indentifiers, find the associated
#information and write the data to *.gb
import os
import sys
from Bio import Entrez
Entrez.email = "yourname@xxx.xxx" #Always tell NCBI who you are
try: #checks to make sure input file is in the folder
name = raw_input("\nEnter file name with sequence identifications only: ")
handle = open(name, 'r')
except:
print "File does not exist in folder! Check file name and extension."
quit()
outfile = os.path.splitext(name)[0]+"_GB_Full.gb"
totalhand = open(outfile, 'w')
for line in handle:
line = line.rstrip() #strips \n from file
print line
fetch_handle = Entrez.efetch(db="nucleotide", rettype="gb", retmode="text", id=line)
data = fetch_handle.read()
fetch_handle.close()
totalhand.write(data)
答案 1 :(得分:0)
所以,如果有其他人有这个问题,这就是解决方案:
handle=Entrez.esummary(db="nucleotide, protein, ...", id="gi or NCBI_ref number")
record=Entrez.read(handle)
handle.close()
description=record[0]["Title"]
print description
这将打印与标识符对应的序列描述。