Program: 16577
Project: 16577
Buggy source:
/** 
 * After all the analysis iteratives have finished, the final MultipleAlignment object is constructed using the alignment graph.
 * @throws StructureException
 */
private void buildAlignment() throws StructureException {
  msa=new MultipleAlignmentImpl();
  msa.getEnsemble().setAtomArrays(new ArrayList<Atom[]>());
  msa.getEnsemble().setAlgorithmName(CeSymm.algorithmName);
  msa.getEnsemble().setVersion(CeSymm.version);
  msa.getEnsemble().setStructureNames(new ArrayList<String>());
  BlockSet bs=new BlockSetImpl(msa);
  Block b=new BlockImpl(bs);
  b.setAlignRes(new ArrayList<List<Integer>>());
  List<List<Integer>> groups=new ArrayList<List<Integer>>();
  List<Integer> alreadySeen=new ArrayList<Integer>();
  int size=0;
  for (int i=0; i < alignGraph.size(); i++) {
    if (!alreadySeen.contains(i)) {
      List<Integer> group=new ArrayList<Integer>();
      List<Integer> residues=new ArrayList<Integer>();
      residues.add(i);
      while (residues.size() > 0) {
        List<Integer> newResidues=new ArrayList<Integer>();
        for (        Integer residue : residues) {
          group.add(residue);
          alreadySeen.add(residue);
          List<Integer> children=alignGraph.get(residue);
          newResidues.addAll(children);
        }
        residues=newResidues;
      }
      Collections.sort(group);
      groups.add(group);
      if (group.size() > size)       size=group.size();
    }
  }
  for (int su=0; su < size; su++) {
    msa.getEnsemble().getStructureNames().add("String_Node_Str" + (su + 1));
    msa.getEnsemble().getAtomArrays().add(allAtoms);
    b.getAlignRes().add(new ArrayList<Integer>());
    for (    List<Integer> group : groups) {
      if (group.size() != size)       continue;
      b.getAlignRes().get(su).add(group.get(su));
    }
  }
}

Fixed version (ground truth):
/** 
 * After all the analysis iteratives have finished, the final MultipleAlignment object is constructed using the alignment graph.
 * @throws StructureException
 */
private void buildAlignment() throws StructureException {
  msa=new MultipleAlignmentImpl();
  msa.getEnsemble().setAtomArrays(new ArrayList<Atom[]>());
  msa.getEnsemble().setAlgorithmName(CeSymm.algorithmName);
  msa.getEnsemble().setVersion(CeSymm.version);
  msa.getEnsemble().setStructureNames(new ArrayList<String>());
  BlockSet bs=new BlockSetImpl(msa);
  Block b=new BlockImpl(bs);
  b.setAlignRes(new ArrayList<List<Integer>>());
  List<List<Integer>> groups=new ArrayList<List<Integer>>();
  List<Integer> alreadySeen=new ArrayList<Integer>();
  for (int i=0; i < alignGraph.size(); i++) {
    if (!alreadySeen.contains(i)) {
      List<Integer> group=new ArrayList<Integer>();
      List<Integer> residues=new ArrayList<Integer>();
      residues.add(i);
      while (residues.size() > 0) {
        List<Integer> newResidues=new ArrayList<Integer>();
        for (        Integer residue : residues) {
          group.add(residue);
          alreadySeen.add(residue);
          List<Integer> children=alignGraph.get(residue);
          newResidues.addAll(children);
        }
        residues=newResidues;
      }
      Collections.sort(group);
      groups.add(group);
    }
  }
  int order=01;
  for (  MultipleAlignment m : levels)   order*=m.size();
  for (int su=0; su < order; su++) {
    msa.getEnsemble().getStructureNames().add("String_Node_Str" + (su + 1));
    msa.getEnsemble().getAtomArrays().add(allAtoms);
    b.getAlignRes().add(new ArrayList<Integer>());
    for (    List<Integer> group : groups) {
      if (group.size() != order)       continue;
      b.getAlignRes().get(su).add(group.get(su));
    }
  }
}