Python SeqIO:“我不知道;“句柄”中未找到任何记录;

Python SeqIO:“我不知道;“句柄”中未找到任何记录;,python,bioinformatics,biopython,genbank,Python,Bioinformatics,Biopython,Genbank,我刚刚开始学习Python和BioPython,没有太多编程经验。我很感激你们能给我的任何帮助 我正试图从genbank中提取CD和/或rRNA序列。重要的是,我只得到开放的阅读框架,这就是为什么我不只是拉整个序列。当我运行下面的代码时,它会返回一个错误,说: 在句柄中找不到任何记录 对于读取的代码行:record=SeqIO.read(handle,“genbank”)。我不知道如何纠正这个问题。我在下面包含了我正在使用的代码 另外,如果有一个更简单的方法来做这件事,或者发布代码,如果你们让我

我刚刚开始学习Python和BioPython,没有太多编程经验。我很感激你们能给我的任何帮助

我正试图从genbank中提取CD和/或rRNA序列。重要的是,我只得到开放的阅读框架,这就是为什么我不只是拉整个序列。当我运行下面的代码时,它会返回一个错误,说:

在句柄中找不到任何记录

对于读取的代码行:
record=SeqIO.read(handle,“genbank”)
。我不知道如何纠正这个问题。我在下面包含了我正在使用的代码

另外,如果有一个更简单的方法来做这件事,或者发布代码,如果你们让我知道,我将不胜感激

谢谢

# search sequences by a combination of keywords
# need to find (number of) results to set 'retmax' value
handle = Entrez.esearch(db = searchdb, term = searchterm)
records = Entrez.read(handle)
handle.close()
# repeat search with appropriate 'retmax' value
all_handle = Entrez.esearch(db = searchdb, term = searchterm, retmax = records['Count'])
records = Entrez.read(all_handle)

print " "
print "Number of sequences found:", records['Count'] #printing to make sure that code is working thus far. 
print " "

locations = [] # store locations of target sequences
sequences = [] # store target sequences

for i in range(0,int(records['Count'])) :
    handle = Entrez.efetch(db = searchdb, id = records['IdList'][i], rettype = "gb", retmode = "xml") 
    record = SeqIO.read(handle, "genbank")
    for feature in record.features:
        if feature.type==searchfeaturetype: #searches features for proper feature type
            if searchgeneproduct in feature.qualifiers['product'][0]: #searches features for proper gene product
                if str(feature.qualifiers) not in locations: # no repeat location entries
                    locations.append(str(feature.location)) # appends location entry
                    sequences.append(feature.extract(record.seq)) # append sequence

SeqIO.read
要求格式为genbank平面文件格式时,您正在向genbank请求
xml
。尝试将您的
efetch
行更改为:

handle = Entrez.efetch(db = searchdb, id = records['IdList'][i], rettype = "gb", retmode = "txt") 

谢谢你,GWW。这解决了我的问题!