Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
31a59d05
Commit
31a59d05
authored
Jul 11, 2022
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
lDDT: recactor block based greedy chain mapping
parent
d7d14546
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/mol/alg/pymod/chain_mapping.py
+37
-45
37 additions, 45 deletions
modules/mol/alg/pymod/chain_mapping.py
with
37 additions
and
45 deletions
modules/mol/alg/pymod/chain_mapping.py
+
37
−
45
View file @
31a59d05
import
itertools
import
copy
import
numpy
as
np
...
...
@@ -488,10 +489,18 @@ def _BlockGreedy(the_greed, seed_size, n_mdl_chains):
if
n_mdl_chains
is
not
None
and
n_mdl_chains
<
1
:
raise
RuntimeError
(
"
n_mdl_chains must be None or >= 1
"
)
ref_chem_groups
=
copy
.
deepcopy
(
the_greed
.
ref_chem_groups
)
mdl_chem_groups
=
copy
.
deepcopy
(
the_greed
.
mdl_chem_groups
)
mapping
=
dict
()
something_happened
=
True
while
something_happened
:
something_happened
=
False
# one block per ref chain, i.e. a mapping that is extended by seed_size
starting_blocks
=
dict
()
for
ref_chains
,
mdl_chains
in
zip
(
the_greed
.
ref_chem_groups
,
the_greed
.
mdl_chem_groups
):
for
ref_chains
,
mdl_chains
in
zip
(
ref_chem_groups
,
mdl_chem_groups
):
if
len
(
mdl_chains
)
==
0
:
continue
# nothing to map
for
ref_ch
in
ref_chains
:
...
...
@@ -512,18 +521,8 @@ def _BlockGreedy(the_greed, seed_size, n_mdl_chains):
best_mapping
=
seed
starting_blocks
[
ref_ch
]
=
best_mapping
# estimate how many chains should get mapped
n_mappings
=
0
for
ref_chains
,
mdl_chains
in
zip
(
the_greed
.
ref_chem_groups
,
the_greed
.
mdl_chem_groups
):
n_mappings
+=
min
(
len
(
ref_chains
),
len
(
mdl_chains
))
mapping
=
dict
()
while
len
(
mapping
)
<
n_mappings
:
best_lddt
=
0.0
best_mapping
=
None
for
ref_ch
,
seed
in
starting_blocks
.
items
():
seed
=
the_greed
.
ExtendMapping
(
seed
)
seed_lddt
=
the_greed
.
lDDTFromFlatMap
(
seed
)
...
...
@@ -534,21 +533,14 @@ def _BlockGreedy(the_greed, seed_size, n_mdl_chains):
if
best_lddt
==
0.0
:
break
# no proper mapping found anymore
something_happened
=
True
mapping
.
update
(
best_mapping
)
for
ref_ch
in
mapping
.
keys
():
if
ref_ch
in
starting_blocks
:
del
starting_blocks
[
ref_ch
]
# sanity check...
starting_blocks_mapped_ref_chains
=
set
()
starting_blocks_mapped_mdl_chains
=
set
()
for
block_seed
in
starting_blocks
.
values
():
for
k
,
v
in
block_seed
.
items
():
starting_block_mapped_ref_chains
.
add
(
k
)
starting_block_mapped_mdl_chains
.
add
(
v
)
for
ref_ch
,
mdl_ch
in
mapping
.
items
():
assert
(
ref_ch
not
in
starting_blocks_mapped_ref_chains
)
assert
(
mdl_ch
not
in
starting_blocks_mapped_mdl_chains
)
for
ref_ch
,
mdl_ch
in
best_mapping
.
items
():
for
group_idx
in
range
(
len
(
ref_chem_groups
)):
if
ref_ch
in
ref_chem_groups
[
group_idx
]:
ref_chem_groups
[
group_idx
].
remove
(
ref_ch
)
if
mdl_ch
in
mdl_chem_groups
[
group_idx
]:
mdl_chem_groups
[
group_idx
].
remove
(
mdl_ch
)
# translate mapping format and return
final_mapping
=
list
()
...
...
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