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