-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_dna.py
105 lines (78 loc) · 2.42 KB
/
test_dna.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
from dna import *
import pytest
@pytest.fixture
def gene_a():
seq = 'ATCUGΨ'
return Gene(seq)
@pytest.fixture
def gene():
seq = 'ATCUGΨATCAUGΨATCUGΨATCUGΨATCUGΨATCUG'
return Gene(seq)
def test_display_basic(gene_a):
output = gene_a.display(
split_codons=False, show_aminos=False, display=False)
print(output)
correct = ('\x1b[32;49mA\x1b[0m'
'\x1b[35;49mT\x1b[0m'
'\x1b[34;49mC\x1b[0m'
'\x1b[35;49mU\x1b[0m'
'\x1b[33;49mG\x1b[0m'
'\x1b[35;49mΨ\x1b[0m')
assert output == correct
def test_display_split(gene_a):
output = gene_a.display(
split_codons=True, show_aminos=False, display=False)
print(output)
correct = ('\x1b[32;49mA\x1b[0m'
'\x1b[35;49mT\x1b[0m'
'\x1b[34;49mC\x1b[0m'
' '
'\x1b[35;49mU\x1b[0m'
'\x1b[33;49mG\x1b[0m'
'\x1b[35;49mΨ\x1b[0m')
assert output == correct
def test_display_split_aminos(gene_a):
output = gene_a.display(
split_codons=True, show_aminos=True, display=False)
print(output)
correct = (' I C \n'
'\x1b[32;49mA\x1b[0m'
'\x1b[35;49mT\x1b[0m'
'\x1b[34;49mC\x1b[0m'
' '
'\x1b[35;49mU\x1b[0m'
'\x1b[33;49mG\x1b[0m'
'\x1b[35;49mΨ\x1b[0m')
assert output == correct
def test_display_frame(gene_a):
output = gene_a.display(
start=2, end=5,
split_codons=False,
show_aminos=False,
display=False)
print(output)
correct = ('\x1b[34;49mC\x1b[0m'
'\x1b[35;49mU\x1b[0m'
'\x1b[33;49mG\x1b[0m')
assert output == correct
def test_display_frame_aminos(gene_a):
output = gene_a.display(
start=2, end=5,
split_codons=False,
show_aminos=True,
display=False)
print(output)
correct = (' L \n'
'\x1b[34;49mC\x1b[0m'
'\x1b[35;49mU\x1b[0m'
'\x1b[33;49mG\x1b[0m')
assert output == correct
def test_visual_compare():
seq_a = 'ATCUGΨATCAUGΨATCUGΨATCUGΨATCUGΨATCUG'
seq_b = 'ATCTGTATCATATATCTGTATCTGTATCTGTATCTG'
gene_a = Gene(seq_a)
gene_b = Gene(seq_b)
print()
gene_a.visual_compare(gene_b)
gene_a.visual_compare(gene_b, start=1)
gene_a.visual_compare(gene_b, start=3, end=12)