+ minor bugfixes in the compile_dataset script
[qpalma.git] / qpalma / 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 import Configuration
9 from Plif import *
10
11 def set_param_palma(param, train_with_intronlengthinformation,\
12 min_intron_len=None, max_intron_len=None, min_svm_score=None, max_svm_score=None):
13
14 print 'Setting parameters ...'
15
16 min_intron_len = Conf.min_intron_len
17 max_intron_len = Conf.max_intron_len
18
19 min_svm_score = Conf.min_svm_score
20 max_svm_score = Conf.max_svm_score
21
22 h = Plf()
23 d = Plf()
24 a = Plf()
25 qualityPlifs = [None]*Configuration.numQualPlifs
26
27 donSP = Configuration.numDonSuppPoints
28 accSP = Configuration.numAccSuppPoints
29 lengthSP = Configuration.numLengthSuppPoints
30 mmatrixSP = Configuration.sizeMatchmatrix[0]\
31 *Configuration.sizeMatchmatrix[1]
32 totalQualSP = Configuration.totalQualSuppPoints
33
34 ####################
35 # Gapfunktion
36 ####################
37 h.limits = logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),lengthSP)
38 h.penalties = param[0:lengthSP].flatten().tolist()[0]
39 #h.transform = '+1'
40 h.transform = ''
41 h.name = 'h'
42 h.max_len = max_intron_len
43 h.min_len = min_intron_len
44 h.id = 1
45 h.use_svm = 0
46 h.next_id = 0
47
48 ####################
49 # Donorfunktion
50 ####################
51 d.limits = linspace(min_svm_score,max_svm_score,donSP)
52 d.penalties = param[lengthSP:lengthSP+donSP].flatten().tolist()[0]
53 #d.transform = '+1'
54 d.transform = ''
55 d.name = 'd'
56 d.max_len = max_svm_score
57 d.min_len = min_svm_score
58 d.id = 1
59 d.use_svm = 0
60 d.next_id = 0
61
62 ####################
63 # Acceptorfunktion
64 ####################
65 a.limits = linspace(min_svm_score,max_svm_score,accSP)
66 a.penalties = param[lengthSP+donSP:lengthSP+donSP+accSP].flatten().tolist()[0]
67 #a.transform = '+1'
68 a.transform = ''
69 a.name = 'a'
70 a.max_len = max_svm_score
71 a.min_len = min_svm_score
72 a.id = 1
73 a.use_svm = 0
74 a.next_id = 0
75
76 ####################
77 # Matchmatrix
78 ####################
79 mmatrix = numpy.matlib.mat(param[lengthSP+donSP+accSP:lengthSP+donSP+accSP+mmatrixSP])
80 mmatrix.reshape(Configuration.sizeMatchmatrix[0],Configuration.sizeMatchmatrix[1])
81
82 ####################
83 # Quality Plifs
84 ####################
85 for idx in range(Configuration.numQualPlifs):
86 currentPlif = Plf()
87 currentPlif.limits = linspace(Configuration.min_qual,Configuration.max_qual,Configuration.numQualSuppPoints)
88 begin = lengthSP+donSP+accSP+mmatrixSP+(idx*Configuration.numQualSuppPoints)
89 end = lengthSP+donSP+accSP+mmatrixSP+((idx+1)*Configuration.numQualSuppPoints)
90 currentPlif.penalties = param[begin:end].flatten().tolist()[0]
91 currentPlif.transform = ''
92 currentPlif.name = 'q'
93 currentPlif.max_len = Configuration.max_qual
94 currentPlif.min_len = Configuration.min_qual
95 qualityPlifs[idx] = currentPlif
96
97 return h,d,a,mmatrix,qualityPlifs
98
99 if __name__ == '__main__':
100 min_svm_score=-5
101 max_svm_score=5
102 print linspace(min_svm_score,max_svm_score,30)