+ fixed minor bugs
[qpalma.git] / qpalma / set_param_palma.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # Written (W) 2008 Fabio De Bona
10 # Copyright (C) 2008 Max-Planck-Society
11
12 import math
13 import numpy.matlib
14 import QPalmaDP
15 import pdb
16 from Plif import *
17
18 def set_param_palma(param, train_with_intronlengthinformation, settings):
19
20 print 'Setting parameters ...'
21
22 min_intron_len = settings['min_intron_len']
23 max_intron_len = settings['max_intron_len']
24
25 min_svm_score = settings['min_svm_score']
26 max_svm_score = settings['max_svm_score']
27
28 h = Plf()
29 d = Plf()
30 a = Plf()
31
32 qualityPlifs = [None]*settings['numQualPlifs']
33 donSP = settings['numDonSuppPoints']
34 accSP = settings['numAccSuppPoints']
35 lengthSP = settings['numLengthSuppPoints']
36 mmatrixSP = settings['matchmatrixRows']*settings['matchmatrixCols']
37 totalQualSP = settings['totalQualSuppPoints']
38
39 ####################
40 # Gapfunktion
41 ####################
42 h.limits = logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),lengthSP)
43 h.penalties = param[0:lengthSP].flatten().tolist()[0]
44 #h.transform = '+1'
45 h.transform = ''
46 h.name = 'h'
47 h.max_len = max_intron_len
48 h.min_len = min_intron_len
49 h.id = 1
50 h.use_svm = 0
51 h.next_id = 0
52
53 ####################
54 # Donorfunktion
55 ####################
56 d.limits = linspace(min_svm_score,max_svm_score,donSP)
57 d.penalties = param[lengthSP:lengthSP+donSP].flatten().tolist()[0]
58 #d.transform = '+1'
59 d.transform = ''
60 d.name = 'd'
61 d.max_len = max_svm_score
62 d.min_len = min_svm_score
63 d.id = 1
64 d.use_svm = 0
65 d.next_id = 0
66
67 ####################
68 # Acceptorfunktion
69 ####################
70 a.limits = linspace(min_svm_score,max_svm_score,accSP)
71 a.penalties = param[lengthSP+donSP:lengthSP+donSP+accSP].flatten().tolist()[0]
72 #a.transform = '+1'
73 a.transform = ''
74 a.name = 'a'
75 a.max_len = max_svm_score
76 a.min_len = min_svm_score
77 a.id = 1
78 a.use_svm = 0
79 a.next_id = 0
80
81 ####################
82 # Matchmatrix
83 ####################
84 mmatrix = numpy.matlib.mat(param[lengthSP+donSP+accSP:lengthSP+donSP+accSP+mmatrixSP])
85
86
87 mmatrix.reshape(settings['matchmatrixRows'],settings['matchmatrixCols'])
88
89 ####################
90 # Quality Plifs
91 ####################
92 for idx in range(settings['numQualPlifs']):
93 currentPlif = Plf()
94 currentPlif.limits = linspace(settings['min_qual'],settings['max_qual'],settings['numQualSuppPoints'])
95 begin = lengthSP+donSP+accSP+mmatrixSP+(idx*settings['numQualSuppPoints'])
96 end = lengthSP+donSP+accSP+mmatrixSP+((idx+1)*settings['numQualSuppPoints'])
97
98 currentPlif.penalties = param[begin:end].flatten().tolist()[0]
99 currentPlif.transform = ''
100 currentPlif.name = 'q'
101
102 currentPlif.max_len = settings['max_qual']
103 currentPlif.min_len = settings['min_qual']
104
105 qualityPlifs[idx] = currentPlif
106
107 return h,d,a,mmatrix,qualityPlifs
108
109
110 if __name__ == '__main__':
111 min_svm_score=-5
112 max_svm_score=5
113 print linspace(min_svm_score,max_svm_score,30)