+ added feature calculation for the labels
[qpalma.git] / python / set_param_palma.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import math
5 import numpy.matlib
6 import QPalmaDP
7 import pdb
8 from Plif import *
9
10
11
12
13 def set_params_pa():
14 h = plf()
15 h.len = int(model.intron_len_bins)
16 h.limits = model.intron_len_limits
17 h.penalties = model.intron_len_penalties
18 h.name = 'h'
19 h.max_len = int(max_intron_len)
20 h.min_len = int(min_intron_len)
21 h.transform = model.intron_len_transform
22
23 d = plf()
24 d.len = int(model.donor_bins)
25 d.limits = model.donor_limits
26 d.penalties = model.donor_penalties
27 d.name = 'd'
28 d.max_len = 100
29 d.min_len = -100
30
31 a = plf()
32 a.len = int(model.acceptor_bins)
33 a.limits = model.acceptor_limits
34 a.penalties = model.acceptor_penalties
35 a.name = 'a'
36 a.max_len = 100
37 a.min_len = -100
38
39 mmatrix = model.substitution_matrix
40
41
42 def set_param_palma(param, train_with_intronlengthinformation,\
43 min_intron_len=None, max_intron_len=None, min_svm_score=None, max_svm_score=None):
44
45 print 'Setting parameters ...'
46
47 if min_intron_len == None:
48 if train_with_intronlengthinformation:
49 min_intron_len=20
50 max_intron_len=1000
51 else:
52 min_intron_len = 1
53 max_intron_len = 2
54
55 if min_intron_len != None and max_intron_len != None:
56 min_svm_score=-5
57 max_svm_score=5
58
59 h = Plf()
60 d = Plf()
61 a = Plf()
62
63 ####################
64 # Gapfunktion
65 ####################
66 h.limits = logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),30)
67 h.penalties = param[0:30].flatten().tolist()[0]
68 #h.transform = '+1'
69 h.transform = ''
70 h.name = 'h'
71 h.max_len = 100000
72 h.min_len = 4
73 h.id = 1
74 h.use_svm = 0
75 h.next_id = 0
76
77
78 ####################
79 # Donorfunktion
80 ####################
81 d.limits = linspace(min_svm_score,max_svm_score,30)
82 d.penalties = param[30:60].flatten().tolist()[0]
83 #d.transform = '+1'
84 d.transform = ''
85 d.name = 'd'
86 d.max_len = 100
87 d.min_len = -100
88 d.id = 1
89 d.use_svm = 0
90 d.next_id = 0
91
92
93 ####################
94 # Acceptorfunktion
95 ####################
96 a.limits = linspace(min_svm_score,max_svm_score,30)
97 a.penalties = param[60:90].flatten().tolist()[0]
98 #a.transform = '+1'
99 a.transform = ''
100 a.name = 'a'
101 a.max_len = 100
102 a.min_len = -100
103 a.id = 1
104 a.use_svm = 0
105 a.next_id = 0
106
107
108 ####################
109 # Matchmatrix
110 ####################
111 mmatrix = numpy.matlib.mat(param[90:126])
112 mmatrix.reshape(6,6)
113
114 return h,d,a,mmatrix
115
116 if __name__ == '__main__':
117 #min_intron_len=20
118 #max_intron_len=1000
119 #print logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),30)
120
121 min_svm_score=-5
122 max_svm_score=5
123 print linspace(min_svm_score,max_svm_score,30)