In one of my scripts, I utilized the following block of code to query for the ID of a protein using another type of ID:
import os
import sys
import urllib.request
uniprot = 'A0A0M3KKX3'
url = 'https://www.uniprot.org/uploadlists/'
params = {
'from': 'ACC',
'to': 'PDB_ID',
'format': 'tab',
'query': uniprot,
'species': 'human'
}
dat = urllib.parse.urlencode(params)
dat = dat.encode('utf-8')
req = urllib.request.Request(url, dat)
with urllib.request.urlopen(req) as f:
response = f.read()
For the past few months, code involving this method has worked reliably, allowing me to build my algorithm on top of these features. However, as of last night, running the same code, I received the following error:
Traceback (most recent call last):
File "\\wsl.localhost\Ubuntu\home\defrondevillec\FASTAtest.py", line 21, in <module>
with urllib.request.urlopen(req) as f:
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 563, in error
return self._call_chain(*args)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 496, in _call_chain
result = func(*args)
File "C:\Users\chris\AppData\Local\Programs\Python\Python310\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 405: Not Allowed
How would I go about fixing this issue?