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
ad7b23ae
Commit
ad7b23ae
authored
8 years ago
by
Gerardo Tauriello
Browse files
Options
Downloads
Patches
Plain Diff
fixed Renumber-function which was failing for the given example code
parent
e70cc686
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/seq/alg/doc/seqalg.rst
+1
-0
1 addition, 0 deletions
modules/seq/alg/doc/seqalg.rst
modules/seq/alg/pymod/renumber.py
+40
-25
40 additions, 25 deletions
modules/seq/alg/pymod/renumber.py
with
41 additions
and
25 deletions
modules/seq/alg/doc/seqalg.rst
+
1
−
0
View file @
ad7b23ae
...
...
@@ -163,6 +163,7 @@ Algorithms for Alignments
:param gap_ext: The gap extension penalty. Must be a negative number
:returns: best-scoring alignment of *seq1* and *seq2*.
.. autofunction:: ost.seq.alg.renumber.Renumber
.. _contact-prediction:
...
...
This diff is collapsed.
Click to expand it.
modules/seq/alg/pymod/renumber.py
+
40
−
25
View file @
ad7b23ae
from
ost
import
io
,
seq
,
mol
,
conop
from
ost
import
*
from
ost
import
seq
,
mol
def
_RenumberSeq
(
seq_handle
):
if
not
seq_handle
.
HasAttachedView
():
...
...
@@ -8,14 +6,13 @@ def _RenumberSeq(seq_handle):
ev
=
seq_handle
.
attached_view
.
CreateEmptyView
()
new_numbers
=
mol
.
ResNumList
()
for
pos
in
range
(
len
(
seq_handle
)):
if
seq_handle
[
pos
]
!=
'
-
'
:
r
=
seq_handle
.
GetResidue
(
pos
)
if
seq_handle
[
pos
]
!=
'
-
'
:
r
=
seq_handle
.
GetResidue
(
pos
)
if
r
.
IsValid
():
#print seq_handle[pos],r.number.num,pos+1
ev
.
AddResidue
(
r
,
mol
.
INCLUDE_ALL
)
new_numbers
.
append
(
pos
+
1
)
else
:
raise
RuntimeError
(
'
Error: renumbering failed at position %s
'
%
pos
)
raise
RuntimeError
(
'
Error: renumbering failed at position %s
'
%
pos
)
return
ev
,
new_numbers
def
_RenumberAln
(
aln
,
seq_index
):
...
...
@@ -25,44 +22,62 @@ def _RenumberAln(aln, seq_index):
ev
=
aln
.
sequences
[
seq_index
].
attached_view
.
CreateEmptyView
()
new_numbers
=
mol
.
ResNumList
()
for
col
in
aln
:
if
col
[
0
]
!=
'
-
'
and
col
[
seq_index
]
!=
'
-
'
:
if
col
[
0
]
!=
col
[
seq_index
]:
raise
RuntimeError
(
"
residue mismatch at position %d (%s vs %s) (renumbering failed)
"
%
(
counter
,
col
[
0
],
col
[
1
]))
rnum
=
aln
.
GetSequence
(
seq_index
).
GetResidueIndex
(
counter
)
r
=
aln
.
GetSequence
(
seq_index
).
GetResidue
(
counter
)
if
col
[
0
]
!=
'
-
'
and
col
[
seq_index
]
!=
'
-
'
:
if
col
[
0
]
!=
col
[
seq_index
]:
raise
RuntimeError
(
"
residue mismatch at position %d (%s vs %s)
"
\
"
(renumbering failed)
"
%
(
counter
,
col
[
0
],
col
[
seq_index
]))
rnum
=
aln
.
GetSequence
(
seq_index
).
GetResidueIndex
(
counter
)
r
=
aln
.
GetSequence
(
seq_index
).
GetResidue
(
counter
)
if
not
r
.
IsValid
():
raise
RuntimeError
(
"
invalid residue at postion %s (renumbering failed)
"
%
(
counter
))
raise
RuntimeError
(
"
invalid residue at postion %s (renumbering failed)
"
\
%
(
counter
))
ev
.
AddResidue
(
r
,
mol
.
INCLUDE_ALL
)
new_numbers
.
append
(
counter
+
1
)
counter
+=
1
counter
+=
1
return
ev
,
new_numbers
def
Renumber
(
seq_handle
,
sequence_number_with_attached_view
=
1
):
"""
Function to renumber an entity according to an alignment between the model sequence
and the full-length target sequence. The aligned model sequence or the alignment itself
with an attached view needs to be provided. Upon succcess, the renumbered entity is returned.
Function to renumber an entity according to an alignment between the model
sequence and the full-length target sequence. The aligned model sequence or
the alignment itself with an attached view needs to be provided. Upon
succcess, the renumbered entity is returned.
If an alignment is given, the sequence must
.. code-block:: python
from ost.seq.alg import renumber
from ost.bindings.clustalw import *
ent
=
io.LoadPDB(
"
path_to_model
"
)
s
=
io.LoadSequence(
"
path_to_full_length_fasta_seqeunce
"
)
pdb_seq
=
seq.SequenceFromChain(
"
model
"
, ent.chains[0])
aln
=
ClustalW(s,pdb_seq)
aln.AttachView(1,ent.chains[0].Select(
""
))
e
=
Renumber(aln.
GetS
equence
(sequence_number_with_attached_view)
)
ent
=
io.LoadPDB(
"
path_to_model
"
)
s
=
io.LoadSequence(
"
path_to_full_length_fasta_seqeunce
"
)
pdb_seq
=
seq.SequenceFromChain(
"
model
"
, ent.chains[0])
aln
=
ClustalW(s,
pdb_seq)
aln.AttachView(1,
ent.chains[0].Select(
""
))
e
=
Renumber(aln.
s
equence
s[1]
)
io.SavePDB(e,
"
renum.pdb
"
)
:param seq_handle: Sequence or alignment handle with attached view.
:type seq_handle: :class:`SequenceHandle` / :class:`AlignmentHandle`
:param sequence_number_with_attached_view: Sequence number for the aln. handle
(not used if seq. handle given)
:type sequence_number_with_attached_view: :class:`int`
:raises: :exc:`RuntimeError` if unknown type of *seq_handle* or if attached
view is missing or if the given alignment sequence is inconsistent.
"""
if
isinstance
(
seq_handle
,
seq
.
SequenceHandle
):
if
isinstance
(
seq_handle
,
seq
.
SequenceHandle
)
\
or
isinstance
(
seq_handle
,
seq
.
ConstSequenceHandle
):
ev
,
new_numbers
=
_RenumberSeq
(
seq_handle
)
elif
isinstance
(
seq_handle
,
seq
.
AlignmentHandle
):
ev
,
new_numbers
=
_RenumberAln
(
seq_handle
,
sequence_number_with_attached_view
)
else
:
raise
RuntimeError
(
"
Unknown input type
"
+
str
(
type
(
seq_handle
)))
ev
.
AddAllInclusiveBonds
()
new_ent
=
mol
.
CreateEntityFromView
(
ev
,
False
);
new_ent
=
mol
.
CreateEntityFromView
(
ev
,
False
);
new_ent
.
EditXCS
().
RenumberChain
(
new_ent
.
chains
[
0
],
new_numbers
)
return
new_ent
# choose visible interface
__all__
=
(
'
Renumber
'
,
)
\ No newline at end of file
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