Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SOaAS
dbxref
Commits
97794e74
Commit
97794e74
authored
Mar 04, 2020
by
Lukas Jelonek
Browse files
Fix failing test. Adapt to general dbxref requirements
parent
018cfd05
Changes
2
Hide whitespace changes
Inline
Side-by-side
dbxref/retrieve/gi.py
View file @
97794e74
...
...
@@ -33,7 +33,7 @@ def main():
print
(
json
.
dumps
(
documents
,
sort_keys
=
True
,
indent
=
4
))
def
retrieve
(
dbxrefs
,
basics
,
dbsource
,
references
):
def
retrieve
(
dbxrefs
,
basics
=
True
,
dbsource
=
True
,
references
=
True
):
"""Retrieve Protein data as xml and parse into json format"""
resolved
=
dbxref
.
resolver
.
resolve
(
dbxrefs
,
check_existence
=
False
)
documents
=
[]
...
...
@@ -42,7 +42,7 @@ def retrieve(dbxrefs, basics, dbsource, references):
logger
.
debug
(
"URL: %s"
,
xml_url
)
gi
=
requests
.
get
(
xml_url
)
logger
.
debug
(
"Content: %s"
,
gi
.
text
)
output
=
{}
output
=
{
"id"
:
entry
[
"dbxref"
]
}
try
:
root
=
ET
.
fromstring
(
gi
.
text
)
if
basics
:
...
...
@@ -51,18 +51,22 @@ def retrieve(dbxrefs, basics, dbsource, references):
except
KeyError
:
print
(
"One ore more of the basic information were not available for given dbxref. "
"Please check the source data."
)
raise
if
dbsource
:
try
:
output
.
update
(
read_dbsource
(
root
))
except
KeyError
:
print
(
"Source database information wasn't or wasn't fully available. Please check the source data"
)
raise
if
references
:
try
:
output
.
update
(
read_references
(
root
))
except
KeyError
:
print
(
"reference information wasn't or wasn't fully available. Please check the source data"
)
raise
except
(
RuntimeError
,
ET
.
ParseError
):
print
(
"An error occurred"
)
raise
documents
.
append
(
output
)
return
documents
...
...
tests/test_gi.py
View file @
97794e74
...
...
@@ -5,7 +5,7 @@ from dbxref.retrieve import gi
class
TestGI
(
unittest
.
TestCase
):
def
test_output
(
self
):
documents
=
gi
.
retrieve
({
"db"
:
"
I
G"
,
"id"
:
"P0ABT0"
,
},
basics
=
True
,
dbsource
=
True
,
references
=
True
)
documents
=
gi
.
retrieve
(
[
{
"db"
:
"G
I
"
,
"id"
:
"P0ABT0"
}
]
,
basics
=
True
,
dbsource
=
True
,
references
=
True
)
self
.
assertTrue
(
documents
)
...
...
Write
Preview
Markdown
is supported
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