Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SOaAS
dbxref
Commits
563015e3
Commit
563015e3
authored
Apr 09, 2018
by
Lukas Jelonek
Browse files
Add parser reporting to pfam retriever
parent
991a74e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
dbxref/retrieve/pfam.py
View file @
563015e3
...
...
@@ -39,15 +39,27 @@ def retrieve(dbxrefs, basic=True, annotation=True):
output
=
{
'id'
:
entry
[
'dbxref'
]}
tree
=
str
(
ET
.
tostring
(
root
))
if
'<error>'
in
tree
:
output
[
'message'
]
=
tree
[
tree
.
find
(
'<error>'
)
+
7
:
tree
.
rfind
(
'</error>'
)]
else
:
for
child
in
root
.
findall
(
'pfam:entry'
,
ns
):
if
basic
:
output
.
update
(
read_basic
(
child
))
if
annotation
:
output
.
update
(
read_annotation
(
child
))
try
:
tree
=
str
(
ET
.
tostring
(
root
))
if
'<error>'
in
tree
:
output
[
'message'
]
=
tree
[
tree
.
find
(
'<error>'
)
+
7
:
tree
.
rfind
(
'</error>'
)]
else
:
for
child
in
root
.
findall
(
'pfam:entry'
,
ns
):
if
basic
:
output
.
update
(
read_basic
(
child
))
if
annotation
:
output
.
update
(
read_annotation
(
child
))
except
(
KeyError
,
AttributeError
)
as
e
:
logger
.
warn
(
'Error in retrieving %s'
,
str
(
entry
))
raise
except
RuntimeError
as
e
:
output
[
'message'
]
=
'an error occurred'
try
:
html
=
HTML
.
document_fromstring
(
r
.
text
.
replace
(
'
\n
'
,
' '
))
if
html
.
get_element_by_id
(
'noResultsMessage'
)
is
not
None
:
output
[
'message'
]
=
'no results found; probably invalid ID'
except
:
pass
documents
.
append
(
output
)
return
documents
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment