Program: 16600
Project: 16600
Buggy source:
private double[][] calculateDistanceMatrix(MultipleSequenceAlignment<C,D> multipleSequenceAlignment,TreeConstructionAlgorithm tca){
  updateProgress("String_Node_Str",0);
  int numberOfSequences=multipleSequenceAlignment.getSize();
  String[] sequenceString=new String[numberOfSequences];
  for (int i=0; i < multipleSequenceAlignment.getSize(); i++) {
    sequenceString[i]=multipleSequenceAlignment.getAlignedSequence(i).getSequenceAsString();
  }
  double[][] distance=new double[numberOfSequences][numberOfSequences];
  int totalloopcount=(numberOfSequences / 2) * (numberOfSequences + 1);
  if (tca == TreeConstructionAlgorithm.PID) {
    int loopcount=0;
    for (int i=0; i < (numberOfSequences - 1); i++) {
      updateProgress("String_Node_Str",(loopcount * 100) / totalloopcount);
      for (int j=i; j < numberOfSequences; j++) {
        loopcount++;
        if (j == i) {
          distance[i][i]=0;
        }
 else {
          distance[i][j]=100 - Comparison.PID(sequenceString[i],sequenceString[j]);
          distance[j][i]=distance[i][j];
        }
      }
    }
  }
 else {
    ScoreMatrix pwmatrix=ResidueProperties.getScoreMatrix(treeConstructionAlgorithm.name());
    if (pwmatrix == null) {
      pwmatrix=ResidueProperties.getScoreMatrix(TreeConstructionAlgorithm.BLOSUM62.name());
    }
    int maxscore=0;
    int end=sequenceString[0].length();
    int loopcount=0;
    for (int i=0; i < (numberOfSequences - 1); i++) {
      updateProgress("String_Node_Str",(loopcount * 100) / totalloopcount);
      for (int j=i; j < numberOfSequences; j++) {
        int score=0;
        loopcount++;
        for (int k=0; k < end; k++) {
          try {
            score+=pwmatrix.getPairwiseScore(sequenceString[i].charAt(k),sequenceString[j].charAt(k));
          }
 catch (          Exception ex) {
            logger.error("String_Node_Str",ex);
          }
        }
        distance[i][j]=(float)score;
        if (score > maxscore) {
          maxscore=score;
        }
      }
    }
    for (int i=0; i < (numberOfSequences - 1); i++) {
      for (int j=i; j < numberOfSequences; j++) {
        distance[i][j]=(float)maxscore - distance[i][j];
        distance[j][i]=distance[i][j];
      }
    }
  }
  updateProgress("String_Node_Str",100);
  return distance;
}

Fixed version (ground truth):
private double[][] calculateDistanceMatrix(MultipleSequenceAlignment<C,D> multipleSequenceAlignment,TreeConstructionAlgorithm tca){
  updateProgress("String_Node_Str",0);
  int numberOfSequences=multipleSequenceAlignment.getSize();
  String[] sequenceString=new String[numberOfSequences];
  for (int i=0; i < multipleSequenceAlignment.getSize(); i++) {
    sequenceString[i]=multipleSequenceAlignment.getAlignedSequence(i + 1).getSequenceAsString();
  }
  double[][] distance=new double[numberOfSequences][numberOfSequences];
  int totalloopcount=(numberOfSequences / 2) * (numberOfSequences + 1);
  if (tca == TreeConstructionAlgorithm.PID) {
    int loopcount=0;
    for (int i=0; i < (numberOfSequences - 1); i++) {
      updateProgress("String_Node_Str",(loopcount * 100) / totalloopcount);
      for (int j=i; j < numberOfSequences; j++) {
        loopcount++;
        if (j == i) {
          distance[i][i]=0;
        }
 else {
          distance[i][j]=100 - Comparison.PID(sequenceString[i],sequenceString[j]);
          distance[j][i]=distance[i][j];
        }
      }
    }
  }
 else {
    ScoreMatrix pwmatrix=ResidueProperties.getScoreMatrix(treeConstructionAlgorithm.name());
    if (pwmatrix == null) {
      pwmatrix=ResidueProperties.getScoreMatrix(TreeConstructionAlgorithm.BLOSUM62.name());
    }
    int maxscore=0;
    int end=sequenceString[0].length();
    int loopcount=0;
    for (int i=0; i < (numberOfSequences - 1); i++) {
      updateProgress("String_Node_Str",(loopcount * 100) / totalloopcount);
      for (int j=i; j < numberOfSequences; j++) {
        int score=0;
        loopcount++;
        for (int k=0; k < end; k++) {
          try {
            score+=pwmatrix.getPairwiseScore(sequenceString[i].charAt(k),sequenceString[j].charAt(k));
          }
 catch (          Exception ex) {
            logger.error("String_Node_Str",ex);
          }
        }
        distance[i][j]=(float)score;
        if (score > maxscore) {
          maxscore=score;
        }
      }
    }
    for (int i=0; i < (numberOfSequences - 1); i++) {
      for (int j=i; j < numberOfSequences; j++) {
        distance[i][j]=(float)maxscore - distance[i][j];
        distance[j][i]=distance[i][j];
      }
    }
  }
  updateProgress("String_Node_Str",100);
  return distance;
}