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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
f83eb6f9
Verified
Commit
f83eb6f9
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
feat: SCHWED-5954 speed up
parent
e6e795ce
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/mol/alg/pymod/ligand_scoring.py
+17
-5
17 additions, 5 deletions
modules/mol/alg/pymod/ligand_scoring.py
with
17 additions
and
5 deletions
modules/mol/alg/pymod/ligand_scoring.py
+
17
−
5
View file @
f83eb6f9
...
@@ -305,8 +305,8 @@ class LigandScorer:
...
@@ -305,8 +305,8 @@ class LigandScorer:
self
.
_unassigned_target_ligands
=
{}
self
.
_unassigned_target_ligands
=
{}
self
.
_unassigned_model_ligands
=
{}
self
.
_unassigned_model_ligands
=
{}
# Keep track of symmetries/isomorphisms
# Keep track of symmetries/isomorphisms
# 0: no isomorphism
#
0.
0: no isomorphism
# 1: isomorphic
# 1
.0
: isomorphic
# np.nan: not assessed yet
# np.nan: not assessed yet
self
.
_assignment_isomorphisms
=
None
self
.
_assignment_isomorphisms
=
None
...
@@ -1249,7 +1249,8 @@ class LigandScorer:
...
@@ -1249,7 +1249,8 @@ class LigandScorer:
self
.
model_ligands
[
ligand_idx
],
self
.
model_ligands
[
ligand_idx
],
self
.
target_ligands
[
trg_lig_idx
],
self
.
target_ligands
[
trg_lig_idx
],
substructure_match
=
self
.
substructure_match
,
substructure_match
=
self
.
substructure_match
,
by_atom_index
=
True
)
by_atom_index
=
True
,
return_symmetries
=
False
)
except
NoSymmetryError
:
except
NoSymmetryError
:
assigned
=
0.
assigned
=
0.
else
:
else
:
...
@@ -1301,7 +1302,8 @@ class LigandScorer:
...
@@ -1301,7 +1302,8 @@ class LigandScorer:
self
.
model_ligands
[
model_lig_idx
],
self
.
model_ligands
[
model_lig_idx
],
self
.
target_ligands
[
ligand_idx
],
self
.
target_ligands
[
ligand_idx
],
substructure_match
=
self
.
substructure_match
,
substructure_match
=
self
.
substructure_match
,
by_atom_index
=
True
)
by_atom_index
=
True
,
return_symmetries
=
False
)
except
NoSymmetryError
:
except
NoSymmetryError
:
assigned
=
0.
assigned
=
0.
else
:
else
:
...
@@ -1412,7 +1414,7 @@ def SCRMSD(model_ligand, target_ligand, transformation=geom.Mat4(),
...
@@ -1412,7 +1414,7 @@ def SCRMSD(model_ligand, target_ligand, transformation=geom.Mat4(),
def
_ComputeSymmetries
(
model_ligand
,
target_ligand
,
substructure_match
=
False
,
def
_ComputeSymmetries
(
model_ligand
,
target_ligand
,
substructure_match
=
False
,
by_atom_index
=
False
):
by_atom_index
=
False
,
return_symmetries
=
True
):
"""
Return a list of symmetries (isomorphisms) of the model onto the target
"""
Return a list of symmetries (isomorphisms) of the model onto the target
residues.
residues.
...
@@ -1430,6 +1432,12 @@ def _ComputeSymmetries(model_ligand, target_ligand, substructure_match=False,
...
@@ -1430,6 +1432,12 @@ def _ComputeSymmetries(model_ligand, target_ligand, substructure_match=False,
Otherwise, if False, the symmetries refer to atom
Otherwise, if False, the symmetries refer to atom
names.
names.
:type by_atom_index: :class:`bool`
:type by_atom_index: :class:`bool`
:type return_symmetries: If Truthy, return the mappings, otherwise simply
return True if a mapping is found (and raise if
no mapping is found). This is useful to quickly
find out if a mapping exist without the expensive
step to find all the mappings.
:type return_symmetries: :class:`bool`
:raises: :class:`NoSymmetryError` when no symmetry can be found.
:raises: :class:`NoSymmetryError` when no symmetry can be found.
"""
"""
...
@@ -1451,12 +1459,16 @@ def _ComputeSymmetries(model_ligand, target_ligand, substructure_match=False,
...
@@ -1451,12 +1459,16 @@ def _ComputeSymmetries(model_ligand, target_ligand, substructure_match=False,
model_graph
,
target_graph
,
node_match
=
lambda
x
,
y
:
model_graph
,
target_graph
,
node_match
=
lambda
x
,
y
:
x
[
"
element
"
]
==
y
[
"
element
"
])
x
[
"
element
"
]
==
y
[
"
element
"
])
if
gm
.
is_isomorphic
():
if
gm
.
is_isomorphic
():
if
not
return_symmetries
:
return
True
symmetries
=
[
symmetries
=
[
(
list
(
isomorphism
.
values
()),
list
(
isomorphism
.
keys
()))
(
list
(
isomorphism
.
values
()),
list
(
isomorphism
.
keys
()))
for
isomorphism
in
gm
.
isomorphisms_iter
()]
for
isomorphism
in
gm
.
isomorphisms_iter
()]
assert
len
(
symmetries
)
>
0
assert
len
(
symmetries
)
>
0
LogDebug
(
"
Found %s isomorphic mappings (symmetries)
"
%
len
(
symmetries
))
LogDebug
(
"
Found %s isomorphic mappings (symmetries)
"
%
len
(
symmetries
))
elif
gm
.
subgraph_is_isomorphic
()
and
substructure_match
:
elif
gm
.
subgraph_is_isomorphic
()
and
substructure_match
:
if
not
return_symmetries
:
return
True
symmetries
=
[(
list
(
isomorphism
.
values
()),
list
(
isomorphism
.
keys
()))
for
isomorphism
in
symmetries
=
[(
list
(
isomorphism
.
values
()),
list
(
isomorphism
.
keys
()))
for
isomorphism
in
gm
.
subgraph_isomorphisms_iter
()]
gm
.
subgraph_isomorphisms_iter
()]
assert
len
(
symmetries
)
>
0
assert
len
(
symmetries
)
>
0
...
...
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