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
8a38690a
Unverified
Commit
8a38690a
authored
2 years ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
fix: SCHWED-5783 distinguish between 0 lDDT and no match
parent
e2e8a084
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/mol/alg/pymod/ligand_scoring.py
+20
-13
20 additions, 13 deletions
modules/mol/alg/pymod/ligand_scoring.py
modules/mol/alg/tests/test_ligand_scoring.py
+10
-10
10 additions, 10 deletions
modules/mol/alg/tests/test_ligand_scoring.py
with
30 additions
and
23 deletions
modules/mol/alg/pymod/ligand_scoring.py
+
20
−
13
View file @
8a38690a
...
...
@@ -460,7 +460,7 @@ class LigandScorer:
# " - setting to Infinity" % str(err))
# bb_rmsd = float("inf")
lddt_pli_full_matrix
[
target_i
,
model_i
]
=
{
"
lddt_pli
"
:
0
,
"
lddt_pli
"
:
np
.
nan
,
"
lddt_pli_n_contacts
"
:
None
,
"
rmsd
"
:
rmsd
,
# "symmetry_number": i,
...
...
@@ -496,7 +496,7 @@ class LigandScorer:
# Save results?
best_lddt
=
lddt_pli_full_matrix
[
target_i
,
model_i
][
"
lddt_pli
"
]
if
global_lddt
>
best_lddt
:
if
global_lddt
>
best_lddt
or
np
.
isnan
(
best_lddt
)
:
lddt_pli_full_matrix
[
target_i
,
model_i
].
update
({
"
lddt_pli
"
:
global_lddt
,
"
lddt_pli_n_contacts
"
:
lddt_tot
,
...
...
@@ -515,8 +515,8 @@ class LigandScorer:
mat1
=
np
.
copy
(
mat1
)
mat2
=
np
.
copy
(
mat2
)
assignments
=
[]
min_mat1
=
mat1
.
min
(
)
while
min_mat1
<
np
.
inf
:
min_mat1
=
LigandScorer
.
_nanmin_nowarn
(
mat1
)
while
not
np
.
isnan
(
min_mat1
)
:
best_mat1
=
np
.
argwhere
(
mat1
==
min_mat1
)
# Multiple "best" - use mat2 to disambiguate
if
len
(
best_mat1
)
>
1
:
...
...
@@ -530,18 +530,25 @@ class LigandScorer:
max_i_trg
,
max_i_mdl
=
best_mat1
[
0
]
# Disable row and column
mat1
[
max_i_trg
,
:]
=
np
.
inf
mat1
[:,
max_i_mdl
]
=
np
.
inf
mat2
[
max_i_trg
,
:]
=
np
.
inf
mat2
[:,
max_i_mdl
]
=
np
.
inf
mat1
[
max_i_trg
,
:]
=
np
.
nan
mat1
[:,
max_i_mdl
]
=
np
.
nan
mat2
[
max_i_trg
,
:]
=
np
.
nan
mat2
[:,
max_i_mdl
]
=
np
.
nan
# Save
assignments
.
append
((
max_i_trg
,
max_i_mdl
))
# Recompute min
min_mat1
=
mat1
.
min
(
)
min_mat1
=
LigandScorer
.
_nanmin_nowarn
(
mat1
)
return
assignments
@staticmethod
def
_nanmin_nowarn
(
array
):
"""
Compute np.nanmin but ignore the RuntimeWarning.
"""
with
warnings
.
catch_warnings
():
# RuntimeWarning: All-NaN slice encountered
warnings
.
simplefilter
(
"
ignore
"
)
return
np
.
nanmin
(
array
)
@staticmethod
def
_reverse_lddt
(
lddt
):
"""
Reverse lDDT means turning it from a number between 0 and 1 to a
...
...
@@ -610,7 +617,7 @@ class LigandScorer:
Target ligands are in rows, model ligands in columns.
Infinite
values indicate that no RMSD could be computed (i.e. different
NaN
values indicate that no RMSD could be computed (i.e. different
ligands).
:rtype: :class:`~numpy.ndarray`
...
...
@@ -620,7 +627,7 @@ class LigandScorer:
if
self
.
_rmsd_matrix
is
None
:
# convert
shape
=
self
.
_rmsd_full_matrix
.
shape
self
.
_rmsd_matrix
=
np
.
full
(
shape
,
np
.
inf
)
self
.
_rmsd_matrix
=
np
.
full
(
shape
,
np
.
nan
)
for
i
,
j
in
np
.
ndindex
(
shape
):
if
self
.
_rmsd_full_matrix
[
i
,
j
]
is
not
None
:
self
.
_rmsd_matrix
[
i
,
j
]
=
self
.
_rmsd_full_matrix
[
...
...
@@ -633,7 +640,7 @@ class LigandScorer:
Target ligands are in rows, model ligands in columns.
A
value
of 0
indicate that no lDDT-PLI could be computed (i.e. different
NaN
value
s
indicate that no lDDT-PLI could be computed (i.e. different
ligands).
:rtype: :class:`~numpy.ndarray`
...
...
@@ -643,7 +650,7 @@ class LigandScorer:
if
self
.
_lddt_pli_matrix
is
None
:
# convert
shape
=
self
.
_lddt_pli_full_matrix
.
shape
self
.
_lddt_pli_matrix
=
np
.
zeros
(
shape
)
self
.
_lddt_pli_matrix
=
np
.
full
(
shape
,
np
.
nan
)
for
i
,
j
in
np
.
ndindex
(
shape
):
if
self
.
_lddt_pli_full_matrix
[
i
,
j
]
is
not
None
:
self
.
_lddt_pli_matrix
[
i
,
j
]
=
self
.
_lddt_pli_full_matrix
[
...
...
This diff is collapsed.
Click to expand it.
modules/mol/alg/tests/test_ligand_scoring.py
+
10
−
10
View file @
8a38690a
...
...
@@ -251,23 +251,23 @@ class TestLigandScoring(unittest.TestCase):
# Check RMSD
assert
sc
.
rmsd_matrix
.
shape
==
(
7
,
1
)
np
.
testing
.
assert_almost_equal
(
sc
.
rmsd_matrix
,
np
.
array
(
[[
np
.
inf
],
[[
np
.
nan
],
[
0.04244993
],
[
np
.
inf
],
[
np
.
inf
],
[
np
.
inf
],
[
np
.
nan
],
[
np
.
nan
],
[
np
.
nan
],
[
0.29399303
],
[
np
.
inf
]]),
decimal
=
5
)
[
np
.
nan
]]),
decimal
=
5
)
# Check lDDT-PLI
self
.
assertEqual
(
sc
.
lddt_pli_matrix
.
shape
,
(
7
,
1
))
self
.
assert
Equal
(
sc
.
lddt_pli_matrix
[
0
,
0
]
,
0
)
self
.
assert
True
(
np
.
isnan
(
sc
.
lddt_pli_matrix
[
0
,
0
]
)
)
self
.
assertAlmostEqual
(
sc
.
lddt_pli_matrix
[
1
,
0
],
0.99843
,
5
)
self
.
assert
Equal
(
sc
.
lddt_pli_matrix
[
2
,
0
]
,
0
)
self
.
assert
Equal
(
sc
.
lddt_pli_matrix
[
3
,
0
]
,
0
)
self
.
assert
Equal
(
sc
.
lddt_pli_matrix
[
4
,
0
]
,
0
)
self
.
assert
True
(
np
.
isnan
(
sc
.
lddt_pli_matrix
[
2
,
0
]
)
)
self
.
assert
True
(
np
.
isnan
(
sc
.
lddt_pli_matrix
[
3
,
0
]
)
)
self
.
assert
True
(
np
.
isnan
(
sc
.
lddt_pli_matrix
[
4
,
0
]
)
)
self
.
assertAlmostEqual
(
sc
.
lddt_pli_matrix
[
5
,
0
],
1.0
)
self
.
assert
Equal
(
sc
.
lddt_pli_matrix
[
6
,
0
]
,
0
)
self
.
assert
True
(
np
.
isnan
(
sc
.
lddt_pli_matrix
[
6
,
0
]
)
)
def
test_check_resnames
(
self
):
"""
Test check_resname argument works
...
...
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