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
6d099003
Unverified
Commit
6d099003
authored
1 year ago
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
test: refactor asserts
parent
e4883f46
Branches
Branches containing commit
Tags
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.py
+81
-81
81 additions, 81 deletions
modules/mol/alg/tests/test_ligand_scoring.py
with
81 additions
and
81 deletions
modules/mol/alg/tests/test_ligand_scoring.py
+
81
−
81
View file @
6d099003
...
@@ -51,10 +51,10 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -51,10 +51,10 @@ class TestLigandScoring(unittest.TestCase):
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
)
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
)
assert
len
(
sc
.
target_ligands
)
==
7
self
.
assert
Equal
(
len
(
sc
.
target_ligands
)
,
7
)
assert
len
(
sc
.
model_ligands
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model_ligands
)
,
1
)
assert
len
([
r
for
r
in
sc
.
target
.
residues
if
r
.
is_ligand
])
==
7
self
.
assert
Equal
(
len
([
r
for
r
in
sc
.
target
.
residues
if
r
.
is_ligand
])
,
7
)
assert
len
([
r
for
r
in
sc
.
model
.
residues
if
r
.
is_ligand
])
==
1
self
.
assert
Equal
(
len
([
r
for
r
in
sc
.
model
.
residues
if
r
.
is_ligand
])
,
1
)
def
test_init_given_ligands
(
self
):
def
test_init_given_ligands
(
self
):
"""
Test that we can instantiate the scorer with ligands contained in
"""
Test that we can instantiate the scorer with ligands contained in
...
@@ -68,29 +68,29 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -68,29 +68,29 @@ class TestLigandScoring(unittest.TestCase):
mdl_lig
=
[
mdl
.
Select
(
"
rname=G3D
"
)]
mdl_lig
=
[
mdl
.
Select
(
"
rname=G3D
"
)]
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_lig
,
trg_lig
)
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_lig
,
trg_lig
)
assert
len
(
sc
.
target_ligands
)
==
4
self
.
assert
Equal
(
len
(
sc
.
target_ligands
)
,
4
)
assert
len
(
sc
.
model_ligands
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model_ligands
)
,
1
)
# IsLigand flag should still be set even on not selected ligands
# IsLigand flag should still be set even on not selected ligands
assert
len
([
r
for
r
in
sc
.
target
.
residues
if
r
.
is_ligand
])
==
7
self
.
assert
Equal
(
len
([
r
for
r
in
sc
.
target
.
residues
if
r
.
is_ligand
])
,
7
)
assert
len
([
r
for
r
in
sc
.
model
.
residues
if
r
.
is_ligand
])
==
1
self
.
assert
Equal
(
len
([
r
for
r
in
sc
.
model
.
residues
if
r
.
is_ligand
])
,
1
)
# Ensure the residues are not copied
# Ensure the residues are not copied
assert
len
(
sc
.
target
.
Select
(
"
rname=MG
"
).
residues
)
==
2
self
.
assert
Equal
(
len
(
sc
.
target
.
Select
(
"
rname=MG
"
).
residues
)
,
2
)
assert
len
(
sc
.
target
.
Select
(
"
rname=G3D
"
).
residues
)
==
2
self
.
assert
Equal
(
len
(
sc
.
target
.
Select
(
"
rname=G3D
"
).
residues
)
,
2
)
assert
len
(
sc
.
model
.
Select
(
"
rname=G3D
"
).
residues
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model
.
Select
(
"
rname=G3D
"
).
residues
)
,
1
)
# Pass residue handles
# Pass residue handles
trg_lig
=
[
trg
.
FindResidue
(
"
F
"
,
1
),
trg
.
FindResidue
(
"
H
"
,
1
)]
trg_lig
=
[
trg
.
FindResidue
(
"
F
"
,
1
),
trg
.
FindResidue
(
"
H
"
,
1
)]
mdl_lig
=
[
mdl
.
FindResidue
(
"
L_2
"
,
1
)]
mdl_lig
=
[
mdl
.
FindResidue
(
"
L_2
"
,
1
)]
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_lig
,
trg_lig
)
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_lig
,
trg_lig
)
assert
len
(
sc
.
target_ligands
)
==
2
self
.
assert
Equal
(
len
(
sc
.
target_ligands
)
,
2
)
assert
len
(
sc
.
model_ligands
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model_ligands
)
,
1
)
# Ensure the residues are not copied
# Ensure the residues are not copied
assert
len
(
sc
.
target
.
Select
(
"
rname=ZN
"
).
residues
)
==
1
self
.
assert
Equal
(
len
(
sc
.
target
.
Select
(
"
rname=ZN
"
).
residues
)
,
1
)
assert
len
(
sc
.
target
.
Select
(
"
rname=G3D
"
).
residues
)
==
2
self
.
assert
Equal
(
len
(
sc
.
target
.
Select
(
"
rname=G3D
"
).
residues
)
,
2
)
assert
len
(
sc
.
model
.
Select
(
"
rname=G3D
"
).
residues
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model
.
Select
(
"
rname=G3D
"
).
residues
)
,
1
)
def
test_init_sdf_ligands
(
self
):
def
test_init_sdf_ligands
(
self
):
"""
Test that we can instantiate the scorer with ligands from separate SDF files.
"""
Test that we can instantiate the scorer with ligands from separate SDF files.
...
@@ -116,11 +116,11 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -116,11 +116,11 @@ class TestLigandScoring(unittest.TestCase):
# Pass entities
# Pass entities
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_ligs
,
trg_ligs
)
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_ligs
,
trg_ligs
)
assert
len
(
sc
.
target_ligands
)
==
7
self
.
assert
Equal
(
len
(
sc
.
target_ligands
)
,
7
)
assert
len
(
sc
.
model_ligands
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model_ligands
)
,
1
)
# Ensure we set the is_ligand flag
# Ensure we set the is_ligand flag
assert
len
([
r
for
r
in
sc
.
target
.
residues
if
r
.
is_ligand
])
==
7
self
.
assert
Equal
(
len
([
r
for
r
in
sc
.
target
.
residues
if
r
.
is_ligand
])
,
7
)
assert
len
([
r
for
r
in
sc
.
model
.
residues
if
r
.
is_ligand
])
==
1
self
.
assert
Equal
(
len
([
r
for
r
in
sc
.
model
.
residues
if
r
.
is_ligand
])
,
1
)
# Pass residues
# Pass residues
mdl_ligs_res
=
[
mdl_ligs
[
0
].
residues
[
0
]]
mdl_ligs_res
=
[
mdl_ligs
[
0
].
residues
[
0
]]
...
@@ -128,8 +128,8 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -128,8 +128,8 @@ class TestLigandScoring(unittest.TestCase):
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_ligs_res
,
trg_ligs_res
)
sc
=
LigandScorer
(
mdl
,
trg
,
mdl_ligs_res
,
trg_ligs_res
)
assert
len
(
sc
.
target_ligands
)
==
7
self
.
assert
Equal
(
len
(
sc
.
target_ligands
)
,
7
)
assert
len
(
sc
.
model_ligands
)
==
1
self
.
assert
Equal
(
len
(
sc
.
model_ligands
)
,
1
)
def
test_init_reject_duplicate_ligands
(
self
):
def
test_init_reject_duplicate_ligands
(
self
):
"""
Test that we reject input if multiple ligands with the same chain
"""
Test that we reject input if multiple ligands with the same chain
...
@@ -159,16 +159,16 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -159,16 +159,16 @@ class TestLigandScoring(unittest.TestCase):
mdl_lig
=
_LoadEntity
(
"
P84080_model_02_ligand_0.sdf
"
)
mdl_lig
=
_LoadEntity
(
"
P84080_model_02_ligand_0.sdf
"
)
graph
=
ligand_scoring
.
_ResidueToGraph
(
mdl_lig
.
residues
[
0
])
graph
=
ligand_scoring
.
_ResidueToGraph
(
mdl_lig
.
residues
[
0
])
assert
len
(
graph
.
edges
)
==
34
self
.
assert
Equal
(
len
(
graph
.
edges
)
,
34
)
assert
len
(
graph
.
nodes
)
==
32
self
.
assert
Equal
(
len
(
graph
.
nodes
)
,
32
)
# Check an arbitrary node
# Check an arbitrary node
assert
[
a
for
a
in
graph
.
adj
[
"
14
"
].
keys
()]
==
[
"
13
"
,
"
29
"
]
self
.
assert
Equal
(
[
a
for
a
in
graph
.
adj
[
"
14
"
].
keys
()]
,
[
"
13
"
,
"
29
"
]
)
graph
=
ligand_scoring
.
_ResidueToGraph
(
mdl_lig
.
residues
[
0
],
by_atom_index
=
True
)
graph
=
ligand_scoring
.
_ResidueToGraph
(
mdl_lig
.
residues
[
0
],
by_atom_index
=
True
)
assert
len
(
graph
.
edges
)
==
34
self
.
assert
Equal
(
len
(
graph
.
edges
)
,
34
)
assert
len
(
graph
.
nodes
)
==
32
self
.
assert
Equal
(
len
(
graph
.
nodes
)
,
32
)
# Check an arbitrary node
# Check an arbitrary node
assert
[
a
for
a
in
graph
.
adj
[
13
].
keys
()]
==
[
12
,
28
]
self
.
assert
Equal
(
[
a
for
a
in
graph
.
adj
[
13
].
keys
()]
,
[
12
,
28
]
)
def
test__ComputeSymmetries
(
self
):
def
test__ComputeSymmetries
(
self
):
"""
Test that _ComputeSymmetries works.
"""
Test that _ComputeSymmetries works.
...
@@ -183,15 +183,15 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -183,15 +183,15 @@ class TestLigandScoring(unittest.TestCase):
mdl_g3d
=
mdl
.
FindResidue
(
"
L_2
"
,
1
)
mdl_g3d
=
mdl
.
FindResidue
(
"
L_2
"
,
1
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d
,
trg_g3d1
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d
,
trg_g3d1
)
assert
len
(
sym
)
==
72
self
.
assert
Equal
(
len
(
sym
)
,
72
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d
,
trg_g3d1
,
by_atom_index
=
True
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d
,
trg_g3d1
,
by_atom_index
=
True
)
assert
len
(
sym
)
==
72
self
.
assert
Equal
(
len
(
sym
)
,
72
)
# Test that we can match ions read from SDF
# Test that we can match ions read from SDF
sdf_lig
=
_LoadEntity
(
"
1r8q_ligand_0.sdf
"
)
sdf_lig
=
_LoadEntity
(
"
1r8q_ligand_0.sdf
"
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
trg_mg1
,
sdf_lig
.
residues
[
0
],
by_atom_index
=
True
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
trg_mg1
,
sdf_lig
.
residues
[
0
],
by_atom_index
=
True
)
assert
len
(
sym
)
==
1
self
.
assert
Equal
(
len
(
sym
)
,
1
)
# Test that it works with views and only consider atoms in the view
# Test that it works with views and only consider atoms in the view
# Skip PA, PB and O[1-3]A and O[1-3]B in target and model
# Skip PA, PB and O[1-3]A and O[1-3]B in target and model
...
@@ -202,14 +202,14 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -202,14 +202,14 @@ class TestLigandScoring(unittest.TestCase):
mdl_g3d_sub
=
mdl_g3d_sub_ent
.
residues
[
0
]
mdl_g3d_sub
=
mdl_g3d_sub_ent
.
residues
[
0
]
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d_sub
,
trg_g3d1_sub
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d_sub
,
trg_g3d1_sub
)
assert
len
(
sym
)
==
6
self
.
assert
Equal
(
len
(
sym
)
,
6
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d_sub
,
trg_g3d1_sub
,
by_atom_index
=
True
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d_sub
,
trg_g3d1_sub
,
by_atom_index
=
True
)
assert
len
(
sym
)
==
6
self
.
assert
Equal
(
len
(
sym
)
,
6
)
# Substructure matches
# Substructure matches
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d
,
trg_g3d1_sub
,
substructure_match
=
True
)
sym
=
ligand_scoring
.
_ComputeSymmetries
(
mdl_g3d
,
trg_g3d1_sub
,
substructure_match
=
True
)
assert
len
(
sym
)
==
6
self
.
assert
Equal
(
len
(
sym
)
,
6
)
# Missing atoms only allowed in target, not in model
# Missing atoms only allowed in target, not in model
with
self
.
assertRaises
(
NoSymmetryError
):
with
self
.
assertRaises
(
NoSymmetryError
):
...
@@ -272,7 +272,7 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -272,7 +272,7 @@ class TestLigandScoring(unittest.TestCase):
sc
.
_compute_scores
()
sc
.
_compute_scores
()
# Check RMSD
# Check RMSD
assert
sc
.
rmsd_matrix
.
shape
==
(
7
,
1
)
self
.
assert
Equal
(
sc
.
rmsd_matrix
.
shape
,
(
7
,
1
)
)
np
.
testing
.
assert_almost_equal
(
sc
.
rmsd_matrix
,
np
.
array
(
np
.
testing
.
assert_almost_equal
(
sc
.
rmsd_matrix
,
np
.
array
(
[[
np
.
nan
],
[[
np
.
nan
],
[
0.04244993
],
[
0.04244993
],
...
@@ -372,23 +372,23 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -372,23 +372,23 @@ class TestLigandScoring(unittest.TestCase):
# Local by default
# Local by default
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
)
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
)
assert
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
A
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
A
'
:
'
A
'
}
)
assert
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
C
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
C
'
:
'
A
'
}
)
# Global
# Global
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
global_chain_mapping
=
True
)
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
global_chain_mapping
=
True
)
assert
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
C
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
C
'
:
'
A
'
}
)
assert
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
C
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
C
'
:
'
A
'
}
)
# Custom
# Custom
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
global_chain_mapping
=
True
,
custom_mapping
=
{
'
A
'
:
'
A
'
})
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
global_chain_mapping
=
True
,
custom_mapping
=
{
'
A
'
:
'
A
'
})
assert
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
A
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
A
'
:
'
A
'
}
)
assert
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
A
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
A
'
:
'
A
'
}
)
# Custom only active with global chain mapping
# Custom only active with global chain mapping
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
global_chain_mapping
=
False
,
custom_mapping
=
{
'
A
'
:
'
A
'
})
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
global_chain_mapping
=
False
,
custom_mapping
=
{
'
A
'
:
'
A
'
})
assert
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
A
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
A
'
:
'
A
'
}
)
assert
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
==
{
'
C
'
:
'
A
'
}
self
.
assert
Equal
(
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
chain_mapping
"
]
,
{
'
C
'
:
'
A
'
}
)
def
test_rmsd_assignment
(
self
):
def
test_rmsd_assignment
(
self
):
"""
Test that the RMSD-based assignment works.
"""
Test that the RMSD-based assignment works.
...
@@ -407,7 +407,7 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -407,7 +407,7 @@ class TestLigandScoring(unittest.TestCase):
# RMSD assignment forces the same assignment
# RMSD assignment forces the same assignment
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
rmsd_assignment
=
True
)
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
rmsd_assignment
=
True
)
assert
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
target_ligand
"
]
==
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
target_ligand
"
]
self
.
assert
Equal
(
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
target_ligand
"
]
,
sc
.
lddt_pli_details
[
"
L_2
"
][
1
][
"
target_ligand
"
]
)
def
test_ignore_binding_site
(
self
):
def
test_ignore_binding_site
(
self
):
"""
Test that we ignore non polymer stuff in the binding site.
"""
Test that we ignore non polymer stuff in the binding site.
...
@@ -419,7 +419,7 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -419,7 +419,7 @@ class TestLigandScoring(unittest.TestCase):
sc
=
LigandScorer
(
trg
,
trg
,
None
,
None
)
sc
=
LigandScorer
(
trg
,
trg
,
None
,
None
)
expected_bs_ref_res
=
[
'
C.GLY62
'
,
'
C.GLN63
'
,
'
C.ASP64
'
,
'
C.PRO65
'
,
'
C.TYR66
'
,
'
C.CYS76
'
,
'
C.PHE77
'
,
'
C.ASN123
'
,
'
C.HIS187
'
]
expected_bs_ref_res
=
[
'
C.GLY62
'
,
'
C.GLN63
'
,
'
C.ASP64
'
,
'
C.PRO65
'
,
'
C.TYR66
'
,
'
C.CYS76
'
,
'
C.PHE77
'
,
'
C.ASN123
'
,
'
C.HIS187
'
]
ost
.
PushVerbosityLevel
(
ost
.
LogLevel
.
Error
)
ost
.
PushVerbosityLevel
(
ost
.
LogLevel
.
Error
)
assert
[
str
(
r
)
for
r
in
sc
.
rmsd_details
[
"
D
"
][
1
][
"
bs_ref_res
"
]]
==
expected_bs_ref_res
self
.
assert
Equal
(
[
str
(
r
)
for
r
in
sc
.
rmsd_details
[
"
D
"
][
1
][
"
bs_ref_res
"
]]
,
expected_bs_ref_res
)
ost
.
PopVerbosityLevel
()
ost
.
PopVerbosityLevel
()
def
test_unassigned_reasons
(
self
):
def
test_unassigned_reasons
(
self
):
...
@@ -504,24 +504,24 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -504,24 +504,24 @@ class TestLigandScoring(unittest.TestCase):
# Check unassigned targets
# Check unassigned targets
# NA: not in contact with target
# NA: not in contact with target
trg_na
=
sc
.
target
.
FindResidue
(
"
L_NA
"
,
1
)
trg_na
=
sc
.
target
.
FindResidue
(
"
L_NA
"
,
1
)
assert
sc
.
unassigned_target_ligands
[
"
L_NA
"
][
1
]
==
"
binding_site
"
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
L_NA
"
][
1
]
,
"
binding_site
"
)
# ZN: no representation
# ZN: no representation
trg_zn
=
sc
.
target
.
FindResidue
(
"
H
"
,
1
)
trg_zn
=
sc
.
target
.
FindResidue
(
"
H
"
,
1
)
assert
sc
.
unassigned_target_ligands
[
"
H
"
][
1
]
==
"
model_representation
"
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
H
"
][
1
]
,
"
model_representation
"
)
# AFB: not identical to anything in the model
# AFB: not identical to anything in the model
trg_afb
=
sc
.
target
.
FindResidue
(
"
G
"
,
1
)
trg_afb
=
sc
.
target
.
FindResidue
(
"
G
"
,
1
)
assert
sc
.
unassigned_target_ligands
[
"
G
"
][
1
]
==
"
identity
"
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
G
"
][
1
]
,
"
identity
"
)
# F.G3D1: J.G3D1 assigned instead
# F.G3D1: J.G3D1 assigned instead
trg_fg3d1
=
sc
.
target
.
FindResidue
(
"
F
"
,
1
)
trg_fg3d1
=
sc
.
target
.
FindResidue
(
"
F
"
,
1
)
assert
sc
.
unassigned_target_ligands
[
"
F
"
][
1
]
==
"
stoichiometry
"
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
F
"
][
1
]
,
"
stoichiometry
"
)
# CMO: disconnected
# CMO: disconnected
trg_cmo1
=
sc
.
target
.
FindResidue
(
"
L_CMO
"
,
1
)
trg_cmo1
=
sc
.
target
.
FindResidue
(
"
L_CMO
"
,
1
)
assert
sc
.
unassigned_target_ligands
[
"
L_CMO
"
][
1
]
==
"
disconnected
"
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
L_CMO
"
][
1
]
,
"
disconnected
"
)
# J.G3D1: assigned to L_2.G3D1 => error
# J.G3D1: assigned to L_2.G3D1 => error
trg_jg3d1
=
sc
.
target
.
FindResidue
(
"
J
"
,
1
)
trg_jg3d1
=
sc
.
target
.
FindResidue
(
"
J
"
,
1
)
with
self
.
assertRaises
(
RuntimeError
):
with
self
.
assertRaises
(
RuntimeError
):
sc
.
_find_unassigned_target_ligand_reason
(
trg_jg3d1
)
sc
.
_find_unassigned_target_ligand_reason
(
trg_jg3d1
)
assert
"
J
"
not
in
sc
.
unassigned_target_ligands
self
.
assert
NotIn
(
"
J
"
,
sc
.
unassigned_target_ligands
)
# Raises with an invalid ligand
# Raises with an invalid ligand
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
sc
.
_find_unassigned_target_ligand_reason
(
sc
.
model_ligands
[
0
])
sc
.
_find_unassigned_target_ligand_reason
(
sc
.
model_ligands
[
0
])
...
@@ -529,28 +529,28 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -529,28 +529,28 @@ class TestLigandScoring(unittest.TestCase):
# Check unassigned models
# Check unassigned models
# OXY: not identical to anything in the model
# OXY: not identical to anything in the model
mdl_oxy
=
sc
.
model
.
FindResidue
(
"
L_OXY
"
,
1
)
mdl_oxy
=
sc
.
model
.
FindResidue
(
"
L_OXY
"
,
1
)
assert
sc
.
unassigned_model_ligands
[
"
L_OXY
"
][
1
]
==
"
identity
"
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_OXY
"
][
1
]
,
"
identity
"
)
assert
sc
.
lddt_pli
[
"
L_OXY
"
][
1
]
is
None
self
.
assert
IsNone
(
sc
.
lddt_pli
[
"
L_OXY
"
][
1
]
)
# NA: not in contact with target
# NA: not in contact with target
mdl_na
=
sc
.
model
.
FindResidue
(
"
L_NA
"
,
1
)
mdl_na
=
sc
.
model
.
FindResidue
(
"
L_NA
"
,
1
)
assert
sc
.
unassigned_model_ligands
[
"
L_NA
"
][
1
]
==
"
binding_site
"
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_NA
"
][
1
]
,
"
binding_site
"
)
assert
sc
.
lddt_pli
[
"
L_NA
"
][
1
]
is
None
self
.
assert
IsNone
(
sc
.
lddt_pli
[
"
L_NA
"
][
1
]
)
# ZN: no representation
# ZN: no representation
mdl_zn
=
sc
.
model
.
FindResidue
(
"
L_ZN
"
,
1
)
mdl_zn
=
sc
.
model
.
FindResidue
(
"
L_ZN
"
,
1
)
assert
sc
.
unassigned_model_ligands
[
"
L_ZN
"
][
1
]
==
"
model_representation
"
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_ZN
"
][
1
]
,
"
model_representation
"
)
assert
sc
.
lddt_pli
[
"
L_ZN
"
][
1
]
is
None
self
.
assert
IsNone
(
sc
.
lddt_pli
[
"
L_ZN
"
][
1
]
)
# MG in L_MG_2 has stupid coordinates and is not assigned
# MG in L_MG_2 has stupid coordinates and is not assigned
mdl_mg_2
=
sc
.
model
.
FindResidue
(
"
L_MG_2
"
,
1
)
mdl_mg_2
=
sc
.
model
.
FindResidue
(
"
L_MG_2
"
,
1
)
assert
sc
.
unassigned_model_ligands
[
"
L_MG_2
"
][
1
]
==
"
stoichiometry
"
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_MG_2
"
][
1
]
,
"
stoichiometry
"
)
assert
sc
.
lddt_pli
[
"
L_MG_2
"
][
1
]
is
None
self
.
assert
IsNone
(
sc
.
lddt_pli
[
"
L_MG_2
"
][
1
]
)
# MG in L_MG_0: assigned to I.MG1 => error
# MG in L_MG_0: assigned to I.MG1 => error
mdl_mg_0
=
sc
.
model
.
FindResidue
(
"
L_MG_0
"
,
1
)
mdl_mg_0
=
sc
.
model
.
FindResidue
(
"
L_MG_0
"
,
1
)
with
self
.
assertRaises
(
RuntimeError
):
with
self
.
assertRaises
(
RuntimeError
):
sc
.
_find_unassigned_model_ligand_reason
(
mdl_mg_0
)
sc
.
_find_unassigned_model_ligand_reason
(
mdl_mg_0
)
assert
"
L_MG_0
"
not
in
sc
.
unassigned_model_ligands
self
.
assert
NotIn
(
"
L_MG_0
"
,
sc
.
unassigned_model_ligands
)
# CMO: disconnected
# CMO: disconnected
mdl_cmo1
=
sc
.
model
.
FindResidue
(
"
L_CMO
"
,
1
)
mdl_cmo1
=
sc
.
model
.
FindResidue
(
"
L_CMO
"
,
1
)
assert
sc
.
unassigned_model_ligands
[
"
L_CMO
"
][
1
]
==
"
disconnected
"
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_CMO
"
][
1
]
,
"
disconnected
"
)
# Raises with an invalid ligand
# Raises with an invalid ligand
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
sc
.
_find_unassigned_model_ligand_reason
(
sc
.
target_ligands
[
0
])
sc
.
_find_unassigned_model_ligand_reason
(
sc
.
target_ligands
[
0
])
...
@@ -558,37 +558,37 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -558,37 +558,37 @@ class TestLigandScoring(unittest.TestCase):
# Should work with rmsd_assignment too
# Should work with rmsd_assignment too
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
unassigned
=
True
,
sc
=
LigandScorer
(
mdl
,
trg
,
None
,
None
,
unassigned
=
True
,
rmsd_assignment
=
True
)
rmsd_assignment
=
True
)
assert
sc
.
unassigned_model_ligands
==
{
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
,
{
'
L_ZN
'
:
{
1
:
'
model_representation
'
},
'
L_ZN
'
:
{
1
:
'
model_representation
'
},
'
L_NA
'
:
{
1
:
'
binding_site
'
},
'
L_NA
'
:
{
1
:
'
binding_site
'
},
'
L_OXY
'
:
{
1
:
'
identity
'
},
'
L_OXY
'
:
{
1
:
'
identity
'
},
'
L_MG_2
'
:
{
1
:
'
stoichiometry
'
},
'
L_MG_2
'
:
{
1
:
'
stoichiometry
'
},
"
L_CMO
"
:
{
1
:
'
disconnected
'
}
"
L_CMO
"
:
{
1
:
'
disconnected
'
}
}
}
)
assert
sc
.
unassigned_target_ligands
==
{
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
,
{
'
G
'
:
{
1
:
'
identity
'
},
'
G
'
:
{
1
:
'
identity
'
},
'
H
'
:
{
1
:
'
model_representation
'
},
'
H
'
:
{
1
:
'
model_representation
'
},
'
J
'
:
{
1
:
'
stoichiometry
'
},
'
J
'
:
{
1
:
'
stoichiometry
'
},
'
K
'
:
{
1
:
'
identity
'
},
'
K
'
:
{
1
:
'
identity
'
},
'
L_NA
'
:
{
1
:
'
binding_site
'
},
'
L_NA
'
:
{
1
:
'
binding_site
'
},
"
L_CMO
"
:
{
1
:
'
disconnected
'
}
"
L_CMO
"
:
{
1
:
'
disconnected
'
}
}
}
)
assert
sc
.
lddt_pli
[
"
L_OXY
"
][
1
]
is
None
self
.
assert
IsNone
(
sc
.
lddt_pli
[
"
L_OXY
"
][
1
]
)
# With missing ligands
# With missing ligands
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
,
None
,
None
)
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
,
None
,
None
)
assert
sc
.
unassigned_target_ligands
[
"
E
"
][
1
]
==
'
no_ligand
'
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
E
"
][
1
]
,
'
no_ligand
'
)
sc
=
LigandScorer
(
mdl
,
trg
.
Select
(
"
cname=A
"
),
None
,
None
)
sc
=
LigandScorer
(
mdl
,
trg
.
Select
(
"
cname=A
"
),
None
,
None
)
assert
sc
.
unassigned_model_ligands
[
"
L_2
"
][
1
]
==
'
no_ligand
'
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_2
"
][
1
]
,
'
no_ligand
'
)
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
,
None
,
None
,
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
,
None
,
None
,
unassigned
=
True
,
rmsd_assignment
=
True
)
unassigned
=
True
,
rmsd_assignment
=
True
)
assert
sc
.
unassigned_target_ligands
[
"
E
"
][
1
]
==
'
no_ligand
'
self
.
assert
Equal
(
sc
.
unassigned_target_ligands
[
"
E
"
][
1
]
,
'
no_ligand
'
)
sc
=
LigandScorer
(
mdl
,
trg
.
Select
(
"
cname=A
"
),
None
,
None
,
sc
=
LigandScorer
(
mdl
,
trg
.
Select
(
"
cname=A
"
),
None
,
None
,
unassigned
=
True
,
rmsd_assignment
=
True
)
unassigned
=
True
,
rmsd_assignment
=
True
)
assert
sc
.
unassigned_model_ligands
[
"
L_2
"
][
1
]
==
'
no_ligand
'
self
.
assert
Equal
(
sc
.
unassigned_model_ligands
[
"
L_2
"
][
1
]
,
'
no_ligand
'
)
# However not everything must be missing
# However not everything must be missing
with
self
.
assertRaises
(
ValueError
):
with
self
.
assertRaises
(
ValueError
):
...
@@ -614,7 +614,7 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -614,7 +614,7 @@ class TestLigandScoring(unittest.TestCase):
sc
=
LigandScorer
(
mdl
.
Select
(
"
protein=True
"
),
trg
.
Select
(
"
protein=True
"
),
sc
=
LigandScorer
(
mdl
.
Select
(
"
protein=True
"
),
trg
.
Select
(
"
protein=True
"
),
model_ligands
=
[
mdl_g3d
],
target_ligands
=
[
trg_g3d1_sub
],
model_ligands
=
[
mdl_g3d
],
target_ligands
=
[
trg_g3d1_sub
],
substructure_match
=
True
)
substructure_match
=
True
)
assert
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
coverage
"
]
==
0.75
self
.
assert
Equal
(
sc
.
rmsd_details
[
"
L_2
"
][
1
][
"
coverage
"
]
,
0.75
)
def
test_6jyf
(
self
):
def
test_6jyf
(
self
):
"""
6JYF initially caused issues in the CASP15-CAMEO/LIGATE paper where
"""
6JYF initially caused issues in the CASP15-CAMEO/LIGATE paper where
...
@@ -629,19 +629,19 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -629,19 +629,19 @@ class TestLigandScoring(unittest.TestCase):
# Problem is easily fixed by just prioritizing full coverage
# Problem is easily fixed by just prioritizing full coverage
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig
],
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig
],
substructure_match
=
True
)
substructure_match
=
True
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
==
1.0
self
.
assert
Equal
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
,
1.0
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
==
"
RET
"
self
.
assert
Equal
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
RET
"
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
15.56022
,
4
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
15.56022
,
4
)
assert
np
.
array_equal
(
sc
.
coverage_matrix
,
self
.
assert
True
(
np
.
array_equal
(
sc
.
coverage_matrix
,
np
.
array
([[
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0.5
,
0.3
,
0.45
,
0
,
0
,
0.55
]]).
transpose
())
np
.
array
([[
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0.5
,
0.3
,
0.45
,
0
,
0
,
0.55
]]).
transpose
())
)
# We need to make sure that it also works if the match is partial.
# 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
# For that we load the complete ligand incl. the O missing in target
# with a coverage of around 95% only.
# with a coverage of around 95% only.
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig_full
],
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig_full
],
substructure_match
=
True
)
substructure_match
=
True
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
>
0.95
self
.
assert
True
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
>
0.95
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
==
"
RET
"
self
.
assert
Equal
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
RET
"
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
15.56022
,
4
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
15.56022
,
4
)
# Next, we check that coverage_delta has an effect. With a large
# Next, we check that coverage_delta has an effect. With a large
...
@@ -650,8 +650,8 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -650,8 +650,8 @@ class TestLigandScoring(unittest.TestCase):
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig_full
],
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig_full
],
substructure_match
=
True
,
substructure_match
=
True
,
coverage_delta
=
0.5
)
coverage_delta
=
0.5
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
>
0.5
self
.
assert
True
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
>
0.5
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
==
"
OLA
"
self
.
assert
Equal
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
OLA
"
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
6.13006878
,
4
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
6.13006878
,
4
)
# Finally, we check that we still assign to the full match even with
# Finally, we check that we still assign to the full match even with
...
@@ -659,8 +659,8 @@ class TestLigandScoring(unittest.TestCase):
...
@@ -659,8 +659,8 @@ class TestLigandScoring(unittest.TestCase):
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig
],
sc
=
LigandScorer
(
mdl
,
trg
,
model_ligands
=
[
mdl_lig
],
substructure_match
=
True
,
substructure_match
=
True
,
coverage_delta
=
0.5
)
coverage_delta
=
0.5
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
==
1.0
self
.
assert
Equal
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
coverage
"
]
,
1.0
)
assert
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
==
"
RET
"
self
.
assert
Equal
(
sc
.
rmsd_details
[
'
00001_
'
][
1
][
"
target_ligand
"
].
name
,
"
RET
"
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
15.56022
,
4
)
self
.
assertAlmostEqual
(
sc
.
rmsd
[
'
00001_
'
][
1
],
15.56022
,
4
)
...
...
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