Program: 16570
Project: 16570
Buggy source:
/** 
 * Converts a refined symmetry AFPChain alignment into the standard representation of symmetry in a MultipleAlignment, that contains the entire Atom array of the strcuture and the symmetric subunits are orgaized in different rows in a single Block.
 * @param symm AFPChain created with a symmetry algorithm and refined
 * @param atoms Atom array of the entire structure
 * @return MultipleAlignment format of the symmetry
 */
public static MultipleAlignment fromAFP(AFPChain symm,Atom[] atoms){
  if (!symm.getAlgorithmName().contains("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  MultipleAlignmentEnsemble e=new MultipleAlignmentEnsembleImpl(symm,atoms,atoms,false);
  e.setAtomArrays(new ArrayList<Atom[]>());
  StructureIdentifier name=null;
  if (e.getStructureIdentifiers() != null) {
    if (!e.getStructureIdentifiers().isEmpty())     name=e.getStructureIdentifiers().get(0);
  }
 else   name=atoms[0].getGroup().getChain().getStructure().getStructureIdentifier();
  e.setStructureIdentifiers(new ArrayList<StructureIdentifier>());
  MultipleAlignment result=new MultipleAlignmentImpl();
  BlockSet bs=new BlockSetImpl(result);
  Block b=new BlockImpl(bs);
  b.setAlignRes(new ArrayList<List<Integer>>());
  int order=symm.getBlockNum();
  for (int su=0; su < order; su++) {
    List<Integer> residues=e.getMultipleAlignment(0).getBlock(su).getAlignRes().get(0);
    b.getAlignRes().add(residues);
    e.getStructureIdentifiers().add(name);
    e.getAtomArrays().add(atoms);
  }
  e.getMultipleAlignments().set(0,result);
  result.setEnsemble(e);
  double tmScore=symm.getTMScore();
  result.putScore(MultipleAlignmentScorer.AVGTM_SCORE,tmScore);
  return result;
}

Fixed version (ground truth):
/** 
 * Converts a refined symmetry AFPChain alignment into the standard representation of symmetry in a MultipleAlignment, that contains the entire Atom array of the strcuture and the symmetric subunits are orgaized in different rows in a single Block.
 * @param symm AFPChain created with a symmetry algorithm and refined
 * @param atoms Atom array of the entire structure
 * @return MultipleAlignment format of the symmetry
 * @throws StructureException
 */
public static MultipleAlignment fromAFP(AFPChain symm,Atom[] atoms) throws StructureException {
  if (!symm.getAlgorithmName().contains("String_Node_Str")) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  MultipleAlignmentEnsemble e=new MultipleAlignmentEnsembleImpl(symm,atoms,atoms,false);
  e.setAtomArrays(new ArrayList<Atom[]>());
  StructureIdentifier name=null;
  if (e.getStructureIdentifiers() != null) {
    if (!e.getStructureIdentifiers().isEmpty())     name=e.getStructureIdentifiers().get(0);
  }
 else   name=atoms[0].getGroup().getChain().getStructure().getStructureIdentifier();
  e.setStructureIdentifiers(new ArrayList<StructureIdentifier>());
  MultipleAlignment result=new MultipleAlignmentImpl();
  BlockSet bs=new BlockSetImpl(result);
  Block b=new BlockImpl(bs);
  b.setAlignRes(new ArrayList<List<Integer>>());
  int order=symm.getBlockNum();
  for (int su=0; su < order; su++) {
    List<Integer> residues=e.getMultipleAlignment(0).getBlock(su).getAlignRes().get(0);
    b.getAlignRes().add(residues);
    e.getStructureIdentifiers().add(name);
    e.getAtomArrays().add(atoms);
  }
  e.getMultipleAlignments().set(0,result);
  result.setEnsemble(e);
  CoreSuperimposer imposer=new CoreSuperimposer();
  imposer.superimpose(result);
  MultipleAlignmentScorer.calculateScores(result);
  return result;
}