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
4d674680
Commit
4d674680
authored
Dec 17, 2020
by
Lukas Jelonek
Browse files
Add retries for uniprot as their servers have ssl problems
parent
5069c8cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
dbxref/retrieve/uniprot.py
View file @
4d674680
...
...
@@ -35,13 +35,27 @@ def main():
documents
=
retrieve
(
dbxrefs
,
basic
=
args
.
basic
,
sequence
=
args
.
sequence
,
organism
=
args
.
organism
,
annotation
=
args
.
annotation
,
features
=
args
.
features
)
print
(
json
.
dumps
(
documents
))
def
lookup
(
xml_url
,
retries
):
requests
.
get
(
xml_url
)
def
retrieve
(
dbxrefs
,
basic
=
True
,
sequence
=
True
,
organism
=
True
,
annotation
=
True
,
features
=
True
):
resolved
=
dbxref
.
resolver
.
resolve
(
dbxrefs
,
check_existence
=
False
)
documents
=
[]
for
entry
in
resolved
:
xml_url
=
entry
[
'locations'
][
'xml'
][
0
]
logger
.
debug
(
'URL: %s'
,
xml_url
)
r
=
requests
.
get
(
xml_url
)
retries
=
3
r
=
None
while
retries
>
0
and
r
==
None
:
try
:
r
=
requests
.
get
(
xml_url
)
break
except
requests
.
exceptions
.
SSLError
:
retries
=
retries
-
1
if
retries
>
0
:
logger
.
warning
(
"Request failed, retrying"
)
else
:
raise
logger
.
debug
(
'Content: %s'
,
r
.
text
)
output
=
{
'id'
:
entry
[
'dbxref'
]}
...
...
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