3 from testlib
import testutil
, PygrTestProgram
4 from pygr
import translationDB
, seqdb
6 class TranslationDB_Test(unittest
.TestCase
):
8 hbb1_mouse
= testutil
.datafile('hbb1_mouse.fa')
9 self
.dna
= seqdb
.SequenceFileDB(hbb1_mouse
)
10 self
.tdb
= translationDB
.get_translation_db(self
.dna
)
12 def test_basic_slice(self
):
13 id = 'gi|171854975|dbj|AB364477.1|'
14 tseq
= self
.tdb
[id][0:99]
15 assert str(tseq
)[0:10] == 'MVHLTDAEKA'
17 tseq
= self
.tdb
[id][1:100]
18 assert str(tseq
)[0:10] == 'WCT*LMLRRL'
20 def test_slice_empty_stop(self
):
21 id = 'gi|171854975|dbj|AB364477.1|'
22 tseq
= self
.tdb
[id][0:]
23 assert str(tseq
)[0:10] == 'MVHLTDAEKA'
25 tseq
= self
.tdb
[id][1:]
26 assert str(tseq
)[0:10] == 'WCT*LMLRRL'
28 def test_slice_empty_start(self
):
29 id = 'gi|171854975|dbj|AB364477.1|'
30 tseq
= self
.tdb
[id][:99]
31 assert str(tseq
)[0:10] == 'MVHLTDAEKA'
33 def test_repr_ne(self
):
35 Make sure there's some way to distinguish translated seqs from
38 id = 'gi|171854975|dbj|AB364477.1|'
43 assert repr(seq
) != repr(tseq
)
45 def test_invalid_annodb_key_str(self
):
47 The invalid key should be mentioned in the KeyError...
50 self
.tdb
.annodb
['fooBar']
51 assert 0, "should not reach this point"
53 assert 'fooBar' in str(e
)
55 if __name__
== '__main__':
56 PygrTestProgram(verbosity
=2)