Program: 125162
Project: 125162
Buggy source:
public void computeTreePartitions(AbstractInference<Tripartition> inference,boolean addExtra){
  int k=inference.trees.size();
  n=GlobalMaps.taxonIdentifier.taxonCount();
  int haveMissing=0;
  for (  Tree tree : inference.trees) {
    if (tree.getLeafCount() != n) {
      haveMissing++;
    }
    String[] gtLeaves=tree.getLeaves();
    STITreeCluster gtAll=new STITreeCluster();
    for (int i=0; i < gtLeaves.length; i++) {
      gtAll.addLeaf(GlobalMaps.taxonIdentifier.taxonId(gtLeaves[i]));
    }
    treeAllClusters.add(gtAll);
  }
  System.err.println(haveMissing + "String_Node_Str");
  if ((haveMissing > k / 20) || addExtra) {
    System.err.println("String_Node_Str");
    calculateDistances(inference);
  }
  if (haveMissing > k / 20) {
    this.orderedTaxonByDist=sortByDistance();
    System.err.println("String_Node_Str");
  }
  if (addExtra) {
    this.distSTMatrix=new float[spm.getSpeciesCount()][spm.getSpeciesCount()];
    float[][] denum=new float[spm.getSpeciesCount()][spm.getSpeciesCount()];
    for (int i=0; i < n; i++) {
      for (int j=i; j < n; j++) {
        int stI=spm.getSpeciesIdForTaxon(i);
        int stJ=spm.getSpeciesIdForTaxon(j);
        this.distSTMatrix[stI][stJ]+=this.distMatrix[i][j];
        this.distSTMatrix[stJ][stI]=this.distSTMatrix[stI][stJ];
        denum[stI][stJ]++;
        denum[stJ][stI]++;
      }
    }
    for (int i=0; i < spm.getSpeciesCount(); i++) {
      for (int j=0; j < spm.getSpeciesCount(); j++) {
        this.distSTMatrix[i][j]=denum[i][j] == 0 ? 0 : this.distSTMatrix[i][j] / denum[i][j];
      }
      this.distSTMatrix[i][i]=1;
    }
    System.err.println("String_Node_Str");
  }
  Map<Tripartition,Integer> geneTreeTripartitonCount=new HashMap<Tripartition,Integer>(k * n);
  STITreeCluster all=new STITreeCluster();
  all.getBitSet().set(0,n);
  addToClusters(all,GlobalMaps.taxonIdentifier.taxonCount());
  traverseTrees(inference.trees,true,geneTreeTripartitonCount,this.orderedTaxonByDist != null);
  this.setAlgorithm(geneTreeTripartitonCount.size(),k);
  if (this.algorithm == 2) {
    System.err.println("String_Node_Str");
    finalTripartitions=new Tripartition[geneTreeTripartitonCount.size()];
    finalCounts=new int[geneTreeTripartitonCount.size()];
    int i=0;
    for (    Entry<Tripartition,Integer> entry : geneTreeTripartitonCount.entrySet()) {
      finalTripartitions[i]=entry.getKey();
      finalCounts[i]=entry.getValue();
      i++;
    }
  }
 else {
    System.err.println("String_Node_Str");
    List<Integer> temp=new ArrayList<Integer>();
    for (    Tree tr : inference.trees) {
      for (      TNode node : tr.postTraverse()) {
        if (node.isLeaf()) {
          temp.add(GlobalMaps.taxonIdentifier.taxonId(node.getName()));
        }
 else {
          temp.add(-node.getChildCount());
        }
        if (node.isRoot()) {
          temp.add(Integer.MIN_VALUE);
        }
      }
    }
    geneTreesAsInts=temp.toArray(new Integer[]{});
  }
  long s=0;
  for (  Integer c : geneTreeTripartitonCount.values()) {
    s+=c;
  }
  System.err.println("String_Node_Str" + k);
  System.err.println("String_Node_Str" + geneTreeTripartitonCount.size());
  System.err.println("String_Node_Str" + s);
  System.err.println("String_Node_Str" + clusters.getClusterCount());
  inference.weightCalculator.initializeWeightContainer(geneTreeTripartitonCount.size() * 2);
}

Fixed version (ground truth):
public void computeTreePartitions(AbstractInference<Tripartition> inference,boolean addExtra){
  int k=inference.trees.size();
  n=GlobalMaps.taxonIdentifier.taxonCount();
  int haveMissing=0;
  for (  Tree tree : inference.trees) {
    if (tree.getLeafCount() != n) {
      haveMissing++;
    }
    String[] gtLeaves=tree.getLeaves();
    STITreeCluster gtAll=new STITreeCluster();
    for (int i=0; i < gtLeaves.length; i++) {
      gtAll.addLeaf(GlobalMaps.taxonIdentifier.taxonId(gtLeaves[i]));
    }
    treeAllClusters.add(gtAll);
  }
  System.err.println(haveMissing + "String_Node_Str");
  if ((haveMissing > k / 20) || addExtra) {
    System.err.println("String_Node_Str");
    calculateDistances(inference,treeAllClusters);
  }
  if (haveMissing > k / 20) {
    this.orderedTaxonByDist=sortByDistance();
    System.err.println("String_Node_Str");
  }
  if (addExtra) {
    this.distSTMatrix=new float[spm.getSpeciesCount()][spm.getSpeciesCount()];
    float[][] denum=new float[spm.getSpeciesCount()][spm.getSpeciesCount()];
    for (int i=0; i < n; i++) {
      for (int j=i; j < n; j++) {
        int stI=spm.getSpeciesIdForTaxon(i);
        int stJ=spm.getSpeciesIdForTaxon(j);
        this.distSTMatrix[stI][stJ]+=this.distMatrix[i][j];
        this.distSTMatrix[stJ][stI]=this.distSTMatrix[stI][stJ];
        denum[stI][stJ]++;
        denum[stJ][stI]++;
      }
    }
    for (int i=0; i < spm.getSpeciesCount(); i++) {
      for (int j=0; j < spm.getSpeciesCount(); j++) {
        this.distSTMatrix[i][j]=denum[i][j] == 0 ? 0 : this.distSTMatrix[i][j] / denum[i][j];
      }
      this.distSTMatrix[i][i]=1;
    }
    System.err.println("String_Node_Str");
  }
  Map<Tripartition,Integer> geneTreeTripartitonCount=new HashMap<Tripartition,Integer>(k * n);
  STITreeCluster all=new STITreeCluster();
  all.getBitSet().set(0,n);
  addToClusters(all,GlobalMaps.taxonIdentifier.taxonCount());
  traverseTrees(inference.trees,true,geneTreeTripartitonCount,this.orderedTaxonByDist != null,treeAllClusters);
  this.setAlgorithm(geneTreeTripartitonCount.size(),k);
  if (this.algorithm == 2) {
    System.err.println("String_Node_Str");
    finalTripartitions=new Tripartition[geneTreeTripartitonCount.size()];
    finalCounts=new int[geneTreeTripartitonCount.size()];
    int i=0;
    for (    Entry<Tripartition,Integer> entry : geneTreeTripartitonCount.entrySet()) {
      finalTripartitions[i]=entry.getKey();
      finalCounts[i]=entry.getValue();
      i++;
    }
  }
 else {
    System.err.println("String_Node_Str");
    List<Integer> temp=new ArrayList<Integer>();
    for (    Tree tr : inference.trees) {
      for (      TNode node : tr.postTraverse()) {
        if (node.isLeaf()) {
          temp.add(GlobalMaps.taxonIdentifier.taxonId(node.getName()));
        }
 else {
          temp.add(-node.getChildCount());
        }
        if (node.isRoot()) {
          temp.add(Integer.MIN_VALUE);
        }
      }
    }
    geneTreesAsInts=temp.toArray(new Integer[]{});
  }
  long s=0;
  for (  Integer c : geneTreeTripartitonCount.values()) {
    s+=c;
  }
  System.err.println("String_Node_Str" + k);
  System.err.println("String_Node_Str" + geneTreeTripartitonCount.size());
  System.err.println("String_Node_Str" + s);
  System.err.println("String_Node_Str" + clusters.getClusterCount());
  inference.weightCalculator.initializeWeightContainer(geneTreeTripartitonCount.size() * 2);
}