+ fixed Swig/python double free bug
[qpalma.git] / python / qpalma.py
index fc7bb3d..be14889 100644 (file)
@@ -221,16 +221,17 @@ class QPalma:
             c_WeightMatch       = QPalmaDP.createIntArrayFromList([0]*(mm_len*num_path[exampleIdx]))
             c_AlignmentScores   = QPalmaDP.createDoubleArrayFromList([.0]*num_path[exampleIdx])
 
-            c_qualityPlifsFeatures = QPalmaDP.createDoubleArrayFromList([.0]*(Configuration.numQualPlifs*num_path[exampleIdx]))
+            c_qualityPlifsFeatures = QPalmaDP.createDoubleArrayFromList([.0]*(Configuration.numQualSuppPoints*Configuration.numQualPlifs*num_path[exampleIdx]))
 
-            #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...'
 
             newSpliceAlign = zeros((num_path[exampleIdx]*dna_len,1))
             newEstAlign = zeros((est_len*num_path[exampleIdx],1))
             newWeightMatch = zeros((num_path[exampleIdx]*mm_len,1))
+            newQualityPlifsFeatures = zeros((Configuration.numQualSuppPoints*Configuration.numQualPlifs*num_path[exampleIdx],1))
 
             #print 'newSpliceAlign'
             for i in range(dna_len*num_path[exampleIdx]):
@@ -251,13 +252,7 @@ class QPalma:
             for i in range(num_path[exampleIdx]):
                AlignmentScores[i+1] = c_AlignmentScores[i]
 
-            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)
@@ -279,6 +274,8 @@ class QPalma:
 
                decodedQualityFeatures = zeros((Configuration.totalQualSuppPoints,1))
 
+               print "Calculating pathNr %d" % pathNr
+
                #for qidx in range(Configuration.numQualPlifs*pathNr,Configuration.numQualPlifs*(pathNr+1)):
                #   decodedQualityFeatures[qidx%Configuration.numQualPlifs] = c_qualityPlifsFeatures[1]
 
@@ -334,6 +331,16 @@ class QPalma:
                #
                # 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
             if exampleIdx != 0 and exampleIdx % 3 == 0 and not __debug__: