如何通过biopython从gi号获取序列描述?

How to get sequence description from gi number through biopython?

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

所以,如果其他人有这个问题,这里是解决方案:

handle=Entrez.esummary(db="nucleotide, protein, ...", id="gi or NCBI_ref number")
record=Entrez.read(handle)
handle.close()
description=record[0]["Title"]
print description

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

这是我编写的脚本,用于为文件中的每个 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)