+ created necessary interfaces
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Sat, 1 Dec 2007 00:59:22 +0000 (00:59 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Sat, 1 Dec 2007 00:59:22 +0000 (00:59 +0000)
+ wrote some convenience python functions in set_param_palma

TODO

- complete python training loop

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

QPalmaDP/Makefile
QPalmaDP/QPalmaDP.i
QPalmaDP/penalty_info.cpp
QPalmaDP/penalty_info.h
QPalmaDP/qpalma_dp.cpp
QPalmaDP/qpalma_dp.h
python/qpalma.py
python/set_param_palma.py

index 42574ea..889c4b4 100644 (file)
@@ -1,5 +1,6 @@
 SRCS= Mathmatics.cpp\
                fill_matrix.cpp\
+               qpalma_dp.cpp\
                result_align.cpp\
                penalty_info.cpp\
                print_align.cpp\
index 05dd99c..a592bb0 100644 (file)
@@ -1,5 +1,8 @@
 %module QPalmaDP
 %{
+#include "common.h"
+#include "Mathmatics.h"
+#include "penalty_info.h"
 #include "qpalma_dp.h"
 %}
 
 
 %include "carrays.i"
 
+%include "common.h"
+%include "Mathmatics.h"
+%include "penalty_info.h"
 %include "qpalma_dp.h"
 
-
 %array_functions(int, intArray) ;
-%array_functions(double, doubleArray) ;
+%array_function(double, doubleArray) ;
 %array_class(Pre_score, Pre_scoreArray) ;
 
 %pythoncode
index 8095ca1..d3f11a2 100644 (file)
@@ -40,7 +40,7 @@ void init_penalty_struct_cache(struct penalty_struct &PEN)
        }
 }
 
-void delete_penalty_struct(struct penalty_struct &PEN)
+void delete_penalty_struct_palma(struct penalty_struct &PEN)
 {
        if (PEN.id!=-1)
        {
@@ -54,7 +54,7 @@ void delete_penalty_struct(struct penalty_struct &PEN)
 void delete_penalty_struct_array(struct penalty_struct *PEN, INT len)
 {
        for (int i=0; i<len; i++)
-               delete_penalty_struct(PEN[i]) ;
+               delete_penalty_struct_palma(PEN[i]) ;
        delete[] PEN ;
 }
 
index 2ed9ee1..56465ca 100644 (file)
@@ -29,8 +29,8 @@ struct penalty_struct
 } ;
 
 void init_penalty_struct(struct penalty_struct &PEN) ;
-void delete_penalty_struct(struct penalty_struct &PEN) ;
-void delete_penalty_struct_array(struct penalty_struct *PEN, INT len) ;
+void delete_penalty_struct_palma(struct penalty_struct &PEN) ;
+//void delete_penalty_struct_array(struct penalty_struct *PEN, INT len) ;
 
 //#ifdef HAVE_MATLAB
 //struct penalty_struct * read_penalty_struct_from_cell(const mxArray * mx_penalty_info, mwSize &P) ;
index 1e86e49..5aeaa80 100644 (file)
@@ -9,9 +9,34 @@
    nrhs - Number of inputs (Right Hand Side)
    prhs - Array of pointers to input data. */
 
-  myalign([nr_paths], dna, est, {h}, matchmatrix, donor, acceptor, remove_duplicate_scores, ...
-  print_matrix) */
+Alignment::Alignment() {
+
+      len = 0;
+      limits = 0;
+      penalties = 0;
+      max_len = 0;
+      min_len = 0;
+      cache = 0;
+      enum ETransformType transform = T_LINEAR;
+      id = 0;
+      name = 0;
+      use_svm = 0;
+}
+
+Alignment::~Alignment() {}
 
+void Alignment::myalign(int nr_paths, char* dna, int dna_len, char* est,
+      int est_len, struct penalty_struct h, double* matchmatrix, int mm_len,
+      double* donor, int d_len, double* acceptor, int a_len,
+      bool remove_duplicate_scores, bool print_matrix) {}
+
+void Alignment::getSpliceAlign(){}
+void Alignment::getEstAlign(){}
+void Alignment::getWeightMatch(){}
+void Alignment::getTotalScores(){}
+void Alignment::getDNAEST(){}
+
+#if 0
 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 {
   
@@ -318,4 +343,4 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
   return;    
   
 }
-
+#endif
index c019466..5b3a4f7 100644 (file)
@@ -59,23 +59,46 @@ extern void print_align(Pre_score* matrix, int length_est,  int length_dna, Alig
 class Alignment {
 
    private:
-      SpliceAlign
-      EstAlign;
-      WeightMatch;
-      TotalScores;
+      int SpliceAlign;
+      int EstAlign;
+      int WeightMatch;
+      int TotalScores;
+
+      INT len;
+      REAL *limits;
+      REAL *penalties;
+      INT max_len;
+      INT min_len;
+      REAL *cache;
+      enum ETransformType transform ;
+      INT id;
+      char * name;
+      INT use_svm;
 
    public:
       Alignment();
       ~Alignment();
 
-      void myalign(int nr_paths, dna, est, h, matchmatrix, double* donor, double* acceptor, bool remove_duplicate_scores, bool print_matrix);
-      getSpliceAlign()
-      getEstAlign();
-      getWeightMatch();
-      getTotalScores();
-      getDNAEST();
-       
-
+      void myalign(int nr_paths, char* dna, int dna_len, char* est,
+      int est_len, struct penalty_struct h, double* matchmatrix, int mm_len,
+      double* donor, int d_len, double* acceptor, int a_len, 
+      bool remove_duplicate_scores, bool print_matrix);
+
+      void penSetLength(int l) { len = l; }
+      void penSetLimits(REAL* lts) { 
+         limits = new REAL[len];
+         for(int i=0; i<len; i++)
+            limits[i] = lts[i];
+      }
+      
+
+      void getSpliceAlign();
+      void getEstAlign();
+      void getWeightMatch();
+      void getTotalScores();
+      void getDNAEST();
+
+   
 };
 
 
index e48073e..d3fb752 100644 (file)
@@ -11,6 +11,7 @@ from set_param_palma import *
 from computeSpliceAlign import *
 
 from computeSpliceWeights import *
+import QPalmaDP
 
 """
 A training method for the QPalma project
@@ -219,27 +220,54 @@ def run():
          trueSpliceAlign, trueWeightMatch = computeSpliceAlign(dna, exons)
 
          trueWeightDon, trueWeightAcc, trueWeightIntron = computeSpliceWeights(d, a, h, trueSpliceAlign, don_supp, acc_supp)
-         pdb.set_trace()
 
          #
          # compute wrong alignments
          #  
+         nr_paths = 1
+         dna = 'acgtagct'
+         dna_len = len(dna)
+
+         est = 'acgtagct'
+         est_len = len(est)
+
+         matchmatrix = QPalmaDP.createDoubleArrayFromList([1.0]*36)
+         mm_len = 36
+         donor = QPalmaDP.createDoubleArrayFromList([1,2.0,4])
+         d_len = 3
+         acceptor = QPalmaDP.createDoubleArrayFromList([.1,2,4])
+         a_len = 3
+         remove_duplicate_scores = False
+         print_matrix = False
+
+         currentAlignment = QPalmaDP.Alignment()
+         currentAlignment.penSetLength(30)
+         dA = QPalmaDP.createDoubleArrayFromList([1.0]*30)
+         #currentAlignment.penSetLimits(dA)
+         ps = QPalmaDP.penalty_struct()
+         ps.len = 30
+         ps.limit = dA
+
+         currentAlignment.myalign( nr_paths, dna, dna_len,\
+         est, est_len, ps, matchmatrix, mm_len, donor, d_len,\
+         acceptor, a_len, remove_duplicate_scores, print_matrix)
+
+         pdb.set_trace()
 
-         # Compute donor, acceptor with penalty_lookup_new
-         # returns two double lists
-         [donor, acceptor] = compute_donacc(don_supp, acc_supp, d, a) ;
+         # Compute donor, acceptor with penalty_lookup_new
+         # returns two double lists
+         [donor, acceptor] = compute_donacc(don_supp, acc_supp, d, a) ;
        
-         #myalign wants the acceptor site on the g of the ag
-         acceptor = [acceptor(2:end) -Inf] ;
-         
-         # call myalign    
-         [SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest] = ...
-           myalign_local(num_path(id), dna, est, {h}, mmatrix, donor, acceptor, ...
-                         remove_duplicate_scores, print_matrix);
+         # #myalign wants the acceptor site on the g of the ag
+         acceptor = [acceptor(2:end) -Inf] ;
+         # 
+         # call myalign    
+         [SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest] = ...
+           myalign_local(num_path(id), dna, est, {h}, mmatrix, donor, acceptor, ...
+                         remove_duplicate_scores, print_matrix);
        
-          SpliceAlign = double(SpliceAlign') ; %column
-          weightMatch = double(weightMatch') ;
-
+         #  SpliceAlign = double(SpliceAlign') ; %column
+         #  weightMatch = double(weightMatch') ;
 
       iteration_nr += 1
       break
index 39eb949..b38283f 100644 (file)
@@ -3,6 +3,7 @@
 
 import math
 import numpy.matlib
+import QPalmaDP
 
 def linspace(a,b,n):
    intervalLength = b-a
@@ -27,13 +28,29 @@ def logspace(a,b,n):
    return interval
 
 class Plf: #means piecewise linear function
-   len = 0
-   limits = []
-   penalties = []
-   transform = ''
-   name = ''
-   max_len = 0
-   min_len = 0
+
+   def __init_(self):
+      self.len = 0
+      self.limits = []
+      self.penalties = []
+      self.transform = ''
+      self.name = ''
+      self.max_len = 0
+      self.min_len = 0
+
+   #def convert2SWIG(self):
+   #   ps = QPalmaDP.penalty_struct()
+   #
+   #   #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
+
+   #   return ps
+
 
 def set_params_pa():
    h = plf()