+ fixed a bug in the C++ interface
[qpalma.git] / python / qpalma.py
index 4b5af6a..271bde9 100644 (file)
@@ -20,6 +20,8 @@ import QPalmaDP
 from SIQP_CPX import SIQPSolver
 
 from paths_load_data import *
+from paths_load_data_pickle import *
+
 from computeSpliceWeights import *
 from set_param_palma import *
 from computeSpliceAlign import *
@@ -78,10 +80,8 @@ class QPalma:
       
    def run(self):
       # Load the whole dataset 
-      Sequences, Acceptors, Donors, Exons, Ests, Noises = paths_load_data('training',self.genome_info,self.ARGS)
-
-      #Sequences, Acceptors, Donors, Exons, Ests, QualityScores = paths_load_data('training',self.genome_info,self.ARGS)
-
+      #Sequences, Acceptors, Donors, Exons, Ests, Noises = paths_load_data('training',self.genome_info,self.ARGS)
+      Sequences, Acceptors, Donors, Exons, Ests, Noises = paths_load_data_pickle('training',self.genome_info,self.ARGS)
 
       # number of training instances
       N = len(Sequences) 
@@ -90,7 +90,7 @@ class QPalma:
       and N == len(Ests), 'The Seq,Accept,Donor,.. arrays are of different lengths'
       self.plog('Number of training examples: %d\n'% N)
 
-      iteration_steps = 10 ; #upper bound on iteration steps
+      iteration_steps = 200 ; #upper bound on iteration steps
 
       remove_duplicate_scores = False
       print_matrix = False
@@ -103,7 +103,6 @@ class QPalma:
       # Set the parameters such as limits penalties for the Plifs
       [h,d,a,mmatrix] = set_param_palma(param,self.ARGS.train_with_intronlengthinformation)
 
-
       # delete splicesite-score-information
       if not self.ARGS.train_with_splicesitescoreinformation:
          for i in range(len(Acceptors)):
@@ -135,7 +134,7 @@ class QPalma:
             break
 
          for exampleIdx in range(self.numExamples):
-            if exampleIdx% 1000 == 0:
+            if (exampleIdx%10) == 0:
                print 'Current example nr %d' % exampleIdx
 
             dna = Sequences[exampleIdx] 
@@ -203,8 +202,8 @@ class QPalma:
             #print 'PYTHON: Calling myalign...'
             # calculates SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest
             currentAlignment.myalign( num_path[exampleIdx], dna, dna_len,\
-            est, est_len, ps, matchmatrix, mm_len, donor, d_len,\
-            acceptor, a_len, remove_duplicate_scores, print_matrix)
+             est, est_len, ps, matchmatrix, mm_len, donor, d_len,\
+             acceptor, a_len, remove_duplicate_scores, print_matrix)
             #print 'PYTHON: After myalign call...'
 
             newSpliceAlign       = QPalmaDP.createIntArrayFromList([0]*(dna_len*num_path[exampleIdx]))
@@ -213,6 +212,7 @@ class QPalma:
             newAlignmentScores   = QPalmaDP.createDoubleArrayFromList([.0]*num_path[exampleIdx])
 
             currentAlignment.getAlignmentResults(newSpliceAlign, newEstAlign, newWeightMatch, newAlignmentScores)
+            del currentAlignment
 
             spliceAlign = zeros((num_path[exampleIdx]*dna_len,1))
             weightMatch = zeros((num_path[exampleIdx]*mm_len,1))
@@ -306,17 +306,28 @@ class QPalma:
                      for elem in self.slacks:
                         sum_xis +=  elem
 
-                  for i in range(len(param)):
-                     param[i] = w[i]
+                     for i in range(len(param)):
+                        param[i] = w[i]
+
+                     [h,d,a,mmatrix] = set_param_palma(param,self.ARGS.train_with_intronlengthinformation)
 
-                  [h,d,a,mmatrix] = set_param_palma(param,self.ARGS.train_with_intronlengthinformation)
-                  
-            if exampleIdx==10:
+               #
+               # end of one example processing 
+               #
+            if exampleIdx == 10:
                break
+         
+         break
 
+         #
+         # end of one iteration through all examples
+         #
          iteration_nr += 1
 
-      export_param('test_params',h,d,a,mmatrix)
+      #
+      # end of optimization 
+      #  
+      export_param('elegans.param',h,d,a,mmatrix)
       self.logfh.close()
       print 'Training completed'