+ fixded index bug in feature count
[qpalma.git] / QPalmaDP / result_align.cpp
index c98b36b..85778f8 100644 (file)
@@ -6,7 +6,8 @@ using namespace std;
 void increaseFeatureCount(penalty_struct* qparam, int dnanum, int estnum, double estprb) {
 
    //printf("Current index %d dna/est: %d %d\n",(estnum-1)*6+(dnanum),dnanum,estnum);
-   penalty_struct currentStruct = qparam[(estnum-1)*6+(dnanum)];
+   int currentPos = (estnum-1)*6+(dnanum);
+   penalty_struct currentStruct = qparam[currentPos];
 
       //printf("before\n");
       //int p_idx;
@@ -23,6 +24,7 @@ void increaseFeatureCount(penalty_struct* qparam, int dnanum, int estnum, double
    double value = estprb;
    int Lower = 0;
    int idx;
+
    for (idx=0;idx<currentStruct.len;idx++) {
       if (currentStruct.limits[idx] <= value)
          Lower++;
@@ -33,7 +35,7 @@ void increaseFeatureCount(penalty_struct* qparam, int dnanum, int estnum, double
          return;
    }
 
-   if (Lower == currentStruct.len) {
+   if (Lower == (currentStruct.len-1)) {
          currentStruct.penalties[currentStruct.len-1] += 1;
          return;
    }
@@ -48,7 +50,7 @@ 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++) {