Program: 16927
Project: 16927
Buggy source:
/** 
 * Swaps the order of structures in an AFPChain
 * @param a
 * @return
 */
public AFPChain invertAlignment(AFPChain a){
  String name1=a.getName1();
  String name2=a.getName2();
  a.setName1(name2);
  a.setName2(name1);
  int len1=a.getCa1Length();
  a.setCa1Length(a.getCa2Length());
  a.setCa2Length(len1);
  int beg1=a.getAlnbeg1();
  a.setAlnbeg1(a.getAlnbeg2());
  a.setAlnbeg2(beg1);
  char[] alnseq1=a.getAlnseq1();
  a.setAlnseq1(a.getAlnseq2());
  a.setAlnseq2(alnseq1);
  Matrix distab1=a.getDisTable1();
  a.setDisTable1(a.getDisTable2());
  a.setDisTable2(distab1);
  int[] focusRes1=a.getFocusRes1();
  a.setFocusRes1(a.getFocusRes2());
  a.setFocusRes2(focusRes1);
  String[][][] pdbAln=a.getPdbAln();
  if (pdbAln != null) {
    for (int block=0; block < a.getBlockNum(); block++) {
      String[] paln1=pdbAln[block][0];
      pdbAln[block][0]=pdbAln[block][1];
      pdbAln[block][1]=paln1;
    }
  }
  int[][][] optAln=a.getOptAln();
  int[] optLen=a.getOptLen();
  if (optAln != null) {
    for (int block=0; block < a.getBlockNum(); block++) {
      int[] aln1=optAln[block][0];
      optAln[block][0]=optAln[block][1];
      optAln[block][1]=aln1;
    }
  }
  a.setOptAln(optAln);
  Matrix distmat=a.getDistanceMatrix();
  if (distmat != null)   a.setDistanceMatrix(distmat.transpose());
  Matrix[] blockRotMat=a.getBlockRotationMatrix();
  Atom[] shiftVec=a.getBlockShiftVector();
  if (blockRotMat != null) {
    for (int block=0; block < a.getBlockNum(); block++) {
      if (blockRotMat[block] != null) {
        blockRotMat[block]=blockRotMat[block].inverse();
        shiftVec[block]=Calc.invert(shiftVec[block]);
      }
    }
  }
  return a;
}

Fixed version (ground truth):
/** 
 * Swaps the order of structures in an AFPChain
 * @param a
 * @return
 */
public AFPChain invertAlignment(AFPChain a){
  String name1=a.getName1();
  String name2=a.getName2();
  a.setName1(name2);
  a.setName2(name1);
  int len1=a.getCa1Length();
  a.setCa1Length(a.getCa2Length());
  a.setCa2Length(len1);
  int beg1=a.getAlnbeg1();
  a.setAlnbeg1(a.getAlnbeg2());
  a.setAlnbeg2(beg1);
  char[] alnseq1=a.getAlnseq1();
  a.setAlnseq1(a.getAlnseq2());
  a.setAlnseq2(alnseq1);
  Matrix distab1=a.getDisTable1();
  a.setDisTable1(a.getDisTable2());
  a.setDisTable2(distab1);
  int[] focusRes1=a.getFocusRes1();
  a.setFocusRes1(a.getFocusRes2());
  a.setFocusRes2(focusRes1);
  String[][][] pdbAln=a.getPdbAln();
  if (pdbAln != null) {
    for (int block=0; block < a.getBlockNum(); block++) {
      String[] paln1=pdbAln[block][0];
      pdbAln[block][0]=pdbAln[block][1];
      pdbAln[block][1]=paln1;
    }
  }
  int[][][] optAln=a.getOptAln();
  int[] optLen=a.getOptLen();
  if (optAln != null) {
    for (int block=0; block < a.getBlockNum(); block++) {
      int[] aln1=optAln[block][0];
      optAln[block][0]=optAln[block][1];
      optAln[block][1]=aln1;
    }
  }
  a.setOptAln(optAln);
  Matrix distmat=a.getDistanceMatrix();
  if (distmat != null)   a.setDistanceMatrix(distmat.transpose());
  Matrix[] blockRotMat=a.getBlockRotationMatrix();
  Atom[] shiftVec=a.getBlockShiftVector();
  if (blockRotMat != null) {
    for (int block=0; block < a.getBlockNum(); block++) {
      if (blockRotMat[block] != null) {
        blockRotMat[block]=blockRotMat[block].inverse();
        try {
          shiftVec[block]=Calc.invert(shiftVec[block]);
        }
 catch (        StructureException e) {
        }
      }
    }
  }
  return a;
}