+ minor changes in the paths
[qpalma.git] / scripts / plot_error.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4
5 import cPickle
6 import sys
7
8 filename = sys.argv[1]
9
10 predict = cPickle.load(open(filename))
11
12 correct = {}
13 off = {}
14 wrong = {}
15
16 split_count = [0]*36
17
18 for elem in predict:
19 current_elem = elem['realRestPos']
20
21 split_count[current_elem] += 1
22
23 if len(elem['predExons']) != 4:
24
25 try:
26 wrong[current_elem] += 1
27 except:
28 wrong[current_elem] = 1
29
30 else:
31 e1b = elem['e1_b_off']
32 e1e = elem['e1_e_off']
33 e2b = elem['e2_b_off']
34 e2e = elem['e2_e_off']
35
36 if e1b == 0 and e1e == 0 and e2b == 0 and e2e == 0:
37 try:
38 correct[current_elem] += 1
39 except:
40 correct[current_elem] = 1
41
42 if not (e1b == 0 and e1e == 0 and e2b == 0 and e2e == 0):
43 try:
44 off[current_elem] += 1
45 except:
46 off[current_elem] = 1
47
48 import pylab
49
50 print split_count
51
52 y_values = []
53 for overlap in range(36):
54 result = 0
55 try:
56 cv = off[overlap]
57 except:
58 cv = 0
59
60 result += cv
61
62 try:
63 cv = wrong[overlap]
64 except:
65 cv = 0
66
67 result += cv
68
69 if split_count[overlap] > 0:
70 result = result/(1.0*split_count[overlap])
71 else:
72 result = 0
73
74 y_values.append(result)
75
76 outfile = filename.replace('_allPredictions','')
77
78 import numpy
79 import pylab
80 pylab.bar(range(36),y_values,width=0.2,align='center')
81 pylab.xticks( numpy.arange(0,36,1) )
82 pylab.savefig('%s_error_vs_overlap.eps'%outfile)
83 pylab.clf()
84 #raw_input()