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
2d0ef5da
Commit
2d0ef5da
authored
10 months ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
ligand scoring: add more unit tests to refactored ligand scoring
parent
8be12ac0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/mol/alg/tests/test_ligand_scoring_fancy.py
+84
-0
84 additions, 0 deletions
modules/mol/alg/tests/test_ligand_scoring_fancy.py
with
84 additions
and
0 deletions
modules/mol/alg/tests/test_ligand_scoring_fancy.py
+
84
−
0
View file @
2d0ef5da
...
...
@@ -516,7 +516,91 @@ class TestLigandScoringFancy(unittest.TestCase):
self
.
assertEqual
([
str
(
r
)
for
r
in
sc
.
aux
[
"
D
"
][
1
][
"
bs_ref_res
"
]],
expected_bs_ref_res
)
ost
.
PopVerbosityLevel
()
def
test_substructure_match
(
self
):
"""
Test that substructure_match=True works.
"""
trg
=
_LoadMMCIF
(
"
1r8q.cif.gz
"
)
mdl
=
_LoadMMCIF
(
"
P84080_model_02.cif.gz
"
)
trg_g3d1
=
trg
.
FindResidue
(
"
F
"
,
1
)
mdl_g3d
=
mdl
.
FindResidue
(
"
L_2
"
,
1
)
# Skip PA, PB and O[1-3]A and O[1-3]B in target and model
# ie 8 / 32 atoms => coverage 0.75
# We assume atom index are fixed and won't change
trg_g3d1_sub_ent
=
trg_g3d1
.
Select
(
"
aindex>6019
"
)
trg_g3d1_sub
=
trg_g3d1_sub_ent
.
residues
[
0
]
# without enabling substructure matches
sc
=
ligand_scoring_scrmsd
.
SCRMSDScorer
(
mdl
.
Select
(
"
protein=True
"
),
trg
.
Select
(
"
protein=True
"
),
model_ligands
=
[
mdl_g3d
],
target_ligands
=
[
trg_g3d1_sub
],
substructure_match
=
False
)
self
.
assertEqual
(
sc
.
coverage_matrix
.
shape
,
(
1
,
1
))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
0
,
0
]))
self
.
assertEqual
(
sc
.
states_matrix
[
0
,
0
],
3
)
# error encoding for that particular issue
# Substructure matches
sc
=
ligand_scoring_scrmsd
.
SCRMSDScorer
(
mdl
.
Select
(
"
protein=True
"
),
trg
.
Select
(
"
protein=True
"
),
model_ligands
=
[
mdl_g3d
],
target_ligands
=
[
trg_g3d1_sub
],
substructure_match
=
True
)
self
.
assertEqual
(
sc
.
coverage_matrix
.
shape
,
(
1
,
1
))
self
.
assertEqual
(
sc
.
coverage_matrix
[
0
,
0
],
0.75
)
self
.
assertEqual
(
sc
.
states_matrix
[
0
,
0
],
0
)
# no error encoded in state
def
test_6jyf
(
self
):
"""
6JYF initially caused issues in the CASP15-CAMEO/LIGATE paper where
the ligand RET was wrongly assigned to short copies of OLA that float
around and yielded higher scores.
Here we test that this is resolved correctly.
"""
mdl
=
_LoadPDB
(
"
6jyf_mdl.pdb
"
)
trg
=
_LoadMMCIF
(
"
6jyf_trg.cif
"
)
mdl_lig
=
_LoadEntity
(
"
6jyf_RET_pred.sdf
"
)
mdl_lig_full
=
_LoadEntity
(
"
6jyf_RET_pred_complete.sdf
"
)
# Problem is easily fixed by just prioritizing full coverage
sc
=
ligand_scoring_scrmsd
.
SCRMSDScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig
],
substructure_match
=
True
)
self
.
assertEqual
(
len
(
sc
.
assignment
),
1
)
# only one mdl ligand => 1 assignment
trg_lig_idx
,
mdl_lig_idx
=
sc
.
assignment
[
0
]
self
.
assertEqual
(
sc
.
coverage_matrix
[
trg_lig_idx
,
mdl_lig_idx
],
1.0
)
self
.
assertEqual
(
sc
.
aux
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
RET
"
)
self
.
assertAlmostEqual
(
sc
.
score
[
'
00001_
'
][
1
],
15.56022
,
4
)
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
0
,
0
],
1.
)
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
1
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
2
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
3
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
4
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
5
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
6
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
7
,
0
]))
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
8
,
0
],
0.5
)
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
9
,
0
],
0.3
)
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
10
,
0
],
0.45
)
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
11
,
0
]))
self
.
assertTrue
(
np
.
isnan
(
sc
.
coverage_matrix
[
12
,
0
]))
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
13
,
0
],
0.55
)
# We need to make sure that it also works if the match is partial.
# For that we load the complete ligand incl. the O missing in target
# with a coverage of around 95% only.
sc
=
ligand_scoring_scrmsd
.
SCRMSDScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig_full
],
substructure_match
=
True
)
self
.
assertEqual
(
len
(
sc
.
assignment
),
1
)
# only one mdl ligand => 1 assignment
trg_lig_idx
,
mdl_lig_idx
=
sc
.
assignment
[
0
]
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
trg_lig_idx
,
mdl_lig_idx
],
0.95238096
)
self
.
assertEqual
(
sc
.
aux
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
RET
"
)
self
.
assertAlmostEqual
(
sc
.
score
[
'
00001_
'
][
1
],
15.56022
,
4
)
# Next, we check that coverage_delta has an effect. With a large
# delta of 0.5 we will assign to OLA which has a higher RMSD
# but a coverage of 0.52 only.
sc
=
ligand_scoring_scrmsd
.
SCRMSDScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig_full
],
substructure_match
=
True
,
coverage_delta
=
0.5
)
self
.
assertEqual
(
len
(
sc
.
assignment
),
1
)
# only one mdl ligand => 1 assignment
trg_lig_idx
,
mdl_lig_idx
=
sc
.
assignment
[
0
]
self
.
assertAlmostEqual
(
sc
.
coverage_matrix
[
trg_lig_idx
,
mdl_lig_idx
],
0.52380955
)
self
.
assertEqual
(
sc
.
aux
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
OLA
"
)
self
.
assertAlmostEqual
(
sc
.
score
[
'
00001_
'
][
1
],
6.13006878
,
4
)
if
__name__
==
"
__main__
"
:
...
...
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