Skip to content
Snippets Groups Projects
Commit 3d4c5b86 authored by juergen's avatar juergen
Browse files

adding initial version of python unit test for seq

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2243 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent cbc1e740
Branches
Tags
No related merge requests found
......@@ -67,8 +67,8 @@ def ViewsFromSequences(seq_a, seq_b, ent_a=None, ent_b=None,
#~ print seq_ent_a
#~ print s1
#~ print seq_ent_a
#~ print s1
#~ print seq_ent_b
#~ print s2
off_a = seq_ent_a.index(s1)
off_b = seq_ent_b.index(s2)
......@@ -84,32 +84,34 @@ def ViewsFromSequences(seq_a, seq_b, ent_a=None, ent_b=None,
# iterate over residues
while index_a<seq_a.GetLength() and index_b<seq_b.GetLength():
# print 'index',index_a, seq_a.GetLength(), index_b, seq_b.GetLength()
while seq_a.GetOneLetterCode(index_a)=='-':
while seq_a.GetOneLetterCode(index_a)=='-':
index_a+=1
if seq_a.GetLength()<index_a:
done=True
break
while seq_b.GetOneLetterCode(index_b)=='-':
while seq_b.GetOneLetterCode(index_b)=='-':
index_b+=1
if seq_b.GetLength()<index_b:
done=True
break
if done or len(res_a)<=off_a+index_b or len(res_b)<=off_b+index_a:
if done or len(res_a)<=off_a+index_b or len(res_b)<=off_b+index_a:
break
ra=res_a[off_a+index_b]
rb=res_b[off_b+index_a]
#ra = res_a[index_b]
#rb = res_a[index_a]
#~ print "set align_index %d for %s %s" % (align_index, ra, rb)
#ra.SetIntProp("align_index",align_index)
#rb.SetIntProp("align_index",align_index)
align_index += 1
ev_a.AddResidue(is_ha and ra or ra.handle, flags)
ev_b.AddResidue(is_hb and rb or rb.handle, flags)
index_a+=1
index_b+=1
eda=ev_a.handle.RequestXCSEditor()
eda.RenameChain(ent_a.chains[0].handle,ent_a.chains[0].name)
edb=ev_b.handle.RequestXCSEditor()
edb.RenameChain(ent_b.chains[0].handle, ent_b.chains[0].name)
ra=res_a[off_a+index_b]
rb=res_b[off_b+index_a]
#ra = res_a[index_b]
#rb = res_a[index_a]
#~ print "set align_index %d for %s %s" % (align_index, ra, rb)
#ra.SetIntProp("align_index",align_index)
#rb.SetIntProp("align_index",align_index)
align_index += 1
ev_a.AddResidue(is_ha and ra or ra.handle, flags)
ev_b.AddResidue(is_hb and rb or rb.handle, flags)
index_a+=1
index_b+=1
if (ent_a.chains[0].name!=ev_a.chains[0].name):
eda=ev_a.handle.RequestXCSEditor()
eda.RenameChain(ent_a.chains[0].handle,ent_a.chains[0].name)
if (ent_b.chains[0].name!=ev_b.chains[0].name):
edb=ev_b.handle.RequestXCSEditor()
edb.RenameChain(ent_b.chains[0].handle, ent_b.chains[0].name)
return ev_a, ev_b
set(OST_SEQ_UNIT_TESTS
test_seq.py
test_sequence.cc
test_aligned_column.cc
test_aligned_region.cc
......
import unittest
from ost import *
from ost import settings
from ost import seq
class TestSeq(unittest.TestCase):
def setUp(self):
self.protein = io.LoadEntity("testfiles/testprotein.pdb")
c=self.protein.chains[0]
self.seq_a=seq.SequenceFromChain('0',c) # MRLDGKTALITGSAR
self.seq_a.AttachView(self.protein.Select('aname==CA'))
self.seq_b=seq.CreateSequence('1','---DGKTALITGSAR')
self.seq_b.AttachView(self.protein.Select('aname==CA'))
self.seq_c=seq.CreateSequence('2','MRLDG---LITGSAR')
self.seq_c.AttachView(self.protein.Select('aname==CA'))
self.seq_d=seq.CreateSequence('3','MRLDG----ITGSAR')
self.seq_d.AttachView(self.protein.Select('aname==CA'))
self.seq_e=seq.CreateSequence('4','AMRLDG----ITGSA')
self.seq_e.AttachView(self.protein.Select('aname==CA'))
self.seq_e.SetSequenceOffset(1)
def testViewsFromSequencesGapFrontSeqB(self):
#~ MRLDGKTALITGSAR
#~ ---DGKTALITGSAR
[a,b]=seq.ViewsFromSequences(self.seq_a,
self.seq_b,
self.seq_a.GetAttachedView(),
self.seq_b.GetAttachedView())
assert(a.atoms[0].GetResidue().GetOneLetterCode()=='D');
assert(b.atoms[0].GetResidue().GetOneLetterCode()=='D');
#~ self.seq_b.GetResidue(j.GetResidue().GetIndex()).GetOneLetterCode());
def testViewsFromSequencesGapMiddleBoth(self):
#~ MRLDG---LITGSAR
#~ MRLDG----ITGSAR
[a,b]=seq.ViewsFromSequences(self.seq_c,
self.seq_d,
self.seq_c.GetAttachedView(),
self.seq_d.GetAttachedView())
print 'aaa'+a.atoms[4].name+'aaaa'
assert(a.atoms[0].GetResidue().GetOneLetterCode()=='M');
assert(b.atoms[0].GetResidue().GetOneLetterCode()=='M');
assert(a.atoms[4].GetResidue().GetOneLetterCode()=='I');
assert(b.atoms[4].GetResidue().GetOneLetterCode()=='I');
#~ self.seq_b.GetResidue(j.GetResidue().GetIndex()).GetOneLetterCode());
def testViewsFromSequencesGapSeqOffset(self):
#~ MRLDGKTALITGSAR
#~ AMRLDG----ITGSA
[a,b]=seq.ViewsFromSequences(self.seq_a,
self.seq_e,
self.seq_a.GetAttachedView(),
self.seq_e.GetAttachedView())
assert(a.atoms[0].GetResidue().GetOneLetterCode()=='M');
assert(b.atoms[0].GetResidue().GetOneLetterCode()=='M');
assert(a.atoms[5].GetResidue().GetOneLetterCode()=='I');
assert(b.atoms[5].GetResidue().GetOneLetterCode()=='I');
#~ self.seq_b.GetResidue(j.GetResidue().GetIndex()).GetOneLetterCode());
if __name__ == "__main__":
# test if python extension for seq module work
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment