HTTP错误405用于以前用于查询Uniprot ID映射的代码
在我的一个脚本中,我使用以下代码块来查询使用另一种ID的蛋白质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()
在过去的几个月中,涉及此方法的代码可靠地起作用,使我能够在顶部构建我的算法这些功能。但是,截至昨晚,运行相同的代码,我收到以下错误:
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
我该如何解决此问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只是遇到了同样的问题 - Uniprot已推出了一个新的网站和一系列服务。目前,旧的可以在
lagacy.uniprot.org
短期修复
使用
https://legacy.uniprot.org/uploadlists/
作为代码中的URL。这是在我的代码中使用类似查询的代码(uniprotid - &gt; Gene名称)长期修复
可能最好地迁移到新的ID映射服务,该服务已记录在此处:
https://wwwww.uniprot.org/help/help/help/id_mapping ID映射请求,该请求返回工作ID,然后对结果进行轮询,文档底部有一些示例python代码: https://www.uniprot.org/help/id_mapping#pypython-example (下面重现)
I've just hit the same issue - Uniprot have launched a new website and series of services. For now the old ones are available at
legacy.uniprot.org
Short term fix
Use
https://legacy.uniprot.org/uploadlists/
as the URL in your code. This is working in my code for a similar query (uniprotID -> gene name)Longer term fix
Probably best to migrate to the new ID Mapping service, which is documented here:
https://www.uniprot.org/help/id_mapping
You are now required to make an ID Mapping request, which returns a job ID, then poll for the result, there is some sample python code at the bottom of the docs: https://www.uniprot.org/help/id_mapping#python-example (reproduced below)
现在,您可以使用迈克尔·米尔顿(Michael Milton)(@多聚元素)要在Python中进行ID映射,请参见公告。该软件包还可以与Uniprot在2022 REST API中的新产品配合使用。
示例在原始帖子中使用Unipredsed:
结果:
请参阅使用它进行三个人类基因的ID映射到Uniprot标识符/登录代码在这里。该帖子还具有链接,以获取有关未经许可的软件包的更多信息,以及用于锻炼
source
和目标(dest
)详细信息的建议。查看更多示例使用Unipredsed访问Uniprot的新REST API 和在底部来自“从 - 到”结果的熊猫数据框。
更新:我做了一个存储库,允许在浏览器中运行此和其他未经许可的示例,而无需在计算机上安装任何内容。首先,Go 在这里,然后单击任何'
启动binder
'徽章。You can now use the Unipressed package by Michael Milton (@multimeric) to do ID mapping in Python, see the announcement. This package also works with UniProt's new in 2022 REST API.
Example from original post using Unipressed:
Result:
See an example of using it to do ID mapping of three human genes to UniProt identifier / accession code here. That post also has links for more information about the Unipressed package and advice for working out
source
and destination (dest
) details.See more examples of using Unipressed to access Uniprot's new REST API here in my reply to Biostar's post 'Accessing UNIPROT using REST API', and at the bottom here includes making a Pandas dataframe from the 'from - to' results.
UPDATE: I made a repo that allows running this and other Unipressed examples right in your browser without installing anything on your machine. To get started, go here and click any '
launch binder
' badge.