I keep on getting an UnboundLocalError: local variable 'res' referenced before assignment
.
However, I'm absolutely positive that the variable is not referenced before assignment!
Here's my code:
def get_models(self,x=None,y=None):
bioservices_up_obj = UniProt()
bioservices_quickgo_obj = QuickGO()
res = bioservices_quickgo_obj.Annotation_from_protein(protein=str(Brick.part_attrib(self,'uniprot_id')))
go_id = []
go_number = len(res['goID'])
for i in range(go_number):
go_id.append(str(res.iloc[i]['goID']))
results = bioservices_up_obj.search(go_id[:go_number],format="tab",columns="id",sort="score",maxTrials=2)
print results
All the other variables seem to print out fine, but for some reason I keep getting this error.
After checking the source of the library you're using
File "/usr/local/lib/python2.7/dist-packages/bioservices/uniprot.py", line 470, in search
It appears that line 470 does actually have a bug. Line 459 in the same file is commented out in the latest version, which appears to be causing the bug.
Downloaded the tarball from here, opened uniprot.py
, observed:
#res = s.request("/uniprot/?query=zap70+AND+organism:9606&format=xml", params)
trials = 3
while trials<maxTrials:
try:
res = self.request("uniprot/?query=%s" % query + "&" + params, "txt")
trials = maxTrials + 1
except:
self.logging.warning("Trying again...")
import time
time.sleep(2)
trials += 1
return res
Notice the commented first line (line 459 in the file). You could experiment with uncommenting that line, but I'm unfamiliar with the library so I don't know what that might do.
The project bug tracker is here, maybe you could submit a bug report.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments