Skip to content
Snippets Groups Projects
Commit fa7a8d57 authored by Marco Biasini's avatar Marco Biasini
Browse files

added AlignmentFromChainView

parent 05b70881
No related branches found
No related tags found
No related merge requests found
:mod:`mol.alg <ost.seq.alg>` -- Algorithms for Sequences
:mod:`seq.alg <ost.seq.alg>` -- Algorithms for Sequences
================================================================================
.. currentmodule:: ost.seq.alg
......@@ -30,4 +30,6 @@
considered as aligned. There is no information in the pairwise alignment to
guide the merging, the result is undefined.
.. autofunction:: AlignToSEQRES
\ No newline at end of file
.. autofunction:: AlignToSEQRES
.. autofunction:: AlignmentFromChainView
\ No newline at end of file
......@@ -39,5 +39,40 @@ def AlignToSEQRES(chain, seqres):
return seq.CreateAlignment(seq.CreateSequence('SEQRES', str(seqres)),
seq.CreateSequence('atoms', aln_seq))
def AlignmentFromChainView(chain, handle_seq_name='handle',
view_seq_name='view'):
"""
Creates and returns the sequence alignment of the given chain view to the
chain handle. The alignment contains two sequences, the first containing all
non-ligand peptide-linking residues, the second containing all non-ligand
peptide-linking residues that are part of the view.
:param chain: A valid chain
:type chain: :class:`~ost.mol.ChainView`
:param handle_seq_name: Name of the handle sequence in the output alignment
:param view_seq_name: Name of the view sequence in the output alignment
:returns: The alignment
:rtype: :class:`~ost.seq.AlignmentHandle`
"""
from ost import seq
v0=chain.handle.Select('ligand=false and peptide=true')
v1=chain.Select('ligand=false and peptide=true')
s0=seq.CreateSequence(handle_seq_name, '')
s1=seq.CreateSequence(view_seq_name, '')
s0.AttachView(v0)
s1.AttachView(v1)
res0=v0.residues
res1=v1.residues
idx0, idx1=(0, 0)
while idx0<len(res0):
s0.Append(res0[idx0].one_letter_code)
if idx1<len(res1) and res1[idx1].handle==res0[idx0].handle:
s1.Append(res1[idx1].one_letter_code)
idx1+=1
else:
s1.Append('-')
idx0+=1
return seq.CreateAlignment(s0, s1)
......@@ -256,6 +256,7 @@ void export_sequence()
.def("SetOffset", &SequenceHandle::SetOffset)
.def("AttachView", attach_one)
.def("AttachView", attach_two)
.def("Append", &SequenceHandle::Append)
.def("SetString", &SequenceHandle::SetString)
.add_property("string",
make_function(&SequenceHandle::GetString,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment