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
2d10cb40
Commit
2d10cb40
authored
2 years ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
lDDT: avoid dependency on qsscoring.py in lddt unit tests
parent
74976b1e
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/tests/test_lddt.py
+21
-22
21 additions, 22 deletions
modules/mol/alg/tests/test_lddt.py
with
21 additions
and
22 deletions
modules/mol/alg/tests/test_lddt.py
+
21
−
22
View file @
2d10cb40
...
@@ -3,7 +3,6 @@ import ost
...
@@ -3,7 +3,6 @@ import ost
from
ost
import
io
,
mol
,
settings
,
conop
,
seq
from
ost
import
io
,
mol
,
settings
,
conop
,
seq
# check if we can import: fails if numpy or scipy not available
# check if we can import: fails if numpy or scipy not available
try
:
try
:
from
ost.mol.alg.qsscoring
import
*
from
ost.mol.alg.lddt
import
*
from
ost.mol.alg.lddt
import
*
from
ost.mol.alg.scoring
import
*
from
ost.mol.alg.scoring
import
*
except
ImportError
:
except
ImportError
:
...
@@ -79,25 +78,25 @@ class TestlDDT(unittest.TestCase):
...
@@ -79,25 +78,25 @@ class TestlDDT(unittest.TestCase):
ent_full
=
_LoadFile
(
"
4br6.1.pdb
"
)
ent_full
=
_LoadFile
(
"
4br6.1.pdb
"
)
model
=
ent_full
.
Select
(
'
peptide=true
'
)
model
=
ent_full
.
Select
(
'
peptide=true
'
)
target
=
ent_full
.
Select
(
'
peptide=true and cname=A,B
'
)
target
=
ent_full
.
Select
(
'
peptide=true and cname=A,B
'
)
#
we use functionality from QS-scorer to derive a
mapping
#
hardcoded chain
mapping
qs_scorer
=
QSscorer
(
model
,
target
)
chain_mapping
=
{
"
A
"
:
"
A
"
,
"
B
"
:
"
B
"
}
lddt_scorer
=
lDDTScorer
(
target
)
lddt_scorer
=
lDDTScorer
(
target
)
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
chain_mapping
=
qs_scorer
.
chain_mapping
)
chain_mapping
=
chain_mapping
)
self
.
assertAlmostEqual
(
score
,
1.0
,
places
=
5
)
self
.
assertAlmostEqual
(
score
,
1.0
,
places
=
5
)
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
chain_mapping
=
qs_scorer
.
chain_mapping
,
no_interchain
=
True
)
chain_mapping
=
chain_mapping
,
no_interchain
=
True
)
self
.
assertAlmostEqual
(
score
,
1.0
,
places
=
5
)
self
.
assertAlmostEqual
(
score
,
1.0
,
places
=
5
)
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
chain_mapping
=
qs_scorer
.
chain_mapping
,
no_interchain
=
False
,
chain_mapping
=
chain_mapping
,
no_interchain
=
False
,
penalize_extra_chains
=
True
)
penalize_extra_chains
=
True
)
self
.
assertAlmostEqual
(
score
,
0.52084655
,
places
=
5
)
self
.
assertAlmostEqual
(
score
,
0.52084655
,
places
=
5
)
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
chain_mapping
=
qs_scorer
.
chain_mapping
,
no_interchain
=
True
,
chain_mapping
=
chain_mapping
,
no_interchain
=
True
,
penalize_extra_chains
=
True
)
penalize_extra_chains
=
True
)
self
.
assertAlmostEqual
(
score
,
0.499570048
,
places
=
5
)
self
.
assertAlmostEqual
(
score
,
0.499570048
,
places
=
5
)
...
@@ -112,8 +111,8 @@ class TestlDDT(unittest.TestCase):
...
@@ -112,8 +111,8 @@ class TestlDDT(unittest.TestCase):
for
ch
in
model
.
chains
:
for
ch
in
model
.
chains
:
ed
.
RenumberChain
(
ch
.
handle
,
42
,
True
)
ed
.
RenumberChain
(
ch
.
handle
,
42
,
True
)
#
we use functionality from QS-scorer to derive a
mapping
#
hardcoded chain
mapping
qs_scorer
=
QSscorer
(
model
,
target
)
chain_mapping
=
{
"
A
"
:
"
A
"
,
"
B
"
:
"
B
"
}
lddt_scorer
=
lDDTScorer
(
target
)
lddt_scorer
=
lDDTScorer
(
target
)
# naively running lDDT will fail, as residue-residue mapping happens
# naively running lDDT will fail, as residue-residue mapping happens
...
@@ -121,23 +120,23 @@ class TestlDDT(unittest.TestCase):
...
@@ -121,23 +120,23 @@ class TestlDDT(unittest.TestCase):
# complaining about residue name mismatch
# complaining about residue name mismatch
with
self
.
assertRaises
(
RuntimeError
):
with
self
.
assertRaises
(
RuntimeError
):
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
chain_mapping
=
qs_scorer
.
chain_mapping
,
no_interchain
=
False
,
chain_mapping
=
chain_mapping
,
no_interchain
=
False
,
penalize_extra_chains
=
True
)
penalize_extra_chains
=
True
)
# we can rescue that with alignments
from qsscorer
# we can rescue that with alignments
res_map
=
dict
()
res_map
=
dict
()
for
aln
in
qs_scorer
.
alignments
:
for
mdl_ch_name
,
trg_ch_name
in
chain_mapping
.
items
()
:
m
ode
l_ch
ain_name
=
aln
.
GetSequence
(
0
).
GetN
ame
(
)
m
d
l_ch
=
model
.
FindChain
(
mdl_ch_n
ame
)
# we need to inverse the direction... qsscorer
trg_ch
=
target
.
FindChain
(
trg_ch_name
)
# has first model sequence and then target sequence
mdl_seq
=
''
.
join
([
r
.
one_letter_code
for
r
in
mdl_ch
.
residues
])
# (at least the way we set it up above...
)
mdl_seq
=
seq
.
CreateSequence
(
mdl_ch_name
,
mdl_seq
)
new_aln
=
seq
.
CreateAlignment
(
)
trg_seq
=
''
.
join
([
r
.
one_letter_code
for
r
in
trg_ch
.
residues
]
)
new_aln
.
AddSequence
(
aln
.
GetSequence
(
1
)
)
trg_seq
=
seq
.
CreateSequence
(
trg_ch_name
,
trg_seq
)
new_aln
.
AddSequence
(
aln
.
GetSequence
(
0
))
aln
=
seq
.
alg
.
GlobalAlign
(
trg_seq
,
mdl_seq
,
seq
.
alg
.
BLOSUM62
)[
0
]
res_map
[
m
ode
l_ch
ain
_name
]
=
new_
aln
res_map
[
m
d
l_ch_name
]
=
aln
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
score
,
per_res_scores
=
lddt_scorer
.
lDDT
(
model
,
chain_mapping
=
qs_scorer
.
chain_mapping
,
no_interchain
=
False
,
chain_mapping
=
chain_mapping
,
no_interchain
=
False
,
penalize_extra_chains
=
True
,
residue_mapping
=
res_map
)
penalize_extra_chains
=
True
,
residue_mapping
=
res_map
)
self
.
assertAlmostEqual
(
score
,
0.52084655
,
places
=
5
)
self
.
assertAlmostEqual
(
score
,
0.52084655
,
places
=
5
)
...
...
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