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
f7b42cf3
Verified
Commit
f7b42cf3
authored
Jul 26, 2023
by
Xavier Robin
Browse files
Options
Downloads
Patches
Plain Diff
fix: SCHWED-5954 report no ligands instead of raising an error
parent
c310c586
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/mol/alg/pymod/ligand_scoring.py
+18
-2
18 additions, 2 deletions
modules/mol/alg/pymod/ligand_scoring.py
modules/mol/alg/tests/test_ligand_scoring.py
+24
-0
24 additions, 0 deletions
modules/mol/alg/tests/test_ligand_scoring.py
with
42 additions
and
2 deletions
modules/mol/alg/pymod/ligand_scoring.py
+
18
−
2
View file @
f7b42cf3
...
...
@@ -265,7 +265,7 @@ class LigandScorer:
target_ligands
,
rename_ligand_chain
)
if
len
(
self
.
target_ligands
)
==
0
:
raise
ValueError
(
"
No ligands in the target
"
)
LogWarning
(
"
No ligands in the target
"
)
# Extract ligands from model
if
model_ligands
is
None
:
...
...
@@ -275,7 +275,9 @@ class LigandScorer:
model_ligands
,
rename_ligand_chain
)
if
len
(
self
.
model_ligands
)
==
0
:
raise
ValueError
(
"
No ligands in the model
"
)
LogWarning
(
"
No ligands in the model
"
)
if
len
(
self
.
target_ligands
)
==
0
:
raise
ValueError
(
"
No ligand in the model and in the target
"
)
self
.
_chain_mapper
=
chain_mapper
self
.
resnum_alignments
=
resnum_alignments
...
...
@@ -764,6 +766,10 @@ class LigandScorer:
else
:
mat2
=
np
.
copy
(
mat2
)
assignments
=
[]
if
0
in
mat1
.
shape
:
# No model or target ligand
LogDebug
(
"
No model or target ligand, returning no assignment.
"
)
return
assignments
min_mat1
=
LigandScorer
.
_nanmin_nowarn
(
mat1
)
while
not
np
.
isnan
(
min_mat1
):
best_mat1
=
np
.
argwhere
(
mat1
==
min_mat1
)
...
...
@@ -1252,6 +1258,7 @@ class LigandScorer:
Currently, the following reasons are reported:
* `no_ligand`: No ligand in the model.
* `binding_site`: no residue in proximity of the target ligand.
* `model_representation`: no representation of the reference binding
site was found in the model
...
...
@@ -1284,6 +1291,7 @@ class LigandScorer:
Currently, the following reasons are reported:
* `no_ligand`: No ligand in the target.
* `binding_site`: no residue in proximity of the target ligand.
* `model_representation`: no representation of the reference binding
site was found in the model
...
...
@@ -1413,6 +1421,10 @@ class LigandScorer:
if
not
(
"
unassigned
"
in
ligand_details
and
ligand_details
[
"
unassigned
"
]):
raise
RuntimeError
(
"
Ligand %s is mapped to %s
"
%
(
ligand
,
ligand_details
[
"
target_ligand
"
]))
# Were there any ligands in the target?
if
len
(
self
.
target_ligands
)
==
0
:
return
(
"
no_ligand
"
,
"
No ligand in the target
"
)
# Do we have isomorphisms with the target?
for
trg_lig_idx
,
assigned
in
enumerate
(
self
.
_assignment_isomorphisms
[:,
ligand_idx
]):
if
np
.
isnan
(
assigned
):
...
...
@@ -1465,6 +1477,10 @@ class LigandScorer:
raise
RuntimeError
(
"
Ligand %s is mapped to %s.%s
"
%
(
ligand
,
cname
,
rnum
))
# Were there any ligands in the model?
if
len
(
self
.
model_ligands
)
==
0
:
return
(
"
no_ligand
"
,
"
No ligand in the model
"
)
# Is it because there was no valid binding site or no representation?
if
ligand
in
self
.
_unassigned_target_ligands_reason
:
return
self
.
_unassigned_target_ligands_reason
[
ligand
]
...
...
This diff is collapsed.
Click to expand it.
modules/mol/alg/tests/test_ligand_scoring.py
+
24
−
0
View file @
f7b42cf3
...
...
@@ -568,6 +568,30 @@ class TestLigandScoring(unittest.TestCase):
}
assert
sc
.
lddt_pli
[
"
L_OXY
"
][
1
]
is
None
# With missing ligands
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
,
None
,
None
)
assert
sc
.
unassigned_target_ligands
[
"
E
"
][
1
]
==
(
'
no_ligand
'
,
'
No ligand in the model
'
)
sc
=
LigandScorer
(
mdl
,
trg
.
Select
(
"
cname=A
"
),
None
,
None
)
assert
sc
.
unassigned_model_ligands
[
"
L_2
"
][
1
]
==
(
'
no_ligand
'
,
'
No ligand in the target
'
)
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
,
None
,
None
,
unassigned
=
True
,
rmsd_assignment
=
True
)
assert
sc
.
unassigned_target_ligands
[
"
E
"
][
1
]
==
(
'
no_ligand
'
,
'
No ligand in the model
'
)
sc
=
LigandScorer
(
mdl
,
trg
.
Select
(
"
cname=A
"
),
None
,
None
,
unassigned
=
True
,
rmsd_assignment
=
True
)
assert
sc
.
unassigned_model_ligands
[
"
L_2
"
][
1
]
==
(
'
no_ligand
'
,
'
No ligand in the target
'
)
# However not everything must be missing
with
self
.
assertRaises
(
ValueError
):
sc
=
LigandScorer
(
mdl
.
Select
(
"
cname=A
"
),
trg
.
Select
(
"
cname=A
"
),
None
,
None
,
unassigned
=
True
,
rmsd_assignment
=
True
)
if
__name__
==
"
__main__
"
:
from
ost
import
testutils
...
...
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