2016-02-25 62 views
0

我有一个GI(genbank标识符)号码列表。我如何获得每个GI号码的序列描述(如'mus musculus hypothetical protein X'),以便我可以将它存储在一个变量中并将其写入文件? 感谢您的帮助!如何通过biopython从gi编号获取序列描述?

+1

检查了这一点,让你开始:http://biopython.org/DIST/docs/api/Bio.Entrez-pysrc.html – heathobrien

回答

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 

这将打印对应的标识序列描述。

1

这是我写的一个脚本,用于为文件中的每个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 = "yo[email protected]" #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)