Program: 16633
Project: 16633
Buggy source:
/** 
 * Constructor from an AFPChain instance. Creates an equivalent pairwise  alignment, but in the MultipleAlignment format.
 * @param afp pairwise alignment
 * @param ca1 Atoms of the first strcuture
 * @param ca2 Atoms of the second structure
 * @param flexible true if the alignment is flexible (use BlockSets)
 * @return MultipleAlignmentEnsemble an ensemble
 */
public MultipleAlignmentEnsembleImpl(AFPChain afp,Atom[] ca1,Atom[] ca2,boolean flexible){
  this();
  atomArrays=Arrays.asList(ca1,ca2);
  structureNames=Arrays.asList(afp.getName1(),afp.getName2());
  algorithmName=afp.getAlgorithmName();
  version=afp.getVersion();
  calculationTime=afp.getCalculationTime();
  MultipleAlignment msa=new MultipleAlignmentImpl(this);
  setMultipleAlignments(Arrays.asList((MultipleAlignment)msa));
  Matrix4d ident=new Matrix4d();
  ident.setIdentity();
  Matrix[] rot=afp.getBlockRotationMatrix();
  Atom[] shift=afp.getBlockShiftVector();
  if (flexible) {
    for (int bs=0; bs < afp.getBlockNum(); bs++) {
      BlockSet blockSet=new BlockSetImpl(msa);
      Matrix4d blockTr=Calc.getTransformation(rot[bs],shift[bs]);
      blockSet.setTransformations(Arrays.asList(ident,blockTr));
      Block block=new BlockImpl(blockSet);
      block.setAlignRes(new ArrayList<List<Integer>>());
      block.getAlignRes().add(new ArrayList<Integer>());
      block.getAlignRes().add(new ArrayList<Integer>());
      Matrix rotB=afp.getBlockRotationMatrix()[bs];
      Atom shiftB=afp.getBlockShiftVector()[bs];
      Matrix4d transformB=Calc.getTransformation(rotB,shiftB);
      blockSet.setTransformations(Arrays.asList(ident,transformB));
      for (int i=0; i < afp.getOptAln()[bs][0].length; i++) {
        block.getAlignRes().get(0).add(afp.getOptAln()[bs][0][i]);
        block.getAlignRes().get(1).add(afp.getOptAln()[bs][1][i]);
      }
    }
  }
 else {
    BlockSet blockSet=new BlockSetImpl(msa);
    Matrix4d blockTr=Calc.getTransformation(rot[0],shift[0]);
    blockSet.setTransformations(Arrays.asList(ident,blockTr));
    for (int bs=0; bs < afp.getBlockNum(); bs++) {
      Block block=new BlockImpl(blockSet);
      block.setAlignRes(new ArrayList<List<Integer>>());
      block.getAlignRes().add(new ArrayList<Integer>());
      block.getAlignRes().add(new ArrayList<Integer>());
      for (int i=0; i < afp.getOptAln()[bs][0].length; i++) {
        block.getAlignRes().get(0).add(afp.getOptAln()[bs][0][i]);
        block.getAlignRes().get(1).add(afp.getOptAln()[bs][1][i]);
      }
    }
  }
  msa.putScore(MultipleAlignmentScorer.PROBABILITY,afp.getProbability());
  msa.putScore(MultipleAlignmentScorer.AVGTM_SCORE,afp.getTMScore());
  msa.putScore(MultipleAlignmentScorer.CE_SCORE,afp.getAlignScore());
  msa.putScore(MultipleAlignmentScorer.RMSD,afp.getTotalRmsdOpt());
}

Fixed version (ground truth):
/** 
 * Constructor from an AFPChain instance. Creates an equivalent pairwise  alignment, but in the MultipleAlignment format.
 * @param afp pairwise alignment
 * @param ca1 Atoms of the first strcuture
 * @param ca2 Atoms of the second structure
 * @param flexible true if the alignment is flexible (use BlockSets)
 * @return MultipleAlignmentEnsemble an ensemble
 */
public MultipleAlignmentEnsembleImpl(AFPChain afp,Atom[] ca1,Atom[] ca2,boolean flexible){
  this();
  atomArrays=Arrays.asList(ca1,ca2);
  structureNames=Arrays.asList(afp.getName1(),afp.getName2());
  algorithmName=afp.getAlgorithmName();
  version=afp.getVersion();
  calculationTime=afp.getCalculationTime();
  MultipleAlignment msa=new MultipleAlignmentImpl(this);
  setMultipleAlignments(Arrays.asList((MultipleAlignment)msa));
  Matrix4d ident=new Matrix4d();
  ident.setIdentity();
  Matrix[] rot=afp.getBlockRotationMatrix();
  Atom[] shift=afp.getBlockShiftVector();
  if (flexible) {
    for (int bs=0; bs < afp.getBlockNum(); bs++) {
      BlockSet blockSet=new BlockSetImpl(msa);
      Matrix4d blockTr=null;
      try {
        blockTr=Calc.getTransformation(rot[bs],shift[bs]);
      }
 catch (      IndexOutOfBoundsException e) {
        blockTr=ident;
      }
      blockSet.setTransformations(Arrays.asList(ident,blockTr));
      Block block=new BlockImpl(blockSet);
      block.setAlignRes(new ArrayList<List<Integer>>());
      block.getAlignRes().add(new ArrayList<Integer>());
      block.getAlignRes().add(new ArrayList<Integer>());
      Matrix rotB=afp.getBlockRotationMatrix()[bs];
      Atom shiftB=afp.getBlockShiftVector()[bs];
      Matrix4d transformB=Calc.getTransformation(rotB,shiftB);
      blockSet.setTransformations(Arrays.asList(ident,transformB));
      for (int i=0; i < afp.getOptAln()[bs][0].length; i++) {
        block.getAlignRes().get(0).add(afp.getOptAln()[bs][0][i]);
        block.getAlignRes().get(1).add(afp.getOptAln()[bs][1][i]);
      }
    }
  }
 else {
    BlockSet blockSet=new BlockSetImpl(msa);
    Matrix4d blockTr=null;
    try {
      blockTr=Calc.getTransformation(rot[0],shift[0]);
    }
 catch (    IndexOutOfBoundsException e) {
      blockTr=ident;
    }
    blockSet.setTransformations(Arrays.asList(ident,blockTr));
    for (int bs=0; bs < afp.getBlockNum(); bs++) {
      Block block=new BlockImpl(blockSet);
      block.setAlignRes(new ArrayList<List<Integer>>());
      block.getAlignRes().add(new ArrayList<Integer>());
      block.getAlignRes().add(new ArrayList<Integer>());
      for (int i=0; i < afp.getOptAln()[bs][0].length; i++) {
        block.getAlignRes().get(0).add(afp.getOptAln()[bs][0][i]);
        block.getAlignRes().get(1).add(afp.getOptAln()[bs][1][i]);
      }
    }
  }
  msa.putScore(MultipleAlignmentScorer.PROBABILITY,afp.getProbability());
  msa.putScore(MultipleAlignmentScorer.AVGTM_SCORE,afp.getTMScore());
  msa.putScore(MultipleAlignmentScorer.CE_SCORE,afp.getAlignScore());
  msa.putScore(MultipleAlignmentScorer.RMSD,afp.getTotalRmsdOpt());
}