Program: 169223
Project: 169223
Buggy source:
public Alignment<S> localAlignSmithWaterGotoh(S a,S b){
  float[][] D=new float[a.length() + 1][b.length() + 1];
  float[][] P=new float[a.length() + 1][b.length() + 1];
  float[][] Q=new float[a.length() + 1][b.length() + 1];
  for (int i=1; i <= a.length(); i++) {
    D[i][0]=0.0f;
    P[i][0]=Float.NEGATIVE_INFINITY;
    Q[i][0]=Float.NEGATIVE_INFINITY;
  }
  for (int j=1; j <= b.length(); j++) {
    D[0][j]=0.0f;
    P[0][j]=Float.NEGATIVE_INFINITY;
    Q[0][j]=Float.NEGATIVE_INFINITY;
  }
  float maxValue=0.0f;
  int maxI=0;
  int maxJ=0;
  for (int i=1; i <= a.length(); i++) {
    for (int j=1; j <= b.length(); j++) {
      P[i][j]=Math.max(D[i - 1][j] + this.gapOpen,P[i - 1][j] + this.gapExtend);
      Q[i][j]=Math.max(D[i][j - 1] + this.gapOpen,Q[i][j - 1] + this.gapExtend);
      float score=D[i - 1][j - 1] + (float)a.similarityScore(b,i - 1,j - 1) + this.scoreOffset;
      D[i][j]=Math.max(score,Math.max(P[i][j],Q[i][j]));
      if (D[i][j] > maxValue) {
        maxValue=D[i][j];
        maxI=i;
        maxJ=j;
      }
    }
  }
  float score=maxValue;
  int a1=0;
  int a2=maxI;
  int b1=0;
  int b2=maxJ;
  if (storePath) {
    ArrayList<Alignment.Operation> backOperations=new ArrayList<>(a.length() + b.length());
    int i=a.length();
    while (i > maxI) {
      backOperations.add(Operation.DELETE);
      i--;
    }
    i=maxI;
    int j=maxJ;
    while (i > 0 && j > 0) {
      if ((P[i][j] >= Q[i][j] && P[i][j] == D[i][j]) || j == 0) {
        backOperations.add(Operation.DELETE);
        i--;
      }
 else       if (Q[i][j] == D[i][j] || i == 0) {
        backOperations.add(Operation.INSERT);
        j--;
      }
 else {
        backOperations.add(Operation.MATCH);
        i--;
        j--;
      }
    }
    a1=i + 1;
    b1=j + 1;
    while (i > 0) {
      backOperations.add(Operation.DELETE);
      i--;
    }
    Collections.reverse(backOperations);
    return new Alignment<S>(a,b,a1,a2,b1,b2,score,this.gapOpen,backOperations);
  }
  return new Alignment<S>(a,b,a1,a2,b1,b2,score,this.gapOpen,null);
}

Fixed version (ground truth):
public Alignment<S> localAlignSmithWaterGotoh(S a,S b){
  float[][] D=new float[a.length() + 1][b.length() + 1];
  float[][] P=new float[a.length() + 1][b.length() + 1];
  float[][] Q=new float[a.length() + 1][b.length() + 1];
  for (int i=1; i <= a.length(); i++) {
    D[i][0]=0.0f;
    P[i][0]=Float.NEGATIVE_INFINITY;
    Q[i][0]=Float.NEGATIVE_INFINITY;
  }
  for (int j=1; j <= b.length(); j++) {
    D[0][j]=0.0f;
    P[0][j]=Float.NEGATIVE_INFINITY;
    Q[0][j]=Float.NEGATIVE_INFINITY;
  }
  float maxValue=0.0f;
  int maxI=0;
  int maxJ=0;
  for (int i=1; i <= a.length(); i++) {
    for (int j=1; j <= b.length(); j++) {
      P[i][j]=Math.max(D[i - 1][j] + this.gapOpen,P[i - 1][j] + this.gapExtend);
      Q[i][j]=Math.max(D[i][j - 1] + this.gapOpen,Q[i][j - 1] + this.gapExtend);
      float score=D[i - 1][j - 1] + (float)a.similarityScore(b,i - 1,j - 1) + this.scoreOffset;
      D[i][j]=Math.max(score,Math.max(P[i][j],Q[i][j]));
      if (D[i][j] > maxValue) {
        maxValue=D[i][j];
        maxI=i;
        maxJ=j;
      }
    }
  }
  float score=maxValue;
  int a1=0;
  int a2=maxI - 1;
  int b1=0;
  int b2=maxJ - 1;
  if (storePath) {
    ArrayList<Alignment.Operation> backOperations=new ArrayList<>(a.length() + b.length());
    int i=a.length();
    while (i > maxI) {
      backOperations.add(Operation.DELETE);
      i--;
    }
    i=maxI;
    int j=maxJ;
    while (i > 0 && j > 0) {
      if ((P[i][j] >= Q[i][j] && P[i][j] == D[i][j]) || j == 0) {
        backOperations.add(Operation.DELETE);
        i--;
      }
 else       if (Q[i][j] == D[i][j] || i == 0) {
        backOperations.add(Operation.INSERT);
        j--;
      }
 else {
        backOperations.add(Operation.MATCH);
        i--;
        j--;
      }
    }
    a1=i;
    b1=j;
    while (i > 0) {
      backOperations.add(Operation.DELETE);
      i--;
    }
    Collections.reverse(backOperations);
    return new Alignment<S>(a,b,a1,a2,b1,b2,score,this.gapOpen,backOperations);
  }
  return new Alignment<S>(a,b,a1,a2,b1,b2,score,this.gapOpen,null);
}