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
77efa561
Commit
77efa561
authored
2 years ago
by
Studer Gabriel
Browse files
Options
Downloads
Patches
Plain Diff
scoring: Adapt Scorer to reduced restrictions on rnums in chain mapping
parent
38ec67a7
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/scoring.py
+28
-16
28 additions, 16 deletions
modules/mol/alg/pymod/scoring.py
modules/mol/alg/tests/test_chain_mapping.py
+4
-2
4 additions, 2 deletions
modules/mol/alg/tests/test_chain_mapping.py
with
32 additions
and
18 deletions
modules/mol/alg/pymod/scoring.py
+
28
−
16
View file @
77efa561
...
...
@@ -144,27 +144,39 @@ class Scorer:
for
ch
in
self
.
_model
.
chains
:
if
ch
.
GetName
().
strip
()
==
""
:
raise
RuntimeError
(
"
Model chains must have valid chain names
"
)
# catch models with residue numbers that are not strictly increasing
# (requirement of ChainMapper)
for
ch
in
self
.
_model
.
chains
:
nums
=
[
r
.
GetNumber
().
GetNum
()
for
r
in
ch
.
residues
]
if
not
all
(
i
<
j
for
i
,
j
in
zip
(
nums
,
nums
[
1
:])):
raise
RuntimeError
(
"
Residue numbers in each model chain must
"
"
be strictly increasing
"
)
# catch targets which have empty chain names
for
ch
in
self
.
_target
.
chains
:
if
ch
.
GetName
().
strip
()
==
""
:
raise
RuntimeError
(
"
Target chains must have valid chain names
"
)
# catch targets with residue numbers that are not strictly increasing
# (requirement of ChainMapper)
for
ch
in
self
.
_target
.
chains
:
nums
=
[
r
.
GetNumber
().
GetNum
()
for
r
in
ch
.
residues
]
if
not
all
(
i
<
j
for
i
,
j
in
zip
(
nums
,
nums
[
1
:])):
raise
RuntimeError
(
"
Residue numbers in each target chain must
"
"
be strictly increasing
"
)
if
resnum_alignments
:
# In case of resnum_alignments, we have some requirements on
# residue numbers in the chain mapping: 1) no ins codes 2) strictly
# increasing residue numbers.
for
ch
in
self
.
_model
.
chains
:
ins_codes
=
[
r
.
GetNumber
().
GetInsCode
()
for
r
in
ch
.
residues
]
if
len
(
set
(
ins_codes
))
!=
1
or
ins_codes
[
0
]
!=
'
\0
'
:
raise
RuntimeError
(
"
Residue numbers in each model chain
"
"
must not contain insertion codes if
"
"
resnum_alignments are enabled
"
)
nums
=
[
r
.
GetNumber
().
GetNum
()
for
r
in
ch
.
residues
]
if
not
all
(
i
<
j
for
i
,
j
in
zip
(
nums
,
nums
[
1
:])):
raise
RuntimeError
(
"
Residue numbers in each model chain
"
"
must be strictly increasing if
"
"
resnum_alignments are enabled
"
)
for
ch
in
self
.
_target
.
chains
:
ins_codes
=
[
r
.
GetNumber
().
GetInsCode
()
for
r
in
ch
.
residues
]
if
len
(
set
(
ins_codes
))
!=
1
or
ins_codes
[
0
]
!=
'
\0
'
:
raise
RuntimeError
(
"
Residue numbers in each target chain
"
"
must not contain insertion codes if
"
"
resnum_alignments are enabled
"
)
nums
=
[
r
.
GetNumber
().
GetNum
()
for
r
in
ch
.
residues
]
if
not
all
(
i
<
j
for
i
,
j
in
zip
(
nums
,
nums
[
1
:])):
raise
RuntimeError
(
"
Residue numbers in each target chain
"
"
must be strictly increasing if
"
"
resnum_alignments are enabled
"
)
if
molck_settings
is
None
:
molck_settings
=
MolckSettings
(
rm_unk_atoms
=
True
,
...
...
This diff is collapsed.
Click to expand it.
modules/mol/alg/tests/test_chain_mapping.py
+
4
−
2
View file @
77efa561
...
...
@@ -118,18 +118,20 @@ class TestChainMapper(unittest.TestCase):
self
.
assertTrue
(
_CompareViews
(
mapper
.
chem_group_alignments
[
2
].
GetSequence
(
0
).
GetAttachedView
(),
nuc_view_two
))
# ensure that error is triggered if there are insertion codes
# and resnum_alignments are enabled
tmp_ent
=
ent
.
Copy
()
ed
=
tmp_ent
.
EditXCS
()
r
=
tmp_ent
.
residues
[
0
]
ed
.
SetResidueNumber
(
r
,
mol
.
ResNum
(
r
.
GetNumber
().
GetNum
(),
'
A
'
))
self
.
assertRaises
(
Exception
,
ChainMapper
,
tmp_ent
)
self
.
assertRaises
(
Exception
,
ChainMapper
,
tmp_ent
,
resnum_alignments
=
True
)
# ensure that error is triggered if resnums are not strictly increasing
# and resnum_alignments are enabled
tmp_ent
=
ent
.
Copy
()
ed
=
tmp_ent
.
EditXCS
()
r
=
tmp_ent
.
residues
[
0
]
ed
.
SetResidueNumber
(
r
,
mol
.
ResNum
(
r
.
GetNumber
().
GetNum
()
+
42
))
self
.
assertRaises
(
Exception
,
ChainMapper
,
tmp_ent
)
self
.
assertRaises
(
Exception
,
ChainMapper
,
tmp_ent
,
resnum_alignments
=
True
)
# chain B has a missing Valine... set pep_gap_thr to 0.0 should give an
# additional chem group
...
...
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