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