Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
modelcif-converters
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
schwede
modelcif-converters
Commits
8bcd3d2f
Commit
8bcd3d2f
authored
9 months ago
by
Gerardo Tauriello
Browse files
Options
Downloads
Patches
Plain Diff
Fix _fetch_upkb_cached in translate2modelcif.py
parent
60328aa8
Branches
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
projects/PP2A-B55-design/translate2modelcif.py
+9
-12
9 additions, 12 deletions
projects/PP2A-B55-design/translate2modelcif.py
with
9 additions
and
12 deletions
projects/PP2A-B55-design/translate2modelcif.py
+
9
−
12
View file @
8bcd3d2f
...
@@ -363,19 +363,24 @@ def _check_sequence(up_ac, sequence):
...
@@ -363,19 +363,24 @@ def _check_sequence(up_ac, sequence):
# for cache below
# for cache below
upkb_entry_cache
=
{}
# key = (up_ac, up_version, mdl_sequence)
upkb_entry_cache
=
{}
# key = (up_ac, up_version, mdl_sequence)
def
_fetch_upkb_cached
(
sqe
,
up_ac
,
up_version
=
None
):
def
_fetch_upkb_cached
(
sqe
,
up_ac
,
up_version
=
None
):
"""
Get
versioned
UniProtKB entry
(version=None means latest)
.
"""
Get
best matching
UniProtKB entry
for sequence sqe
.
Get it from cache if already fetched.
Get it from cache if already fetched.
Return None if failed to parse entry.
up_version defines starting version in UP to check.
Note that the returned UP entry may be a different version than the one in up_version.
Returned UP data includes result of _align_sequences.
If no perfect match found, it prints a warning.
"""
"""
# check if in cache already
# check if in cache already
cache_key
=
(
up_ac
,
up_version
,
sqe
)
cache_key
=
(
up_ac
,
up_version
,
sqe
)
if
cache_key
in
upkb_entry_cache
:
if
cache_key
in
upkb_entry_cache
:
return
upkb_entry_cache
[
cache_key
]
return
upkb_entry_cache
[
cache_key
]
# fetch and parse
# fetch and parse
first guess
if
up_version
is
None
:
if
up_version
is
None
:
up_data
=
_fetch_upkb_entry
(
up_ac
)
up_data
=
_fetch_upkb_entry
(
up_ac
)
else
:
up_data
=
_fetch_unisave_entry
(
up_ac
,
up_version
)
# find best match starting from first guess
min_up_data
=
None
min_up_data
=
None
while
True
:
while
True
:
mismatches
,
up_range
,
mdl_range
,
covered_aln
,
mdl_seqres
=
_align_sequences
(
mismatches
,
up_range
,
mdl_range
,
covered_aln
,
mdl_seqres
=
_align_sequences
(
sqe
,
up_data
[
"
up_sequence
"
],
atomseq_aln
=
False
)
sqe
,
up_data
[
"
up_sequence
"
],
atomseq_aln
=
False
)
...
@@ -415,14 +420,6 @@ def _fetch_upkb_cached(sqe, up_ac, up_version=None):
...
@@ -415,14 +420,6 @@ def _fetch_upkb_cached(sqe, up_ac, up_version=None):
_warn_msg
(
msg
)
_warn_msg
(
msg
)
# raise RuntimeError(msg)
# raise RuntimeError(msg)
break
break
'''
else:
try:
# note: can fail to parse very old UP versions...
up_data = _fetch_unisave_entry(up_ac, up_version)
except RuntimeError as ex:
#_warn_msg(f
"
Error in parsing v{next_v} of {up_ac}:
\n
{ex}
"
)
up_data = None
'''
# keep in cache
# keep in cache
upkb_entry_cache
[
cache_key
]
=
up_data
upkb_entry_cache
[
cache_key
]
=
up_data
...
...
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