Program: 16560
Project: 16560
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 {
  MultipleAlignment msa=new MultipleAlignmentImpl();
  msa.getEnsemble().setAtomArrays(new ArrayList<Atom[]>());
  msa.getEnsemble().setAlgorithmName(CeSymm.algorithmName);
  msa.getEnsemble().setVersion(CeSymm.version);
  msa.getEnsemble().setStructureIdentifiers(new ArrayList<StructureIdentifier>());
  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=1;
  for (  MultipleAlignment m : levels)   order*=m.size();
  for (int su=0; su < order; su++) {
    msa.getEnsemble().getStructureIdentifiers().add(new PassthroughIdentifier("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));
    }
  }
  result.setMultipleAlignment(msa);
  result.setRefined(true);
  result.setSymmOrder(order);
}

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 {
  MultipleAlignment msa=new MultipleAlignmentImpl();
  msa.getEnsemble().setAtomArrays(new ArrayList<Atom[]>());
  msa.getEnsemble().setAlgorithmName(CeSymm.algorithmName);
  msa.getEnsemble().setVersion(CeSymm.version);
  msa.getEnsemble().setStructureIdentifiers(new ArrayList<StructureIdentifier>());
  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=1;
  for (  MultipleAlignment m : levels)   order*=m.size();
  for (int su=0; su < order; su++) {
    msa.getEnsemble().getStructureIdentifiers().add(new PassthroughIdentifier("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));
    }
  }
  CoreSuperimposer imposer=new CoreSuperimposer();
  imposer.superimpose(msa);
  MultipleAlignmentScorer.calculateScores(msa);
  result.setMultipleAlignment(msa);
  result.setRefined(true);
  result.setSymmOrder(order);
}