Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mutalyzer
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
mutalyzer
Commits
ea67260e
Commit
ea67260e
authored
9 years ago
by
Vermaat
Browse files
Options
Downloads
Plain Diff
Merge pull request #139 from mutalyzer/entrez-httperror
Degrade gracefully on HTTP error from Entrez
parents
bd705d16
5872d941
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mutalyzer/ncbi.py
+18
-4
18 additions, 4 deletions
mutalyzer/ncbi.py
with
18 additions
and
4 deletions
mutalyzer/ncbi.py
+
18
−
4
View file @
ea67260e
...
...
@@ -3,6 +3,8 @@ Communication with the NCBI.
"""
from
urllib2
import
HTTPError
from
Bio
import
Entrez
from
.config
import
settings
...
...
@@ -65,7 +67,11 @@ def _get_link_from_ncbi(source_db, target_db, match_link_name,
source
=
'
%s.%d
'
%
(
source_accession
,
source_version
)
# Find source record.
handle
=
Entrez
.
esearch
(
db
=
source_db
,
term
=
source
)
try
:
handle
=
Entrez
.
esearch
(
db
=
source_db
,
term
=
source
)
except
HTTPError
:
return
fail_or_retry
()
try
:
result
=
Entrez
.
read
(
handle
)
except
Entrez
.
Parser
.
ValidationError
:
...
...
@@ -79,7 +85,11 @@ def _get_link_from_ncbi(source_db, target_db, match_link_name,
return
fail_or_retry
()
# Find link from source record to target record.
handle
=
Entrez
.
elink
(
dbfrom
=
source_db
,
db
=
target_db
,
id
=
source_gi
)
try
:
handle
=
Entrez
.
elink
(
dbfrom
=
source_db
,
db
=
target_db
,
id
=
source_gi
)
except
HTTPError
:
return
fail_or_retry
()
try
:
result
=
Entrez
.
read
(
handle
)
except
Entrez
.
Parser
.
ValidationError
:
...
...
@@ -98,8 +108,12 @@ def _get_link_from_ncbi(source_db, target_db, match_link_name,
return
fail_or_retry
()
# Get target record.
handle
=
Entrez
.
efetch
(
db
=
target_db
,
id
=
target_gi
,
rettype
=
'
acc
'
,
retmode
=
'
text
'
)
try
:
handle
=
Entrez
.
efetch
(
db
=
target_db
,
id
=
target_gi
,
rettype
=
'
acc
'
,
retmode
=
'
text
'
)
except
HTTPError
:
return
fail_or_retry
()
target
=
unicode
(
handle
.
read
()).
strip
().
split
(
'
.
'
)
handle
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment