1

我发现自己对以下错误感到有些困惑

from future.standard_library import install_aliases
install_aliases()
from urllib.request import urlopen
import xmltodict

oboxml = urlopen('http://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0003723&format=oboxml')
obo_dict = oboxml.read()
obo_dict_parse = xmltodict.parse(obo_dict)

返回错误:

ExpatError Traceback(最近一次通话最后一次)在 6oboxml = urlopen(' http://www.ebi.ac.uk/QuickGO/GTerm?id=GO:0003723&format=oboxml ') 7obo_dict =oboxml.read() -- --> 8 obo_dict_parse = xmltodict.parse(obo_dict)

~/anaconda3/lib/python3.6/site-packages/xmltodict.py in parse(xml_input, encoding, expat, process_namespaces, namespace_separator, disable_entities, **kwargs) 328 parser.ParseFile(xml_input) 329 else: --> 330 parser.Parse(xml_input, True) 331 返回 handler.item 332

ExpatError:语法错误:第 1 行,第 0 列

正在返回 xml 文件,因此它不为空。但我不确定为什么 xml 解析器会不高兴,特别是因为我正在关注一个教程笔记本*。我正在使用 xmltodict 0.11.0-py36_1,通过 anaconda 安装和更新。

非常感谢任何指针

*以下笔记本:goatools https://link.springer.com/protocol/10.1007/978-1-4939-3743-1_16

4

1 回答 1

0

From what I can gather:

Quickgo doesn't provide xml format. It is not listed as a response type in their API https://www.ebi.ac.uk/QuickGO/api/index.html#!/annotations/downloadLookupUsingGET

I tried an alternative fetch method using the Bioservices package and its QuickGo tools. It seems this package has diverged from its documentation, i.e. where once:

term = qgo.Term("GO:0000016", frmt="oboxml")

it no longer does. Term has been replaced with Terms, and it no longer accept 'frmt=' or 'format='.

The closest I can currently get is:

from bioservices import QuickGO as qgo
qgo = qgo()
term = qgo.Terms("GO:0000016")
print(term, type(term))

which will return a list.

An xml file was desired, for use with the package goatools. I will edit the original question to clarify this in case others come across the same problem.

于 2019-01-25T03:42:41.190 回答