+ added some assertions
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Tue, 15 Jan 2008 15:26:45 +0000 (15:26 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Tue, 15 Jan 2008 15:26:45 +0000 (15:26 +0000)
+ can switch now between 'normal' palma and qpalma
+ compared result values with qpalma matlab version -> correct
TODO
+ check values/indices for qpalma
+ train!

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

QPalmaDP/qpalma_dp.cpp
QPalmaDP/qpalma_dp.h
python/Configuration.py
python/computeSpliceAlignWithQuality.py
python/qpalma.py

index be35def..c89f979 100644 (file)
@@ -19,17 +19,18 @@ Alignment::Alignment(int numQPlifs, int numq) {
       name = 0;
       use_svm = 0;
 
       name = 0;
       use_svm = 0;
 
-      splice_align = 0;
-      est_align = 0;
-      mmatrix_param = 0;
-      alignmentscores = 0;
+      // set ptrs to zero first
+      splice_align         = 0;
+      est_align            = 0;
+      mmatrix_param        = 0;
+      alignmentscores      = 0;
       qualityScoresAllPaths = 0;
 
       numQualSuppPoints = numq;
       totalNumPlifs = numQPlifs;
 
       qualityScoresAllPaths = 0;
 
       numQualSuppPoints = numq;
       totalNumPlifs = numQPlifs;
 
-      FA( numQualSuppPoints > 0 );
-      FA( totalNumPlifs > 0 );
+      FA( numQualSuppPoints >= 0 );
+      FA( totalNumPlifs >= 0 );
 }
 
 void Alignment::getDNAEST(){}
 }
 
 void Alignment::getDNAEST(){}
@@ -37,7 +38,7 @@ void Alignment::getDNAEST(){}
 void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
       int est_len_p, double* prb, double* chastity, struct penalty_struct h, double* matchmatrix, int mm_len,
       double* donor, int d_len, double* acceptor, int a_len, struct penalty_struct* qualityScores, 
 void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
       int est_len_p, double* prb, double* chastity, struct penalty_struct h, double* matchmatrix, int mm_len,
       double* donor, int d_len, double* acceptor, int a_len, struct penalty_struct* qualityScores, 
-      bool remove_duplicate_scores, bool print_matrix) {
+      bool remove_duplicate_scores, bool print_matrix, bool use_quality_scores) {
 
    // printf("Entering myalign...\n");
    mlen = 6; // score matrix: length of 6 for "- A C G T N"
 
    // printf("Entering myalign...\n");
    mlen = 6; // score matrix: length of 6 for "- A C G T N"
@@ -49,6 +50,12 @@ void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
   // initialize alignment matrices and call fill_matrix()  
   /***************************************************************************/
 
   // initialize alignment matrices and call fill_matrix()  
   /***************************************************************************/
 
+  mode currentMode;
+  if (use_quality_scores) 
+   currentMode = USE_QUALITY_SCORES;
+  else
+   currentMode = NORMAL;
+
     // dnaest
    double *DNA_ARRAY = 0;
    double *EST_ARRAY = 0;
     // dnaest
    double *DNA_ARRAY = 0;
    double *EST_ARRAY = 0;
@@ -80,8 +87,6 @@ void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
   
   // printf("calling fill_matrix...\n");
   //
   
   // printf("calling fill_matrix...\n");
   //
-   mode currentMode = NORMAL;
-   currentMode = USE_QUALITY_SCORES;
 
   fill_matrix(nr_paths, matrices, est_len, dna_len, est, dna, prb, &h, matchmatrix, qualityScores, donor, acceptor, remove_duplicate_scores, nr_donor_sites, donor_sites, max_score_positions,currentMode);
   
 
   fill_matrix(nr_paths, matrices, est_len, dna_len, est, dna, prb, &h, matchmatrix, qualityScores, donor, acceptor, remove_duplicate_scores, nr_donor_sites, donor_sites, max_score_positions,currentMode);
   
@@ -145,9 +150,9 @@ void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
     int* mparam  = mmatrix_param + (mlen*mlen)*z; //pointer
     penalty_struct* qparam = qualityScoresAllPaths + (totalNumPlifs*z);
 
     int* mparam  = mmatrix_param + (mlen*mlen)*z; //pointer
     penalty_struct* qparam = qualityScoresAllPaths + (totalNumPlifs*z);
 
-    printf("before call to result_align...\n");
+    //printf("before call to result_align...\n");
     bool no_more_path = result_align(matrices, z, est_len, dna_len, &result_length, est, dna, prb, chastity, s_align, e_align, mparam, alignmentscores, max_score_positions, qparam, currentMode);
     bool no_more_path = result_align(matrices, z, est_len, dna_len, &result_length, est, dna, prb, chastity, s_align, e_align, mparam, alignmentscores, max_score_positions, qparam, currentMode);
-    printf("after call to result_align...\n");
+    //printf("after call to result_align...\n");
 
   //for(qidx=0;qidx<totalNumPlifs*nr_paths;qidx++) {
   // penalty_struct p;
 
   //for(qidx=0;qidx<totalNumPlifs*nr_paths;qidx++) {
   // penalty_struct p;
@@ -211,7 +216,7 @@ void Alignment::myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
    for (int i=nr_paths-1;i>=0; i--)
       delete[] matrices[i];
 
    for (int i=nr_paths-1;i>=0; i--)
       delete[] matrices[i];
 
-   printf("Leaving myalign...\n");
+   //printf("Leaving myalign...\n");
 }
 
 void Alignment::getAlignmentResults(int* s_align, int* e_align,
 }
 
 void Alignment::getAlignmentResults(int* s_align, int* e_align,
index d42d084..05667c6 100644 (file)
@@ -111,15 +111,15 @@ class Alignment {
          if(alignmentscores != 0)
             delete[] alignmentscores;
 
          if(alignmentscores != 0)
             delete[] alignmentscores;
 
-         //if(qualityScoresAllPaths != 0)
-         //   delete[] qualityScoresAllPaths;
+         if(qualityScoresAllPaths != 0)
+            delete[] qualityScoresAllPaths;
       }
 
       void myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
       int est_len_p, double* prb, double* chastity, struct penalty_struct h, 
       double* matchmatrix, int mm_len, double* donor, int d_len, double* acceptor,
       int a_len, struct penalty_struct* qualityScores, bool remove_duplicate_scores,
       }
 
       void myalign(int nr_paths_p, char* dna, int dna_len_p, char* est,
       int est_len_p, double* prb, double* chastity, struct penalty_struct h, 
       double* matchmatrix, int mm_len, double* donor, int d_len, double* acceptor,
       int a_len, struct penalty_struct* qualityScores, bool remove_duplicate_scores,
-      bool print_matrix);
+      bool print_matrix, bool use_quality_scores);
 
       void getDNAEST();
       void getAlignmentResults(int* s_align, int* e_align,
 
       void getDNAEST();
       void getAlignmentResults(int* s_align, int* e_align,
index f486b66..3bc75ef 100644 (file)
@@ -74,6 +74,34 @@ fixedParam = numpy.matlib.mat(
        [ 0.4177651 ], [ 0.01360547], [ 0.29069319]
        ])
 
        [ 0.4177651 ], [ 0.01360547], [ 0.29069319]
        ])
 
+fixedParam = numpy.matlib.mat([[ 0.62870709], [ 0.7012026 ], [ 0.60236784],
+  [ 0.51316259], [ 0.20220814], [ 0.70324863], [ 0.37218684], [ 0.82178927],
+  [ 0.60394866], [ 0.70371272], [ 0.07548074], [ 0.63412803], [ 0.97442266],
+  [ 0.13216791], [ 0.71041168], [ 0.2093887 ], [ 0.35227344], [ 0.3405142 ],
+  [ 0.69677236], [ 0.41673747], [ 0.564245  ], [ 0.37613432], [ 0.88805642],
+  [ 0.88691608], [ 0.69476752], [ 0.81659504], [ 0.17801859], [ 0.71048235],
+  [ 0.08188783], [ 0.54884803], [ 0.84039558], [ 0.6982093 ], [ 0.41686176],
+  [ 0.38568873], [ 0.29401347], [ 0.12704074], [ 0.30640858], [ 0.89578031],
+  [ 0.84621571], [ 0.11783439], [ 0.0944695 ], [ 0.34081575], [ 0.44157643],
+  [ 0.77847185], [ 0.04283567], [ 0.45107823], [ 0.89789891], [ 0.41045519],
+  [ 0.49073531], [ 0.29727627], [ 0.94711483], [ 0.24898204], [ 0.26181212],
+  [ 0.71760957], [ 0.60326883], [ 0.80887576], [ 0.09448718], [ 0.88064525],
+  [ 0.84317654], [ 0.48893703], [ 0.24847021], [ 0.84203596], [ 0.34104156],
+  [ 0.75604701], [ 0.91703057], [ 0.69325475], [ 0.61276969], [ 0.16335226],
+  [ 0.4684374 ], [ 0.16553371], [ 0.79594434], [ 0.6440283 ], [ 0.80922237],
+  [ 0.5349296 ], [ 0.31924316], [ 0.10960695], [ 0.40151062], [ 0.50473641],
+  [ 0.14812671], [ 0.73523169], [ 0.35141625], [ 0.80364238], [ 0.02128181],
+  [ 0.0061226 ], [ 0.34541924], [ 0.07694485], [ 0.05551339], [ 0.23087636],
+  [ 0.87016395], [ 0.31682377], [ 0.27375113], [ 0.72226332], [ 0.62914149],
+  [ 0.59236012], [ 0.2070238 ], [ 0.52390942], [ 0.11894098], [ 0.55725917],
+  [ 0.72706009], [ 0.087196  ], [ 0.04745082], [ 0.95636492], [ 0.31524576],
+  [ 0.79685218], [ 0.80386771], [ 0.70942604], [ 0.82869417], [ 0.26906569],
+  [ 0.51848039], [ 0.64169354], [ 0.07114973], [ 0.39249454], [ 0.07002803],
+  [ 0.94667567], [ 0.02252752], [ 0.01039039], [ 0.5721312 ], [ 0.06065969],
+  [ 0.69422476], [ 0.4310939 ], [ 0.03069099], [ 0.35969779], [ 0.18047331],
+  [ 0.4177651 ], [ 0.01360547], [ 0.29069319]])
+
+
 ###########################################################
 #
 # The parameters for the QPalma algorithm
 ###########################################################
 #
 # The parameters for the QPalma algorithm
@@ -85,8 +113,8 @@ C = 100.0
 # 'normal' means work like Palma 'using_quality_scores' means work like Palma
 # plus using sequencing quality scores
 
 # 'normal' means work like Palma 'using_quality_scores' means work like Palma
 # plus using sequencing quality scores
 
-#mode = 'normal'
-mode = 'using_quality_scores'
+mode = 'normal'
+#mode = 'using_quality_scores'
 
 # Here we specify the total number of parameters.
 
 
 # Here we specify the total number of parameters.
 
@@ -123,7 +151,7 @@ totalQualSuppPoints = numQualPlifs*numQualSuppPoints
 numFeatures = numDonSuppPoints + numAccSuppPoints\
 + numLengthSuppPoints + sizeMatchmatrix[0]*sizeMatchmatrix[1] + totalQualSuppPoints 
 
 numFeatures = numDonSuppPoints + numAccSuppPoints\
 + numLengthSuppPoints + sizeMatchmatrix[0]*sizeMatchmatrix[1] + totalQualSuppPoints 
 
-iter_steps = 2
+iter_steps = 10
 remove_duplicate_scores = False
 print_matrix            = False
 anzpath                 = 2
 remove_duplicate_scores = False
 print_matrix            = False
 anzpath                 = 2
index 2cfc5f5..646df38 100644 (file)
@@ -76,7 +76,8 @@ def  computeSpliceAlignWithQuality(dna, exons):
       if elem == 'n':
          numChar[4] += 1
 
       if elem == 'n':
          numChar[4] += 1
 
-      trueWeightQuality[base_coord(elem,elem)*Configuration.numQualSuppPoints+Configuration.numQualSuppPoints-1] += 1.0
+      if Configuration.mode == 'using_quality_scores':
+         trueWeightQuality[base_coord(elem,elem)*Configuration.numQualSuppPoints+Configuration.numQualSuppPoints-1] += 1.0
 
    totalNumChar = 0
    for idx in range(sizeMatchmatrix[0]):
 
    totalNumChar = 0
    for idx in range(sizeMatchmatrix[0]):
@@ -86,10 +87,9 @@ def  computeSpliceAlignWithQuality(dna, exons):
 
    # writing in weight match matrix
    # matrix is saved columnwise
 
    # writing in weight match matrix
    # matrix is saved columnwise
-   print numChar
    trueWeightMatch = zeros((sizeMatchmatrix[0],sizeMatchmatrix[1])) # Scorematrix fuer Wahrheit
    trueWeightMatch = zeros((sizeMatchmatrix[0],sizeMatchmatrix[1])) # Scorematrix fuer Wahrheit
-   for idx in range(sizeMatchmatrix[0]-1):
-      trueWeightMatch[idx,idx] = numChar[idx]
+   for idx in range(1,sizeMatchmatrix[0]):
+      trueWeightMatch[idx,idx] = numChar[idx-1]
 
    trueWeightMatch = trueWeightMatch.reshape(sizeMatchmatrix[0]*sizeMatchmatrix[1],1)
 
 
    trueWeightMatch = trueWeightMatch.reshape(sizeMatchmatrix[0]*sizeMatchmatrix[1],1)
 
index be14889..9f47d33 100644 (file)
@@ -68,8 +68,10 @@ class QPalma:
       # Load the whole dataset 
       if Configuration.mode == 'normal':
          Sequences, Acceptors, Donors, Exons, Ests, Noises = paths_load_data_pickle('training',self.genome_info,self.ARGS)
       # Load the whole dataset 
       if Configuration.mode == 'normal':
          Sequences, Acceptors, Donors, Exons, Ests, Noises = paths_load_data_pickle('training',self.genome_info,self.ARGS)
+         use_quality_scores = False
       elif Configuration.mode == 'using_quality_scores':
          Sequences, Acceptors, Donors, Exons, Ests, Qualities = paths_load_data_solexa('training',self.genome_info,self.ARGS)
       elif Configuration.mode == 'using_quality_scores':
          Sequences, Acceptors, Donors, Exons, Ests, Qualities = paths_load_data_solexa('training',self.genome_info,self.ARGS)
+         use_quality_scores = True
       else:
          assert(False)
 
       else:
          assert(False)
 
@@ -132,15 +134,20 @@ class QPalma:
          if iteration_nr == iteration_steps:
             break
 
          if iteration_nr == iteration_steps:
             break
 
-         #for exampleIdx in range(self.numExamples):
-         for exampleIdx in range(6,11):
+         for exampleIdx in range(self.numExamples):
+
             if (exampleIdx%10) == 0:
                print 'Current example nr %d' % exampleIdx
 
             dna = Sequences[exampleIdx] 
             est = Ests[exampleIdx] 
             if (exampleIdx%10) == 0:
                print 'Current example nr %d' % exampleIdx
 
             dna = Sequences[exampleIdx] 
             est = Ests[exampleIdx] 
-            quality = Qualities[exampleIdx]
-            quality = [40]*len(quality )
+
+            if Configuration.mode == 'normal':
+               quality = [40]*len(est)
+
+            if Configuration.mode == 'using_quality_scores':
+               quality = Qualities[exampleIdx]
+
             exons = Exons[exampleIdx] 
             # NoiseMatrix = Noises[exampleIdx] 
             don_supp = Donors[exampleIdx] 
             exons = Exons[exampleIdx] 
             # NoiseMatrix = Noises[exampleIdx] 
             don_supp = Donors[exampleIdx] 
@@ -151,15 +158,16 @@ class QPalma:
             
             # Calculate the weights
             trueWeightDon, trueWeightAcc, trueWeightIntron = computeSpliceWeights(d, a, h, trueSpliceAlign, don_supp, acc_supp)
             
             # Calculate the weights
             trueWeightDon, trueWeightAcc, trueWeightIntron = computeSpliceWeights(d, a, h, trueSpliceAlign, don_supp, acc_supp)
-
             trueWeight = numpy.vstack([trueWeightIntron, trueWeightDon, trueWeightAcc, trueWeightMatch, trueWeightQuality])
             trueWeight = numpy.vstack([trueWeightIntron, trueWeightDon, trueWeightAcc, trueWeightMatch, trueWeightQuality])
-            totalQualityPenalties = param[-totalQualSP:]
 
             currentPhi[0:donSP]                                               = mat(d.penalties[:]).reshape(donSP,1)
             currentPhi[donSP:donSP+accSP]                                     = mat(a.penalties[:]).reshape(accSP,1)
             currentPhi[donSP+accSP:donSP+accSP+lengthSP]                      = mat(h.penalties[:]).reshape(lengthSP,1)
             currentPhi[donSP+accSP+lengthSP:donSP+accSP+lengthSP+mmatrixSP]   = mmatrix[:]
 
             currentPhi[0:donSP]                                               = mat(d.penalties[:]).reshape(donSP,1)
             currentPhi[donSP:donSP+accSP]                                     = mat(a.penalties[:]).reshape(accSP,1)
             currentPhi[donSP+accSP:donSP+accSP+lengthSP]                      = mat(h.penalties[:]).reshape(lengthSP,1)
             currentPhi[donSP+accSP+lengthSP:donSP+accSP+lengthSP+mmatrixSP]   = mmatrix[:]
-            currentPhi[donSP+accSP+lengthSP+mmatrixSP:]                       = totalQualityPenalties[:]
+
+            if Configuration.mode == 'using_quality_scores':
+               totalQualityPenalties = param[-totalQualSP:]
+               currentPhi[donSP+accSP+lengthSP+mmatrixSP:]                       = totalQualityPenalties[:]
 
             # Calculate w'phi(x,y) the total score of the alignment
             trueAlignmentScore = (trueWeight.T * currentPhi)[0,0]
 
             # Calculate w'phi(x,y) the total score of the alignment
             trueAlignmentScore = (trueWeight.T * currentPhi)[0,0]
@@ -173,6 +181,7 @@ class QPalma:
             AlignmentScores = [0.0]*(num_path[exampleIdx]+1)
             AlignmentScores[0] = trueAlignmentScore
 
             AlignmentScores = [0.0]*(num_path[exampleIdx]+1)
             AlignmentScores[0] = trueAlignmentScore
 
+
             ################## Calculate wrong alignment(s) ######################
 
             # Compute donor, acceptor with penalty_lookup_new
             ################## Calculate wrong alignment(s) ######################
 
             # Compute donor, acceptor with penalty_lookup_new
@@ -186,7 +195,6 @@ class QPalma:
             # for now we don't use donor/acceptor scores
             donor = [-inf] * len(donor)
             acceptor = [-inf] * len(donor)
             # for now we don't use donor/acceptor scores
             donor = [-inf] * len(donor)
             acceptor = [-inf] * len(donor)
-            # 
 
             dna = str(dna)
             est = str(est)
 
             dna = str(dna)
             est = str(est)
@@ -212,9 +220,10 @@ class QPalma:
             # calculates SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest
             currentAlignment.myalign( num_path[exampleIdx], dna, dna_len,\
              est, est_len, prb, chastity, ps, matchmatrix, mm_len, donor, d_len,\
             # calculates SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest
             currentAlignment.myalign( num_path[exampleIdx], dna, dna_len,\
              est, est_len, prb, chastity, ps, matchmatrix, mm_len, donor, d_len,\
-             acceptor, a_len, c_qualityPlifs, remove_duplicate_scores, print_matrix)
+             acceptor, a_len, c_qualityPlifs, remove_duplicate_scores,
+             print_matrix, use_quality_scores)
 
 
-            print 'Python: after myalign...'
+            #print 'Python: after myalign...'
 
             c_SpliceAlign       = QPalmaDP.createIntArrayFromList([0]*(dna_len*num_path[exampleIdx]))
             c_EstAlign          = QPalmaDP.createIntArrayFromList([0]*(est_len*num_path[exampleIdx]))
 
             c_SpliceAlign       = QPalmaDP.createIntArrayFromList([0]*(dna_len*num_path[exampleIdx]))
             c_EstAlign          = QPalmaDP.createIntArrayFromList([0]*(est_len*num_path[exampleIdx]))
@@ -226,7 +235,7 @@ class QPalma:
             currentAlignment.getAlignmentResults(c_SpliceAlign, c_EstAlign,\
             c_WeightMatch, c_AlignmentScores, c_qualityPlifsFeatures)
 
             currentAlignment.getAlignmentResults(c_SpliceAlign, c_EstAlign,\
             c_WeightMatch, c_AlignmentScores, c_qualityPlifsFeatures)
 
-            print 'Python: after getAlignmentResults...'
+            #print 'Python: after getAlignmentResults...'
 
             newSpliceAlign = zeros((num_path[exampleIdx]*dna_len,1))
             newEstAlign = zeros((est_len*num_path[exampleIdx],1))
 
             newSpliceAlign = zeros((num_path[exampleIdx]*dna_len,1))
             newEstAlign = zeros((est_len*num_path[exampleIdx],1))
@@ -252,7 +261,19 @@ class QPalma:
             for i in range(num_path[exampleIdx]):
                AlignmentScores[i+1] = c_AlignmentScores[i]
 
             for i in range(num_path[exampleIdx]):
                AlignmentScores[i+1] = c_AlignmentScores[i]
 
+            for i in range(Configuration.numQualSuppPoints*Configuration.numQualPlifs*num_path[exampleIdx]):
+               newQualityPlifsFeatures[i] = c_qualityPlifsFeatures[i]
+
+            #  equals palma up to here
+            pdb.set_trace()
 
 
+            # print "Calling destructors"
+            del c_SpliceAlign
+            del c_EstAlign
+            del c_WeightMatch
+            del c_AlignmentScores
+            del c_qualityPlifsFeatures
+            del currentAlignment
 
             newSpliceAlign = newSpliceAlign.reshape(num_path[exampleIdx],dna_len)
             newWeightMatch = newWeightMatch.reshape(num_path[exampleIdx],mm_len)
 
             newSpliceAlign = newSpliceAlign.reshape(num_path[exampleIdx],dna_len)
             newWeightMatch = newWeightMatch.reshape(num_path[exampleIdx],mm_len)
@@ -267,17 +288,17 @@ class QPalma:
             true_map[0] = 1
             path_loss = [0]*(num_path[exampleIdx]+1)
 
             true_map[0] = 1
             path_loss = [0]*(num_path[exampleIdx]+1)
 
-            print 'Calculating decoded features'
+            #print 'Calculating decoded features'
 
             for pathNr in range(num_path[exampleIdx]):
                weightDon, weightAcc, weightIntron = computeSpliceWeights(d, a, h, newSpliceAlign[pathNr,:].flatten().tolist()[0], don_supp, acc_supp)
 
                decodedQualityFeatures = zeros((Configuration.totalQualSuppPoints,1))
 
 
             for pathNr in range(num_path[exampleIdx]):
                weightDon, weightAcc, weightIntron = computeSpliceWeights(d, a, h, newSpliceAlign[pathNr,:].flatten().tolist()[0], don_supp, acc_supp)
 
                decodedQualityFeatures = zeros((Configuration.totalQualSuppPoints,1))
 
-               print "Calculating pathNr %d" % pathNr
+               #print "Calculating pathNr %d" % pathNr
 
 
-               #for qidx in range(Configuration.numQualPlifs*pathNr,Configuration.numQualPlifs*(pathNr+1)):
-               #   decodedQualityFeatures[qidx%Configuration.numQualPlifs] = c_qualityPlifsFeatures[1]
+               for qidx in range(Configuration.numQualPlifs*pathNr,Configuration.numQualPlifs*(pathNr+1)):
+                  decodedQualityFeatures[qidx%Configuration.numQualPlifs] = newQualityPlifsFeatures[qidx]
 
                # sum up positionwise loss between alignments
                for alignPosIdx in range(len(newSpliceAlign[pathNr,:])):
 
                # sum up positionwise loss between alignments
                for alignPosIdx in range(len(newSpliceAlign[pathNr,:])):
@@ -323,7 +344,7 @@ class QPalma:
                   trueWeights       = allWeights[:,0]
                   firstFalseWeights = allWeights[:,firstFalseIdx]
                   differenceVector  = firstFalseWeights - trueWeights
                   trueWeights       = allWeights[:,0]
                   firstFalseWeights = allWeights[:,firstFalseIdx]
                   differenceVector  = firstFalseWeights - trueWeights
-                  #pdb.set_trace()
+                  pdb.set_trace()
 
                   if not __debug__:
                      const_added = solver.addConstraint(differenceVector, exampleIdx)
 
                   if not __debug__:
                      const_added = solver.addConstraint(differenceVector, exampleIdx)
@@ -331,19 +352,9 @@ class QPalma:
                #
                # end of one example processing 
                #
                #
                # end of one example processing 
                #
-            print "Calling destructors"
-            del c_SpliceAlign
-            del c_EstAlign
-            del c_WeightMatch
-            del c_AlignmentScores
-
-            print 'rest of destructors'
-
-            del c_qualityPlifsFeatures
-            del currentAlignment
 
             # call solver every nth step
 
             # call solver every nth step
-            if exampleIdx != 0 and exampleIdx % 3 == 0 and not __debug__:
+            if exampleIdx != 0 and exampleIdx % 10 == 0 and not __debug__:
                objValue,w,self.slacks = solver.solve()
       
                print "objValue is %f" % objValue
                objValue,w,self.slacks = solver.solve()
       
                print "objValue is %f" % objValue