我正在尝试使用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/