-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
93 lines (67 loc) · 1.93 KB
/
test.py
File metadata and controls
93 lines (67 loc) · 1.93 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from assembly import SequenceAssembler
""" Test case #1: small test case from email
Test case #2: large test case from email
Test case #3: the first read contains the second read
ATTAGACCTG
AGACCT
ACCTGCC
TGCCGG
--------------
ATTAGACCTGCCGG
Test case #4: the second read contains the first read
ATTAGACCTG
ATTAGACCTGCC
GACCTGCCTGAC
TGCCTGACAGC
-------------------
ATTAGACCTGCCTGACAGC
Test case #5: the first and the second reads are equal
ATTAGACCTG
ATTAGACCTG
GACCTGCCTGAC
TGCCTGACAGC
-------------------
ATTAGACCTGCCTGACAGC
Test case #6: all reads are equal
ATTAGACCTG
ATTAGACCTG
ATTAGACCTG
ATTAGACCTG
----------
ATTAGACCTG
Test case #7: the first read can be glued to the right side
of the second read
ATTAGACCAT
GACCATTAGA
ATTAGACCGG
GACCGGATCG
----------------------
ATTAGACCATTAGACCGGATCG
"""
TESTS = [
('data/case1_input.txt', 'data/case1_output.txt'),
('data/case2_input.txt', 'data/case2_output.txt'),
('data/case3_input.txt', 'data/case3_output.txt'),
('data/case4_input.txt', 'data/case4_output.txt'),
('data/case5_input.txt', 'data/case5_output.txt'),
('data/case6_input.txt', 'data/case6_output.txt'),
('data/case7_input.txt', 'data/case7_output.txt')
]
def test_case((input_handle, output_handle)):
s = SequenceAssembler()
with open(input_handle) as data:
s.read_fasta(data)
with open(output_handle) as data:
output = data.readline().strip()
s.assemble()
if s.sequence == output:
return True
else:
return False
if __name__ == "__main__":
passed = 0
total = len(TESTS)
for i in range(total):
if test_case(TESTS[i]):
passed += 1
print "Passed {} tests out of {}.".format(passed, total)