Program: 169247
Project: 169247
Buggy source:
public OverlapInfo getFullScore(OrderKmerHashes s,double maxShiftPercent){
  int[][][] allKmerHashes=this.orderedHashes;
  int[][][] sAllKmerHashes=s.orderedHashes;
  int size1=this.size();
  int size2=s.size();
  int valid1Lower=0;
  int valid1Upper=size1;
  int valid2Lower=0;
  int valid2Upper=size2;
  int medianShift=0;
  int overlapSize=Math.min(size1,size2);
  int absMaxShiftInOverlap=Math.max(size1,size2);
  int count=0;
  int[] posShift=new int[Math.min(size1,size2) / 8 + 1];
  int[] pos1Index=new int[posShift.length];
  int[] pos2Index=new int[posShift.length];
  int numScoringRepeats=2;
  if (maxShiftPercent <= 0) {
    numScoringRepeats=1;
    maxShiftPercent=Math.abs(maxShiftPercent);
  }
  for (int repeat=0; repeat < numScoringRepeats; repeat++) {
    count=0;
    int ii1=0;
    int ii2=0;
    int i1=0;
    int i2=0;
    int hash1=0;
    int hash2=0;
    int pos1;
    int pos2;
    while (true) {
      if (i1 >= allKmerHashes[ii1].length) {
        ii1++;
        i1=0;
        if (ii1 >= allKmerHashes.length)         break;
      }
      if (i2 >= sAllKmerHashes[ii2].length) {
        ii2++;
        i2=0;
        if (ii2 >= sAllKmerHashes.length)         break;
      }
      hash1=allKmerHashes[ii1][i1][0];
      pos1=allKmerHashes[ii1][i1][1];
      hash2=sAllKmerHashes[ii2][i2][0];
      pos2=sAllKmerHashes[ii2][i2][1];
      if (hash1 < hash2 || pos1 < valid1Lower || pos1 >= valid1Upper)       i1++;
 else       if (hash2 < hash1 || pos2 < valid2Lower || pos2 >= valid2Upper)       i2++;
 else {
        int currShift=pos2 - pos1;
        if (Math.abs(currShift - medianShift) > absMaxShiftInOverlap) {
          i2++;
          continue;
        }
        if (posShift.length <= count) {
          posShift=Arrays.copyOf(posShift,posShift.length * 2);
          pos1Index=Arrays.copyOf(pos1Index,pos1Index.length * 2);
          pos2Index=Arrays.copyOf(pos2Index,pos2Index.length * 2);
        }
        posShift[count]=currShift;
        pos1Index[count]=pos1;
        pos2Index[count]=pos2;
        count++;
        i2++;
      }
    }
    if (count > 0) {
      if (repeat > 0) {
        int reducedCount=-1;
        for (int iter=0; iter < count; iter++) {
          if (reducedCount >= 0 && pos1Index[reducedCount] == pos1Index[iter]) {
            if (Math.abs(posShift[reducedCount] - medianShift) > Math.abs(posShift[iter] - medianShift)) {
              pos1Index[reducedCount]=pos1Index[iter];
              pos2Index[reducedCount]=pos2Index[iter];
              posShift[reducedCount]=posShift[iter];
            }
          }
 else {
            reducedCount++;
            pos1Index[reducedCount]=pos1Index[iter];
            pos2Index[reducedCount]=pos2Index[iter];
            posShift[reducedCount]=posShift[iter];
          }
        }
        count=reducedCount + 1;
      }
      medianShift=Utils.quickSelect(posShift,count / 2,count);
    }
 else     medianShift=0;
    int leftPosition=Math.max(0,medianShift);
    int rightPosition=Math.min(size2,size1 + medianShift);
    overlapSize=Math.max(50,rightPosition - leftPosition);
    absMaxShiftInOverlap=Math.min(Math.max(size1,size2),(int)((double)overlapSize * maxShiftPercent));
    valid1Lower=Math.max(0,-medianShift - absMaxShiftInOverlap);
    valid1Upper=Math.min(size1,size2 - medianShift + absMaxShiftInOverlap);
    valid2Lower=Math.max(0,medianShift - absMaxShiftInOverlap);
    valid2Upper=Math.min(size2,size1 + medianShift + absMaxShiftInOverlap);
  }
  int leftEdge1=Integer.MAX_VALUE;
  int leftEdge2=Integer.MAX_VALUE;
  int rightEdge1=Integer.MIN_VALUE;
  int rightEdge2=Integer.MIN_VALUE;
  int validCount=0;
  for (int iter=0; iter < count; iter++) {
    int pos1=pos1Index[iter];
    int pos2=pos2Index[iter];
    if (Math.abs(posShift[iter] - medianShift) > absMaxShiftInOverlap)     continue;
    if (pos1 < leftEdge1)     leftEdge1=pos1;
    if (pos2 < leftEdge2)     leftEdge2=pos2;
    if (pos1 > rightEdge1)     rightEdge1=pos1;
    if (pos2 > rightEdge2)     rightEdge2=pos2;
    validCount++;
  }
  int gap1=(int)Math.round((rightEdge1 - validCount) / (double)validCount);
  int gap2=(int)Math.round((rightEdge2 - validCount) / (double)validCount);
  int a1=Math.max(0,leftEdge1 - gap1);
  int a2=Math.max(0,leftEdge2 - gap2);
  int b1=Math.min(this.size() + 20,rightEdge1 + gap1);
  int b2=Math.min(s.size() + 20,rightEdge2 + gap2);
  int ahang=a1 - a2;
  int bhang=(this.size() - b1 > s.size() - b2) ? b1 - this.size() : s.size() - b2;
  double score=(double)validCount / (double)(overlapSize);
  return new OverlapInfo(score,ahang,bhang);
}

Fixed version (ground truth):
public OverlapInfo getFullScore(OrderKmerHashes s,double maxShiftPercent){
  int[][][] allKmerHashes=this.orderedHashes;
  int[][][] sAllKmerHashes=s.orderedHashes;
  int size1=this.size();
  int size2=s.size();
  int valid1Lower=0;
  int valid1Upper=size1;
  int valid2Lower=0;
  int valid2Upper=size2;
  int medianShift=0;
  int overlapSize=Math.min(size1,size2);
  int absMaxShiftInOverlap=Math.max(size1,size2);
  int count=0;
  int[] posShift=new int[Math.min(size1,size2) / 8 + 1];
  int[] pos1Index=new int[posShift.length];
  int[] pos2Index=new int[posShift.length];
  int numScoringRepeats=2;
  if (maxShiftPercent <= 0) {
    numScoringRepeats=1;
    maxShiftPercent=Math.abs(maxShiftPercent);
  }
  for (int repeat=0; repeat < numScoringRepeats; repeat++) {
    count=0;
    int ii1=0;
    int ii2=0;
    int i1=0;
    int i2=0;
    int hash1=0;
    int hash2=0;
    int pos1;
    int pos2;
    while (true) {
      if (i1 >= allKmerHashes[ii1].length) {
        ii1++;
        i1=0;
        if (ii1 >= allKmerHashes.length)         break;
      }
      if (i2 >= sAllKmerHashes[ii2].length) {
        ii2++;
        i2=0;
        if (ii2 >= sAllKmerHashes.length)         break;
      }
      hash1=allKmerHashes[ii1][i1][0];
      pos1=allKmerHashes[ii1][i1][1];
      hash2=sAllKmerHashes[ii2][i2][0];
      pos2=sAllKmerHashes[ii2][i2][1];
      if (hash1 < hash2 || pos1 < valid1Lower || pos1 >= valid1Upper)       i1++;
 else       if (hash2 < hash1 || pos2 < valid2Lower || pos2 >= valid2Upper)       i2++;
 else {
        int currShift=pos2 - pos1;
        if (Math.abs(currShift - medianShift) > absMaxShiftInOverlap) {
          i2++;
          continue;
        }
        if (posShift.length <= count) {
          posShift=Arrays.copyOf(posShift,posShift.length * 2);
          pos1Index=Arrays.copyOf(pos1Index,pos1Index.length * 2);
          pos2Index=Arrays.copyOf(pos2Index,pos2Index.length * 2);
        }
        posShift[count]=currShift;
        pos1Index[count]=pos1;
        pos2Index[count]=pos2;
        count++;
        i2++;
      }
    }
    if (count > 0) {
      if (repeat > 0) {
        int reducedCount=-1;
        for (int iter=0; iter < count; iter++) {
          if (reducedCount >= 0 && pos1Index[reducedCount] == pos1Index[iter]) {
            if (Math.abs(posShift[reducedCount] - medianShift) > Math.abs(posShift[iter] - medianShift)) {
              pos1Index[reducedCount]=pos1Index[iter];
              pos2Index[reducedCount]=pos2Index[iter];
              posShift[reducedCount]=posShift[iter];
            }
          }
 else {
            reducedCount++;
            pos1Index[reducedCount]=pos1Index[iter];
            pos2Index[reducedCount]=pos2Index[iter];
            posShift[reducedCount]=posShift[iter];
          }
        }
        count=reducedCount + 1;
      }
      medianShift=Utils.quickSelect(Arrays.copyOf(posShift,count),count / 2,count);
    }
 else     medianShift=0;
    int leftPosition=Math.max(0,medianShift);
    int rightPosition=Math.min(size2,size1 + medianShift);
    overlapSize=Math.max(50,rightPosition - leftPosition);
    absMaxShiftInOverlap=Math.min(Math.max(size1,size2),(int)((double)overlapSize * maxShiftPercent));
    valid1Lower=Math.max(0,-medianShift - absMaxShiftInOverlap);
    valid1Upper=Math.min(size1,size2 - medianShift + absMaxShiftInOverlap);
    valid2Lower=Math.max(0,medianShift - absMaxShiftInOverlap);
    valid2Upper=Math.min(size2,size1 + medianShift + absMaxShiftInOverlap);
  }
  int leftEdge1=Integer.MAX_VALUE;
  int leftEdge2=Integer.MAX_VALUE;
  int rightEdge1=Integer.MIN_VALUE;
  int rightEdge2=Integer.MIN_VALUE;
  int validCount=0;
  for (int iter=0; iter < count; iter++) {
    int pos1=pos1Index[iter];
    int pos2=pos2Index[iter];
    if (Math.abs(posShift[iter] - medianShift) > absMaxShiftInOverlap)     continue;
    if (pos1 < leftEdge1)     leftEdge1=pos1;
    if (pos2 < leftEdge2)     leftEdge2=pos2;
    if (pos1 > rightEdge1)     rightEdge1=pos1;
    if (pos2 > rightEdge2)     rightEdge2=pos2;
    validCount++;
  }
  double score=(double)validCount / (double)(overlapSize);
  int gap1=(int)Math.round((rightEdge1 - validCount) / (double)validCount);
  int gap2=(int)Math.round((rightEdge2 - validCount) / (double)validCount);
  int a1=Math.max(0,leftEdge1 - gap1);
  int a2=Math.max(0,leftEdge2 - gap2);
  int b1=Math.min(this.size() + 20,rightEdge1 + gap1);
  int b2=Math.min(s.size() + 20,rightEdge2 + gap2);
  int ahang=a1 - a2;
  int bhang=(this.size() - b1 > s.size() - b2) ? b1 - this.size() : s.size() - b2;
  return new OverlapInfo(score,ahang,bhang);
}