Program: 16559
Project: 16559
Buggy source:
@SuppressWarnings("String_Node_Str") protected static CeSymmResult align(Atom[] atoms,CESymmParameters params) throws StructureException {
  CeSymmResult result=new CeSymmResult();
  result.setParams(params);
  result.setAtoms(atoms);
  Atom[] ca2=StructureTools.duplicateCA2(atoms);
  int rows=atoms.length;
  int cols=ca2.length;
  if (rows == 0 || cols == 0) {
    throw new StructureException("String_Node_Str");
  }
  Matrix origM=null;
  AFPChain myAFP=new AFPChain(algorithmName);
  CECalculator calculator=new CECalculator(params);
  Matrix lastMatrix=null;
  List<AFPChain> selfAlignments=new ArrayList<AFPChain>();
  int i=0;
  do {
    if (origM != null)     myAFP.setDistanceMatrix((Matrix)origM.clone());
    origM=align(myAFP,atoms,ca2,params,origM,calculator,i);
    double tmScore2=AFPChainScorer.getTMScore(myAFP,atoms,ca2);
    myAFP.setTMScore(tmScore2);
    AFPChain newAFP=(AFPChain)myAFP.clone();
    newAFP=CeCPMain.postProcessAlignment(newAFP,atoms,ca2,calculator);
    double tmScore3=AFPChainScorer.getTMScore(newAFP,atoms,ca2);
    newAFP.setTMScore(tmScore3);
    if (tmScore3 < params.getScoreThreshold()) {
      if (i == 0)       selfAlignments.add(newAFP);
      lastMatrix=newAFP.getDistanceMatrix().copy();
      break;
    }
    selfAlignments.add(newAFP);
    i++;
  }
 while (i < params.getMaxSymmOrder() && multiPass);
  if (lastMatrix == null && selfAlignments.size() > 1 && multiPass) {
    AFPChain last=selfAlignments.get(selfAlignments.size() - 1);
    lastMatrix=SymmetryTools.blankOutPreviousAlignment(last,ca2,last.getCa1Length(),last.getCa2Length(),calculator,origM,params.getWinSize());
    lastMatrix=lastMatrix.getMatrix(0,last.getCa1Length() - 1,0,last.getCa2Length() - 1);
  }
  result.setSelfAlignment(selfAlignments.get(0));
  SymmetryType type=params.getSymmType();
  if (type == SymmetryType.AUTO) {
    if (result.getSelfAlignment().getBlockNum() == 1) {
      result.setType(SymmetryType.OPEN);
      logger.info("String_Node_Str");
    }
 else {
      result.setType(SymmetryType.CLOSE);
      logger.info("String_Node_Str");
    }
  }
  SymmetryRefiner refiner=null;
  OrderDetector orderDetector=null;
  int order=1;
  try {
switch (type) {
case CLOSE:
switch (params.getOrderDetectorMethod()) {
case SEQUENCE_FUNCTION:
        orderDetector=new SequenceFunctionOrderDetector(params.getMaxSymmOrder(),0.4f);
      order=orderDetector.calculateOrder(result.getSelfAlignment(),atoms);
    break;
case USER_INPUT:
  order=params.getUserOrder();
break;
}
switch (params.getRefineMethod()) {
case NOT_REFINED:
result.setSymmOrder(order);
return result;
case GRAPH:
refiner=new GraphRefiner();
break;
case SINGLE:
refiner=new SingleRefiner();
break;
}
break;
default :
if (params.getRefineMethod() == RefineMethod.NOT_REFINED) {
return result;
}
 else {
refiner=new OpenRefiner();
order=params.getUserOrder();
}
break;
}
MultipleAlignment msa=refiner.refine(result.getSelfAlignment(),atoms,order);
result.setMultipleAlignment(msa);
result.setSymmOrder(msa.size());
result.setRefined(true);
}
 catch (RefinerFailedException e) {
logger.info("String_Node_Str" + e.getMessage());
return result;
}
SymmetryAxes axes=new SymmetryAxes();
order=result.getSymmOrder();
Matrix4d axis=result.getMultipleAlignment().getBlockSet(0).getTransformations().get(1);
List<List<Integer>> superposition=new ArrayList<List<Integer>>();
List<Integer> chain1=new ArrayList<Integer>();
List<Integer> chain2=new ArrayList<Integer>();
superposition.add(chain1);
superposition.add(chain2);
List<Integer> subunitTrans=new ArrayList<Integer>();
switch (type) {
case CLOSE:
for (int bk=0; bk < order; bk++) {
chain1.add(bk);
chain2.add((bk + 1) % order);
subunitTrans.add(bk);
}
axes.addAxis(axis,superposition,subunitTrans,order);
break;
default :
subunitTrans.add(0);
for (int bk=0; bk < order - 1; bk++) {
chain1.add(bk);
chain2.add(bk + 1);
subunitTrans.add(bk + 1);
}
axes.addAxis(axis,superposition,subunitTrans,order);
break;
}
result.setAxes(axes);
return result;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") protected static CeSymmResult align(Atom[] atoms,CESymmParameters params) throws StructureException {
  CeSymmResult result=new CeSymmResult();
  result.setParams(params);
  result.setAtoms(atoms);
  Atom[] ca2=StructureTools.duplicateCA2(atoms);
  int rows=atoms.length;
  int cols=ca2.length;
  if (rows == 0 || cols == 0) {
    throw new StructureException("String_Node_Str");
  }
  Matrix origM=null;
  AFPChain myAFP=new AFPChain(algorithmName);
  CECalculator calculator=new CECalculator(params);
  Matrix lastMatrix=null;
  List<AFPChain> selfAlignments=new ArrayList<AFPChain>();
  int i=0;
  do {
    if (origM != null)     myAFP.setDistanceMatrix((Matrix)origM.clone());
    origM=align(myAFP,atoms,ca2,params,origM,calculator,i);
    double tmScore2=AFPChainScorer.getTMScore(myAFP,atoms,ca2);
    myAFP.setTMScore(tmScore2);
    AFPChain newAFP=(AFPChain)myAFP.clone();
    newAFP=CeCPMain.postProcessAlignment(newAFP,atoms,ca2,calculator);
    double tmScore3=AFPChainScorer.getTMScore(newAFP,atoms,ca2);
    newAFP.setTMScore(tmScore3);
    if (tmScore3 < params.getScoreThreshold()) {
      if (i == 0)       selfAlignments.add(newAFP);
      lastMatrix=newAFP.getDistanceMatrix().copy();
      break;
    }
    selfAlignments.add(newAFP);
    i++;
  }
 while (i < params.getMaxSymmOrder() && multiPass);
  if (lastMatrix == null && selfAlignments.size() > 1 && multiPass) {
    AFPChain last=selfAlignments.get(selfAlignments.size() - 1);
    lastMatrix=SymmetryTools.blankOutPreviousAlignment(last,ca2,last.getCa1Length(),last.getCa2Length(),calculator,origM,params.getWinSize());
    lastMatrix=lastMatrix.getMatrix(0,last.getCa1Length() - 1,0,last.getCa2Length() - 1);
  }
  result.setSelfAlignment(selfAlignments.get(0));
  if (params.getSymmType() == SymmetryType.AUTO) {
    if (result.getSelfAlignment().getBlockNum() == 1) {
      result.setType(SymmetryType.OPEN);
      logger.info("String_Node_Str");
    }
 else {
      result.setType(SymmetryType.CLOSE);
      logger.info("String_Node_Str");
    }
  }
  SymmetryRefiner refiner=null;
  OrderDetector orderDetector=null;
  int order=1;
  try {
switch (result.getType()) {
case CLOSE:
switch (params.getOrderDetectorMethod()) {
case SEQUENCE_FUNCTION:
        orderDetector=new SequenceFunctionOrderDetector(params.getMaxSymmOrder(),0.4f);
      order=orderDetector.calculateOrder(result.getSelfAlignment(),atoms);
    break;
case USER_INPUT:
  order=params.getUserOrder();
break;
}
switch (params.getRefineMethod()) {
case NOT_REFINED:
result.setSymmOrder(order);
return result;
case GRAPH:
order=0;
refiner=new GraphRefiner();
break;
case SINGLE:
refiner=new SingleRefiner();
break;
}
break;
default :
if (params.getRefineMethod() == RefineMethod.NOT_REFINED) {
return result;
}
 else {
refiner=new OpenRefiner();
order=params.getUserOrder();
}
break;
}
MultipleAlignment msa=refiner.refine(result.getSelfAlignment(),atoms,order);
result.setMultipleAlignment(msa);
result.setSymmOrder(msa.size());
result.setRefined(true);
}
 catch (RefinerFailedException e) {
logger.info("String_Node_Str" + e.getMessage());
return result;
}
SymmetryAxes axes=new SymmetryAxes();
order=result.getSymmOrder();
Matrix4d axis=result.getMultipleAlignment().getBlockSet(0).getTransformations().get(1);
List<List<Integer>> superposition=new ArrayList<List<Integer>>();
List<Integer> chain1=new ArrayList<Integer>();
List<Integer> chain2=new ArrayList<Integer>();
superposition.add(chain1);
superposition.add(chain2);
List<Integer> subunitTrans=new ArrayList<Integer>();
switch (result.getType()) {
case CLOSE:
for (int bk=0; bk < order; bk++) {
chain1.add(bk);
chain2.add((bk + 1) % order);
subunitTrans.add(bk);
}
axes.addAxis(axis,superposition,subunitTrans,order);
break;
default :
subunitTrans.add(0);
for (int bk=0; bk < order - 1; bk++) {
chain1.add(bk);
chain2.add(bk + 1);
subunitTrans.add(bk + 1);
}
axes.addAxis(axis,superposition,subunitTrans,order);
break;
}
result.setAxes(axes);
return result;
}