+ fixed some index bugs in the weights calculation
[qpalma.git] / python / qpalma.py
index 51ee5c7..3277d43 100644 (file)
@@ -162,11 +162,12 @@ def run():
 
          # Berechne die Parameter des wirklichen Alignments (but with untrained d,a,h ...)    
          trueSpliceAlign, trueWeightMatch = computeSpliceAlign(dna, exons)
+         
+         pdb.set_trace()
 
          # Calculate
          trueWeightDon, trueWeightAcc, trueWeightIntron = computeSpliceWeights(d, a, h, trueSpliceAlign, don_supp, acc_supp)
 
-
          # Reshape currentW param 
          currentW = zeros((numFeatures,1))
       
@@ -177,9 +178,9 @@ def run():
          currentW[numDonSuppPoints+numAccSuppPoints+numLengthSuppPoints+sizeMMatrix:numDonSuppPoints+numAccSuppPoints+numLengthSuppPoints+sizeMMatrix+numQualSuppPoints,0] = qualityMatrix[:,0]
 
          currentPhi = zeros((numFeatures,1))
-         currentPhi[0:30]     = d.penalties[:]
-         currentPhi[30:60]    = a.penalties[:]
-         currentPhi[60:90]    = h.penalties[:]
+         currentPhi[0:30]     = mat(d.penalties[:]).reshape(30,1)
+         currentPhi[30:60]    = mat(a.penalties[:]).reshape(30,1)
+         currentPhi[60:90]    = mat(h.penalties[:]).reshape(30,1)
          currentPhi[90:126]   = mmatrix[:]
          currentPhi[126:]   = qualityMatrix[:]
 
@@ -204,38 +205,41 @@ def run():
          dna_len = len(dna)
          est_len = len(est)
 
+         ps = h.convert2SWIG()
+
          matchmatrix = QPalmaDP.createDoubleArrayFromList(mmatrix.flatten().tolist()[0])
          mm_len = 36
-         donor = QPalmaDP.createDoubleArrayFromList([1,2.0,4])
-         d_len = 3
-         acceptor = QPalmaDP.createDoubleArrayFromList([.1,2,4])
-         a_len = 3
+
+         d_len = len(donor)
+         donor = QPalmaDP.createDoubleArrayFromList(donor)
+         a_len = len(acceptor)
+         acceptor = QPalmaDP.createDoubleArrayFromList(acceptor)
+
          remove_duplicate_scores = False
          print_matrix = False
 
          currentAlignment = QPalmaDP.Alignment()
-
          qualityMat = QPalmaDP.createDoubleArrayFromList(qualityMatrix)
          currentAlignment.setQualityMatrix(qualityMat,numQualSuppPoints)
-         ps = h.convert2SWIG()
 
+         print 'PYTHON: Calling myalign...'
          # returns [SpliceAlign, EstAlign, weightMatch, Gesamtscores, dnaest]
          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)
 
-         newSpliceAlign       = QPalmaDP.createIntArrayFromList([0]*(dna_len*nr_paths))
-         newEstAlign          = QPalmaDP.createIntArrayFromList([0]*(est_len*nr_paths))
-         newWeightMatch       = QPalmaDP.createIntArrayFromList([0]*(mm_len*nr_paths))
-         newAlignmentScores   = QPalmaDP.createDoubleArrayFromList([.0]*nr_paths)
+         #newSpliceAlign       = QPalmaDP.createIntArrayFromList([0]*(dna_len*nr_paths))
+         #newEstAlign          = QPalmaDP.createIntArrayFromList([0]*(est_len*nr_paths))
+         #newWeightMatch       = QPalmaDP.createIntArrayFromList([0]*(mm_len*nr_paths))
+         #newAlignmentScores   = QPalmaDP.createDoubleArrayFromList([.0]*nr_paths)
 
-         currentAlignment.getAlignmentResults(newSpliceAlign, newEstAlign, newWeightMatch, newAlignmentScores)
+         #currentAlignment.getAlignmentResults(newSpliceAlign, newEstAlign, newWeightMatch, newAlignmentScores)
 
-         print newSpliceAlign
+         #print newSpliceAlign
 
          print 'after myalign call...'
 
-         if iteration_nr == 2:
+         if exampleId == 2:
             break
 
       iteration_nr += 1