index b38283f..25746ce 100644 (file)
@@ -4,29 +4,36 @@
import math
import numpy.matlib
+import pdb

def linspace(a,b,n):
intervalLength = b-a
-   stepSize = intervalLength / n
+   stepSize = 1.0*intervalLength / (n-1)

interval = [0]*n
-   for i in range(n):
-      interval[i] = a+i*stepSize
+   interval[0] = a
+   interval[-1] = b
+   for i in range(1,n-1):
+      interval[i] = a+(i*stepSize)

return interval

-
def logspace(a,b,n):
interval = [0]*n
-   intervalSize = b-a
+   begin = 10.0**a
+   end = 10.0**b
+   intervalSize = 1.0*(b-a)/(n-1)
+   interval[0] = begin
+   interval[-1] = end

-   interval[n-1] = b
-
-   for i in range(n-2,0,-1):
-      interval[i] = interval[i+1] / math.e
+   for i in range(1,n-1):
+      interval[i] = 10**(a+i*intervalSize)

return interval

+def log10(x):
+   return math.log(x)/math.log(10)
+
class Plf: #means piecewise linear function

def __init_(self):
@@ -38,18 +45,20 @@ class Plf: #means piecewise linear function
self.max_len = 0
self.min_len = 0

-   #def convert2SWIG(self):
-   #
-   #   #ps.len = self.len
-   #   #ps.limits = self.limits
-   #   ps.penalties = self.penalties
-   #   ps.max_len = self.max_len
-   #   ps.min_len = self.min_len
-   #   ps.transform = 0
-   #   ps.name = self.name
+   def convert2SWIG(self):
+
+      ps.len = len(self.limits)
+
+
+      ps.max_len = self.max_len
+      ps.min_len = self.min_len
+      ps.transform = 0
+      ps.name = self.name

-   #   return ps
+      return ps

def set_params_pa():
@@ -98,7 +107,6 @@ def set_param_palma(param, train_with_intronlengthinformation,\
min_svm_score=-5
max_svm_score=5

-
h = Plf()
d = Plf()
a = Plf()
@@ -107,7 +115,7 @@ def set_param_palma(param, train_with_intronlengthinformation,\
# Gapfunktion
####################
h.limits    = logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),30)
-   h.penalties = param[1:30]
+   h.penalties = param[0:30].flatten().tolist()[0]
#h.transform = '+1'
h.transform = ''
h.name      = 'h'
@@ -122,7 +130,7 @@ def set_param_palma(param, train_with_intronlengthinformation,\
# Donorfunktion
####################
d.limits    = linspace(min_svm_score,max_svm_score,30)
-   d.penalties = param[31:60]
+   d.penalties = param[30:60].flatten().tolist()[0]
#d.transform = '+1'
d.transform = ''
d.name      = 'd'
@@ -137,7 +145,7 @@ def set_param_palma(param, train_with_intronlengthinformation,\
# Acceptorfunktion
####################
a.limits    = linspace(min_svm_score,max_svm_score,30)
-   a.penalties = param[61:90]
+   a.penalties = param[60:90].flatten().tolist()[0]
#a.transform = '+1'
a.transform = ''
a.name      = 'a'
@@ -155,3 +163,12 @@ def set_param_palma(param, train_with_intronlengthinformation,\
mmatrix.reshape(6,6)

return h,d,a,mmatrix
+
+if __name__ == '__main__':
+   #min_intron_len=20
+   #max_intron_len=1000
+   #print logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),30)
+
+   min_svm_score=-5
+   max_svm_score=5
+   print linspace(min_svm_score,max_svm_score,30)