【问题标题】:Error when using NCBIWWW from biopython从 biopython 使用 NCBIWWW 时出错
【发布时间】:2017-01-07 04:07:53
【问题描述】:

我正在尝试使用 NCBIWWW 爆破核苷酸序列

from Bio.Blast import NCBIWWW
my_query = "TGCGTGCCGTGCAATGTGCGT"
result_handle = NCBIWWW.qblast("blastn", "nt", my_query)
blast_result = open("my_blast.xml", "w") 
blast_result.write(result_handle.read())
blast_result.close()
result_handle.close()

这是第一次运行良好,但几天后我尝试运行它时出现错误:

>     result_handle = NCBIWWW.qblast("blastn", "nt", my_query)   File "/usr/local/lib/python2.7/dist-packages/biopython-1.63-py2.7-linux-x86_64.egg/Bio/Blast/NCBIWWW.py", line 123, in qblast
>     handle = _urlopen(request)   File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
>     return _opener.open(url, data, timeout)   File "/usr/lib/python2.7/urllib2.py", line 410, in open
>     response = meth(req, response)   File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
>     'http', request, response, code, msg, hdrs)   File "/usr/lib/python2.7/urllib2.py", line 448, in error
>     return self._call_chain(*args)   File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
>     result = func(*args)   File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
>     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 403: Forbidden

我没有更改代码中的任何内容,所以我不明白发生了什么。 可能是什么问题?

谢谢!

【问题讨论】:

  • 你是不是碰巧第一次用python3但这次用python2运行它?
  • 抱歉,我无法使用您在 Windows 10 上使用 BioPython 1.68 和 Python 3.5.2 或 2.7.12 提供的代码来复制您的问题。您是否在 3 和 2 中使用不同版本的 Biopython?您最近是否再次尝试查看它现在是否正常工作?
  • 我两次都使用 Python 2.7.6。从那以后我运行了几次,但仍然没有工作......

标签: python biopython blast ncbi


【解决方案1】:

我最近尝试在蛋白质数据库上使用 qblast 时收到了完全相同的错误消息。

修复:

我去了Biopython github,得到了qblast模块的源代码。

https://github.com/biopython/biopython/blob/master/Bio/Blast/NCBIWWW.py

我在文本编辑器中打开它并在末尾添加了一个简单的脚本

fasta_string = open("test500.fasta").read()

result_handle = qblast(
"blastp",
"swissprot",
fasta_string,
)
save_file = open("out.xml", "w")

save_file.write(result_handle.read())

save_file.close()

result_handle.close()

然后我运行了整个程序,得到了我之前得到的结果。请注意,您不再需要导入语句。事实上,如果你有它们,它就不会起作用。您现在正在脚本中定义函数。

我不确定为什么现在这是一个问题,但 NCBI 最近确实进行了一些格式更改,因此可能与此有关。任何澄清都将不胜感激,因为我知道这更多的是脚本小子工作而不是解决方案。

【讨论】:

    【解决方案2】:

    我在使用 blastn 时遇到了同样的错误。 看起来 NCBI 已经从 http 转移到 https (https://www.ncbi.nlm.nih.gov/home/develop/https-guidance.shtml)。如果您点击链接,您会看到现在需要 Biopython 1.67 或更高版本才能使用 NCBIWWW。我刚刚升级到 biopython 1.68,这解决了我的问题,希望对你也有帮助。

    【讨论】:

      猜你喜欢
      • 2019-08-30
      • 1970-01-01
      • 2014-02-11
      • 2015-04-06
      • 1970-01-01
      • 2016-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多