/
evaluate.py
59 lines (39 loc) · 1.16 KB
/
evaluate.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
from subprocess import call
from dna import utils
import matplotlib.pyplot as plt
import os
RESULTS = ([], [])
if not os.path.isdir('decoded'):
os.mkdir('decoded')
def compare(filename_a, filename_b):
a = open(filename_a)
b = open(filename_b)
_, sequence_a = utils.load(a)
a.close()
_, sequence_b = utils.load(b)
b.close()
return utils.compare(sequence_a, sequence_b)
def execute(window):
print('Window: {}'.format(window))
output_file = 'decoded/{}.fasta'.format(window)
if not os.path.exists(output_file):
cmd = 'python hmm_decoder.py -o {} coli.model {} test_aa.fasta'.format(output_file, window)
print cmd
call(cmd, shell=True)
RESULTS[0].append(window)
RESULTS[1].append(compare(output_file, 'test.fasta'))
print(RESULTS[1][-1])
def graph():
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(RESULTS[0], RESULTS[1])
plt.savefig('graph.png')
for window in range(1, 10):
execute(window)
for window in range(10, 150, 10):
execute(window)
for window in range(150, 500, 50):
execute(window)
for window in range(500, 2000, 100):
execute(window)
graph()