+ fixded index bug in feature count
[qpalma.git] / QPalmaDP / result_align.cpp
index 20dd4eb..85778f8 100644 (file)
@@ -5,34 +5,40 @@ using namespace std;
 
 void increaseFeatureCount(penalty_struct* qparam, int dnanum, int estnum, double estprb) {
 
-   penalty_struct currentStruct = qparam[(estnum-1)*6+(dnanum)];
-   printf("Current index %d dna/est: %d %d\n",(estnum-1)*6+(dnanum),dnanum,estnum);
-
-      printf("before\n");
-      int p_idx;
-      for(p_idx=0;p_idx<currentStruct.len;p_idx++) {
-         printf("%f ",currentStruct.limits[p_idx]);
-      }
-      printf("\n");
+   //printf("Current index %d dna/est: %d %d\n",(estnum-1)*6+(dnanum),dnanum,estnum);
+   int currentPos = (estnum-1)*6+(dnanum);
+   penalty_struct currentStruct = qparam[currentPos];
+
+      //printf("before\n");
+      //int p_idx;
+      //for(p_idx=0;p_idx<currentStruct.len;p_idx++) {
+      //   printf("%f ",currentStruct.limits[p_idx]);
+      //}
+      //printf("\n");
    
-      for(p_idx=0;p_idx<currentStruct.len;p_idx++) {
-         printf("%f ",currentStruct.penalties[p_idx]);
-      }
-      printf("\n");
+      //for(p_idx=0;p_idx<currentStruct.len;p_idx++) {
+      //   printf("%f ",currentStruct.penalties[p_idx]);
+      //}
+      //printf("\n");
 
    double value = estprb;
    int Lower = 0;
    int idx;
+
    for (idx=0;idx<currentStruct.len;idx++) {
       if (currentStruct.limits[idx] <= value)
          Lower++;
    }
 
-   if (Lower == 0)
+   if (Lower == 0) {
          currentStruct.penalties[0] += 1;
+         return;
+   }
 
-   if (Lower == currentStruct.len)
+   if (Lower == (currentStruct.len-1)) {
          currentStruct.penalties[currentStruct.len-1] += 1;
+         return;
+   }
 
    Lower -= 1;
    int Upper = Lower+1; // x-werte bleiben fest
@@ -44,16 +50,16 @@ void increaseFeatureCount(penalty_struct* qparam, int dnanum, int estnum, double
 
    //printf("estprb/Lower/Upper %f %d %d\n",estprb,Lower,Upper);
 
-   qparam[(estnum-1)*5+(dnanum-1)] = currentStruct;
+   qparam[currentPos] = currentStruct;
 
-   printf("after\n");
-   for(p_idx=0;p_idx<currentStruct.len;p_idx++) {
-      printf("%f ",currentStruct.limits[p_idx]);
-   }
-   printf("\n");
-   for(p_idx=0;p_idx<currentStruct.len;p_idx++)
-      printf("%f ",currentStruct.penalties[p_idx]);
-   printf("\n");
+   //printf("after\n");
+   //for(p_idx=0;p_idx<currentStruct.len;p_idx++) {
+   //   printf("%f ",currentStruct.limits[p_idx]);
+   //}
+   //printf("\n");
+   //for(p_idx=0;p_idx<currentStruct.len;p_idx++)
+   //   printf("%f ",currentStruct.penalties[p_idx]);
+   //printf("\n");
 }
 
 bool result_align(Pre_score* matrices[], int z, int est_len, int dna_len, int* result_length_ptr, char* est, char* dna, double* prb, double* chastity, int* s_align, int* e_align, int* mparam, double* alignmentscores, int* max_score_positions, penalty_struct* qparam, mode currentMode)
@@ -70,6 +76,7 @@ bool result_align(Pre_score* matrices[], int z, int est_len, int dna_len, int* r
 
   double prbnum ;
   double chastitynum ;
+
   
   int dna_pos ;
   int est_pos ;
@@ -111,6 +118,7 @@ bool result_align(Pre_score* matrices[], int z, int est_len, int dna_len, int* r
   splice_state = 0 ; //exon
   est_state = 1 ; //[112222111 ... for exons of length 2,4,3 ...
 
+
   //compute length of alignment (between max(m,n) and m+n)     
   //local_alignment: backtracking to first Zero: look at actual value
   while(!(((Pre_score*)matrices[act_m_no] + i*dna_len +j)->value)==0.0) {