Program: 16300
Project: 16300
Buggy source:
private void compareBlock(int blockNr,AFPChain afpChain,AFPChain newChain,Atom[] ca1,Atom[] ca2) throws StructureException {
  Atom[] ca1Copy=StructureTools.cloneAtomArray(ca1);
  Atom[] ca2Copy=StructureTools.cloneAtomArray(ca2);
  Atom[] ca2Copy2=StructureTools.cloneAtomArray(ca2);
  int[][][] blocks2=newChain.getOptAln();
  Matrix[] maxs2=newChain.getBlockRotationMatrix();
  Atom[] shifts2=newChain.getBlockShiftVector();
  int[] optLen=afpChain.getOptLen();
  List<Atom> eqrPos1=new ArrayList<Atom>();
  List<Atom> eqrPos2=new ArrayList<Atom>();
  List<Atom> eqrPos2copy=new ArrayList<Atom>();
  for (int z=0; z < blocks2[blockNr][0].length && z < optLen[blockNr]; z++) {
    int pos1=blocks2[blockNr][0][z];
    int pos2=blocks2[blockNr][1][z];
    Atom c1=ca1Copy[pos1];
    Atom c2=ca2Copy[pos2];
    Atom c3=ca2Copy2[pos2];
    eqrPos1.add(c1);
    eqrPos2.add(c2);
    eqrPos2copy.add(c3);
  }
  assertTrue("String_Node_Str" + blockNr + "String_Node_Str"+ afpChain.getOptLen()[blockNr]+ "String_Node_Str"+ eqrPos2.size(),eqrPos2.size() == afpChain.getOptLen()[blockNr]);
  Atom[] blockSet1=eqrPos1.toArray(new Atom[eqrPos1.size()]);
  Atom[] blockSet2=eqrPos2.toArray(new Atom[eqrPos2.size()]);
  Atom[] blockSet2copy=eqrPos2copy.toArray(new Atom[eqrPos2copy.size()]);
  for (  Atom a : blockSet2) {
    for (int i=0; i <= blockNr; i++) {
      Matrix max=maxs2[i];
      Atom shift=shifts2[i];
      Calc.rotate(a,max);
      Calc.shift(a,shift);
    }
  }
  double rmsdFile=SuperPositionSVD.getRMS(blockSet1,blockSet2);
  SuperPositionSVD svd=new SuperPositionSVD(blockSet1,blockSet2copy);
  Matrix m=svd.getRotation();
  Atom s=svd.getTranslation();
  Matrix max=maxs2[blockNr];
  Atom shift=shifts2[blockNr];
  compareMatrices(max,m);
  if (blockNr == 0) {
    compareVectors(shift,s);
  }
 else {
    System.err.println("String_Node_Str");
  }
  for (  Atom a : ca2Copy2) {
    Calc.rotate(a,m);
    Calc.shift(a,s);
  }
  double rmsd3=SuperPositionSVD.getRMS(blockSet1,blockSet2copy);
  assertTrue("String_Node_Str" + blockNr + "String_Node_Str"+ rmsd3+ "String_Node_Str"+ rmsdFile,compareRmsd(rmsd3,rmsdFile));
}

Fixed version (ground truth):
private void compareBlock(int blockNr,AFPChain afpChain,AFPChain newChain,Atom[] ca1,Atom[] ca2) throws StructureException {
  Atom[] ca1Copy=StructureTools.cloneAtomArray(ca1);
  Atom[] ca2Copy=StructureTools.cloneAtomArray(ca2);
  Atom[] ca2Copy2=StructureTools.cloneAtomArray(ca2);
  int[][][] blocks2=newChain.getOptAln();
  Matrix[] maxs2=newChain.getBlockRotationMatrix();
  Atom[] shifts2=newChain.getBlockShiftVector();
  int[] optLen=afpChain.getOptLen();
  List<Atom> eqrPos1=new ArrayList<Atom>();
  List<Atom> eqrPos2=new ArrayList<Atom>();
  List<Atom> eqrPos2copy=new ArrayList<Atom>();
  for (int z=0; z < blocks2[blockNr][0].length && z < optLen[blockNr]; z++) {
    int pos1=blocks2[blockNr][0][z];
    int pos2=blocks2[blockNr][1][z];
    Atom c1=ca1Copy[pos1];
    Atom c2=ca2Copy[pos2];
    Atom c3=ca2Copy2[pos2];
    eqrPos1.add(c1);
    eqrPos2.add(c2);
    eqrPos2copy.add(c3);
  }
  assertTrue("String_Node_Str" + blockNr + "String_Node_Str"+ afpChain.getOptLen()[blockNr]+ "String_Node_Str"+ eqrPos2.size(),eqrPos2.size() == afpChain.getOptLen()[blockNr]);
  Atom[] blockSet1=eqrPos1.toArray(new Atom[eqrPos1.size()]);
  Atom[] blockSet2=eqrPos2.toArray(new Atom[eqrPos2.size()]);
  Atom[] blockSet2copy=eqrPos2copy.toArray(new Atom[eqrPos2copy.size()]);
  for (  Atom a : blockSet2) {
    for (int i=0; i <= blockNr; i++) {
      Matrix max=maxs2[i];
      Atom shift=shifts2[i];
      Calc.rotate(a,max);
      Calc.shift(a,shift);
    }
  }
  double rmsdFile=Calc.rmsd(blockSet1,blockSet2);
  Matrix4d transform=SuperPositions.superpose(Calc.atomsToPoints(blockSet1),Calc.atomsToPoints(blockSet2copy));
  Matrix m=Matrices.getRotationJAMA(transform);
  Atom s=Calc.getTranslationVector(transform);
  Matrix max=maxs2[blockNr];
  Atom shift=shifts2[blockNr];
  compareMatrices(max,m);
  if (blockNr == 0) {
    compareVectors(shift,s);
  }
 else {
    System.err.println("String_Node_Str");
  }
  for (  Atom a : ca2Copy2) {
    Calc.rotate(a,m);
    Calc.shift(a,s);
  }
  double rmsd3=Calc.rmsd(blockSet1,blockSet2copy);
  assertTrue("String_Node_Str" + blockNr + "String_Node_Str"+ rmsd3+ "String_Node_Str"+ rmsdFile,compareRmsd(rmsd3,rmsdFile));
}