+ moved penalty lookup and compute_doncc to Plif module
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Thu, 26 Jun 2008 09:32:24 +0000 (09:32 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Thu, 26 Jun 2008 09:32:24 +0000 (09:32 +0000)
+ added Param class to svn

git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@9780 e1793c9e-67f9-0310-80fc-b846ff1f7b36

qpalma/Plif.py
qpalma/TrainingParam.py [new file with mode: 0644]
qpalma/compute_donacc.py [deleted file]
qpalma/penalty_lookup_new.py [deleted file]
qpalma/set_param_palma.py

index a52594f..9fe0598 100644 (file)
@@ -1,8 +1,14 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+import math
+import pdb
+
+from numpy.matlib import zeros,isinf
+
 import QPalmaDP
 
+
 class Plf: 
    """
    means piecewise linear function
@@ -82,3 +88,66 @@ def logspace(a,b,n):
 
 def log10(x):
    return math.log(x)/math.log(10)
+
+
+def penalty_lookup_new(penalty_struct, value):
+
+   limits = penalty_struct.limits
+   penalties = penalty_struct.penalties
+
+   if penalty_struct.transform == 'log':
+      value = math.log(value)
+
+   elif penalty_struct.transform == 'log(+3)':
+      value = math.log(value+3)
+
+   elif penalty_struct.transform == 'log(+1)':
+      value = math.log(value+1)
+
+   elif penalty_struct.transform == '':
+      pass
+
+   elif penalty_struct.transform == '(+3)':
+      value += 3
+         
+   elif penalty_struct.transform == 'mod3':
+     value = value%3
+
+   else:
+      assert False,'unknown penalty transform'
+
+   count = len([elem for elem in limits if elem <= value])
+
+   if count == 0:
+      pen = penalties[0]
+   elif count == len(limits):
+      pen=penalties[-1]
+   else:
+      pen = (penalties[count]*(value-limits[count-1]) + penalties[count-1]\
+         *(limits[count]-value)) / (limits[count]-limits[count-1])
+
+   return pen
+
+
+def compute_donacc(donor_supp, acceptor_supp, d, a):
+
+   assert(len(donor_supp)==len(acceptor_supp))
+   size = len(donor_supp)
+  
+   donor    = [0.0]*size
+   acceptor = [0.0]*size
+
+   for idx in range(size):
+     if isinf(donor_supp[idx]):
+       donor[idx] = donor_supp[idx]
+     else:
+       donor[idx] = penalty_lookup_new(d, donor_supp[idx])
+
+     if isinf(acceptor_supp[idx]):
+       acceptor[idx] = acceptor_supp[idx]
+     else:
+       acceptor[idx] = penalty_lookup_new(a,acceptor_supp[idx])
+
+   return donor,acceptor
+
+
diff --git a/qpalma/TrainingParam.py b/qpalma/TrainingParam.py
new file mode 100644 (file)
index 0000000..2d5b28b
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+class Param:
+   
+   def __init__(self):
+      """ default parameters """
+
+      self.basedir = '/fml/ag-raetsch/share/projects/qpalma/elegans_palma2'
+      #self.basedir = '/fml/ag-raetsch/share/projects/qpalma/zebrafish'
+      self.MAX_MEM = 31000;
+      self.LOCAL_ALIGN = 1;
+      self.init_param = 1;
+      self.train_with_splicesitescoreinformation = 1;
+      self.train_with_intronlengthinformation = 1;
+      self.C = 0.001;
+      self.microexon = 0;
+      self.prob = 0;
+      self.organism = 'elegans'
+      self.expt = 'training'
+         
+      self.insertion_prob  = self.prob/3 ;
+      self.deletion_prob   = self.prob/3 ;
+      self.mutation_prob   = self.prob/3 ;
diff --git a/qpalma/compute_donacc.py b/qpalma/compute_donacc.py
deleted file mode 100644 (file)
index bad0872..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import math
-from numpy.matlib import zeros,isinf
-from penalty_lookup_new import *
-
-def compute_donacc(donor_supp, acceptor_supp, d, a):
-
-   assert(len(donor_supp)==len(acceptor_supp))
-   size = len(donor_supp)
-  
-   donor    = [0.0]*size
-   acceptor = [0.0]*size
-
-   for idx in range(size):
-     if isinf(donor_supp[idx]):
-       donor[idx] = donor_supp[idx]
-     else:
-       donor[idx] = penalty_lookup_new(d, donor_supp[idx])
-
-     if isinf(acceptor_supp[idx]):
-       acceptor[idx] = acceptor_supp[idx]
-     else:
-       acceptor[idx] = penalty_lookup_new(a,acceptor_supp[idx])
-
-   return donor,acceptor
diff --git a/qpalma/penalty_lookup_new.py b/qpalma/penalty_lookup_new.py
deleted file mode 100644 (file)
index 9837dd5..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import math
-import pdb
-
-def penalty_lookup_new(penalty_struct, value):
-
-   limits = penalty_struct.limits
-   penalties = penalty_struct.penalties
-
-   if penalty_struct.transform == 'log':
-      value = math.log(value)
-
-   elif penalty_struct.transform == 'log(+3)':
-      value = math.log(value+3)
-
-   elif penalty_struct.transform == 'log(+1)':
-      value = math.log(value+1)
-
-   elif penalty_struct.transform == '':
-      pass
-
-   elif penalty_struct.transform == '(+3)':
-      value += 3
-         
-   elif penalty_struct.transform == 'mod3':
-     value = value%3
-
-   else:
-      assert False,'unknown penalty transform'
-
-   count = len([elem for elem in limits if elem <= value])
-
-   if count == 0:
-      pen = penalties[0]
-   elif count == len(limits):
-      pen=penalties[-1]
-   else:
-      pen = (penalties[count]*(value-limits[count-1]) + penalties[count-1]\
-         *(limits[count]-value)) / (limits[count]-limits[count-1])
-
-   return pen
index 0927bec..71cddab 100644 (file)
@@ -78,11 +78,8 @@ def set_param_palma(param, train_with_intronlengthinformation, run):
    mmatrix = numpy.matlib.mat(param[lengthSP+donSP+accSP:lengthSP+donSP+accSP+mmatrixSP])
 
 
-
    mmatrix.reshape(run['matchmatrixRows'],run['matchmatrixCols'])
 
-
-
    ####################
    # Quality Plifs
    ####################
@@ -103,6 +100,7 @@ def set_param_palma(param, train_with_intronlengthinformation, run):
 
    return h,d,a,mmatrix,qualityPlifs
 
+
 if __name__ == '__main__':
    min_svm_score=-5
    max_svm_score=5