python - Biopython Blast - AttributeError:“分析”对象没有属性“dbtype”
问题描述
我正在尝试使用 BLAST for python 分析序列,这是我收到的原始代码。有人告诉我,这段代码可以工作,但由于库更新,它已经损坏了。
我试过寻找类似的代码,看看这是否被修改过,但没有这样的运气。
下面的第一行出现错误,我复制了整个定义,看看是否有帮助。我也一直试图弄清楚它从哪里调用,但收效甚微。
def blast(self):
if self.dbtype == "nucl" and self.querytype=="nucl":
self.blastn_cline = NCBIblast.NcbiblastnCommandline(query=self.outputfasta, db=self.format_filepath, outfmt=5, out=self.outputfasta + ".xml")
stdout, stderr = self.blastn_cline()
elif self.dbtype == "prot" and self.querytype=="nucl":
self.blastx_cline = NCBIblast.NcbiblastxCommandline(query=self.outputfasta, db=self.format_filepath, outfmt=5, out=self.outputfasta + ".xml", seg='no')
stdout, stderr = self.blastx_cline()
elif self.dbtype == "nucl" and self.querytype=="prot":
self.tblastn_cline = NCBIblast.NcbitblastnCommandline(query=self.outputfasta, db=self.format_filepath, outfmt=5, out=self.outputfasta + ".xml", seg='no')
stdout, stderr = self.tblastn_cline()
elif self.dbtype == "prot" and self.querytype=="prot":
self.blastp_cline = NCBIblast.NcbiblastpCommandline(query=self.outputfasta, db=self.format_filepath, outfmt=5, out=self.outputfasta + ".xml", seg='no')
stdout, stderr = self.blastp_cline()
result_handle = open(self.outputfasta + ".xml")
blast_records = NCBIXML.parse(result_handle)
self.simpleresults = {}
self.tophits = {}
for record in blast_records:
for hit in record.alignments:
for hsp in hit.hsps:
try:
self.simpleresults[record.query].append([hit.hit_id.strip(), hsp.identities, hsp.align_length, hsp.query.strip(), hsp.match, hsp.sbjct, hsp.query_start, hsp.sbjct_start, hsp.sbjct_end, hsp.query_end])
except:
self.simpleresults[record.query]=[[hit.hit_id.strip(), hsp.identities, hsp.align_length, hsp.query.strip(), hsp.match, hsp.sbjct, hsp.query_start, hsp.sbjct_start, hsp.sbjct_end, hsp.query_end]]
self.tophits[record.query]=self.simpleresults[record.query][0]
x=0
Label(self.result_frame, text="Query").grid(row=0, column = 1)
Label(self.result_frame, text="Hit").grid(row=0, column=2)
Label(self.result_frame, text="Percent ID").grid(row=0, column=3)
Label(self.result_frame, text="Hit Coverage").grid(row=0, column=4)
Label(self.result_frame, text="Ref Length").grid(row=0, column=5)
for key in sorted(self.tophits.keys()):
if int(100*self.tophits[key][1]/self.tophits[key][2])>=80:
q=Text(self.result_frame, height=1, width=60)
q.insert(1.0, key)
q.grid(row=x+1, column=1)
h=Text(self.result_frame, height=1, width=60)
h.insert(1.0, self.tophits[key][0])
h.grid(row=x+1, column=2)
q.configure(relief=FLAT)
h.configure(relief=FLAT)
Label(self.result_frame, text=str(int(100*self.tophits[key][1]/self.tophits[key][2]))).grid(row=x+1, column=3)
try:
Label(self.result_frame, text=str(int(100*self.tophits[key][2]/len(self.refsequences[self.tophits[key][0]])))).grid(row=x+1, column=4)
except:
Label(self.result_frame, text=str(int(100*self.tophits[key][2]/len(self.tophits[key][5])))).grid(row=x+1, column=4)
try:
Label(self.result_frame, text=str(len(self.refsequences[self.tophits[key][0]]))).grid(row=x+1, column=5)
except:
Label(self.result_frame, text=str(len(self.tophits[key][5]))).grid(row=x+1, column=5)
Button(self.result_frame, text="View alignment", command=lambda arg1=key : self.viewalignment(arg1)).grid(row=x+1, column=6)
x+=1
self.b3.destroy()
和错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\lukec\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "C:/Code/2018-07-31_New/sequencetools.py", line 1183, in blast
if self.dbtype == "nucl" and self.querytype=="nucl":
AttributeError: 'Analyze' object has no attribute 'dbtype'
关于如何让 BLAST 再次工作的任何解决方案?
编辑:我已经能够使用控制台命令发现 dbtype 适用于 blast 的衍生品,但是对于我的脚本使用它们的方式,将它们移植过来的最佳方法是什么?见:https ://www.biostars.org/p/298929/
解决方案
推荐阅读
- r - 如何匹配除数字后跟空格和仅数字后跟空格之外的所有内容?
- php - 如何在我的名为 ajax 的 php 脚本中访问 wordpress 函数
- excel - 如何遍历工作表的多个区域?
- powershell-2.0 - powershell v2 可能的重定向问题
- excel - 获取不属于给定开始和结束日期的周动态列表
- r - 在 R 中为流图添加标题(github 包)
- python - 试图根据具有两列流派和性别的数据框找到每个性别的热门流派
- html - 如何自适应设置行中的项目
- opencv - opencv中的无损jpeg压缩
- javascript - 如何在 Typescript/JavaScript 中显示两个数组之间的差异?