Program: 16974
Project: 16974
Buggy source:
/** 
 * Fundamentally, an alignment is just a list of aligned residues in each protein. This method converts two lists of ResidueNumbers into an AFPChain. <p>Parameters are filled with defaults (often null) or sometimes calculated. <p>For a way to modify the alignment of an existing AFPChain, see  {@link AlignmentTools#replaceOptAln(AFPChain,Atom[],Atom[],Map)}
 * @param ca1 CA atoms of the first protein
 * @param ca2 CA atoms of the second protein
 * @param aligned1 A list of aligned residues from the first protein
 * @param aligned2 A list of aligned residues from the second protein.Must be the same length as aligned1.
 * @return An AFPChain representing the alignment. Many properties may benull or another default.
 * @throws StructureException if an error occured during superposition
 * @throws IllegalArgumentException if aligned1 and aligned2 have differentlengths
 * @see AlignmentTools#replaceOptAln(AFPChain,Atom[],Atom[],Map)
 */
public static AFPChain createAFPChain(Atom[] ca1,Atom[] ca2,ResidueNumber[] aligned1,ResidueNumber[] aligned2) throws StructureException {
  int alnLen=aligned1.length;
  if (alnLen != aligned2.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  AFPChain a=new AFPChain();
  try {
    a.setName1(ca1[0].getGroup().getChain().getParent().getName());
    a.setName2(ca2[0].getGroup().getChain().getParent().getName());
  }
 catch (  Exception e) {
  }
  a.setBlockNum(1);
  a.setCa1Length(ca1.length);
  a.setCa2Length(ca2.length);
  a.setOptLength(alnLen);
  a.setOptLen(new int[]{alnLen});
  Matrix[] ms=new Matrix[a.getBlockNum()];
  a.setBlockRotationMatrix(ms);
  Atom[] blockShiftVector=new Atom[a.getBlockNum()];
  a.setBlockShiftVector(blockShiftVector);
  String[][][] pdbAln=new String[1][2][alnLen];
  for (int i=0; i < alnLen; i++) {
    pdbAln[0][0][i]=aligned1[i].getChainId() + "String_Node_Str" + aligned1[i].toString();
    pdbAln[0][1][i]=aligned2[i].getChainId() + "String_Node_Str" + aligned2[i].toString();
  }
  a.setPdbAln(pdbAln);
  AFPChainXMLParser.rebuildAFPChain(a,ca1,ca2);
  return a;
}

Fixed version (ground truth):
/** 
 * Fundamentally, an alignment is just a list of aligned residues in each protein. This method converts two lists of ResidueNumbers into an AFPChain. <p>Parameters are filled with defaults (often null) or sometimes calculated. <p>For a way to modify the alignment of an existing AFPChain, see  {@link AlignmentTools#replaceOptAln(AFPChain,Atom[],Atom[],Map)}
 * @param ca1 CA atoms of the first protein
 * @param ca2 CA atoms of the second protein
 * @param aligned1 A list of aligned residues from the first protein
 * @param aligned2 A list of aligned residues from the second protein.Must be the same length as aligned1.
 * @return An AFPChain representing the alignment. Many properties may benull or another default.
 * @throws StructureException if an error occured during superposition
 * @throws IllegalArgumentException if aligned1 and aligned2 have differentlengths
 * @see AlignmentTools#replaceOptAln(AFPChain,Atom[],Atom[],Map)
 */
public static AFPChain createAFPChain(Atom[] ca1,Atom[] ca2,ResidueNumber[] aligned1,ResidueNumber[] aligned2) throws StructureException {
  int alnLen=aligned1.length;
  if (alnLen != aligned2.length) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  AFPChain a=new AFPChain();
  try {
    a.setName1(ca1[0].getGroup().getChain().getParent().getName());
    if (ca2[0].getGroup().getChain().getParent() != null) {
      a.setName2(ca2[0].getGroup().getChain().getParent().getName());
    }
  }
 catch (  Exception e) {
  }
  a.setBlockNum(1);
  a.setCa1Length(ca1.length);
  a.setCa2Length(ca2.length);
  a.setOptLength(alnLen);
  a.setOptLen(new int[]{alnLen});
  Matrix[] ms=new Matrix[a.getBlockNum()];
  a.setBlockRotationMatrix(ms);
  Atom[] blockShiftVector=new Atom[a.getBlockNum()];
  a.setBlockShiftVector(blockShiftVector);
  String[][][] pdbAln=new String[1][2][alnLen];
  for (int i=0; i < alnLen; i++) {
    pdbAln[0][0][i]=aligned1[i].getChainId() + "String_Node_Str" + aligned1[i].toString();
    pdbAln[0][1][i]=aligned2[i].getChainId() + "String_Node_Str" + aligned2[i].toString();
  }
  a.setPdbAln(pdbAln);
  AFPChainXMLParser.rebuildAFPChain(a,ca1,ca2);
  return a;
}