-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_dnaseq.py
36 lines (31 loc) · 1.11 KB
/
test_dnaseq.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from dnaseq import *
### Testing ###
class TestRollingHash(unittest.TestCase):
def test_rolling(self):
rh1 = RollingHash('CTAGC')
rh2 = RollingHash('TAGCG')
rh3 = RollingHash('AGCGT')
rh1.slide('C','G')
self.assertTrue(rh1.current_hash() == rh2.current_hash())
rh1.slide('T','T')
self.assertTrue(rh1.current_hash() == rh3.current_hash())
class TestMultidict(unittest.TestCase):
def test_multi(self):
foo = Multidict()
foo.put(1, 'a')
foo.put(2, 'b')
foo.put(1, 'c')
self.assertTrue(foo.get(1) == ['a','c'])
self.assertTrue(foo.get(2) == ['b'])
self.assertTrue(foo.get(3) == [])
# This test case may break once you add the argument m (skipping).
class TestExactSubmatches(unittest.TestCase):
def test_one(self):
foo = 'yabcabcabcz'
bar = 'xxabcxxxx'
matches = list(getExactSubmatches(iter(foo), iter(bar), 3, 1))
correct = [(1,2), (4,2), (7,2)]
self.assertTrue(len(matches) == len(correct))
for x in correct:
self.assertTrue(x in matches)
unittest.main()