Program: 16343
Project: 16343
Buggy source:
private void solve(){
  if (!preCheck()) {
    return;
  }
  HelicalRepeatUnit unit=new HelicalRepeatUnit(subunits);
  List<Point3d> repeatUnitCenters=unit.getRepeatUnitCenters();
  List<Point3d[]> repeatUnits=unit.getRepeatUnits();
  Set<List<Integer>> permutations=new HashSet<List<Integer>>();
  double minRise=parameters.getMinimumHelixRise() * fold;
  Map<Integer[],Integer> interactionMap=unit.getInteractingRepeatUnits();
  int maxLayerLineLength=0;
  for (  Entry<Integer[],Integer> entry : interactionMap.entrySet()) {
    Integer[] pair=entry.getKey();
    logger.debug("String_Node_Str" + Arrays.toString(pair));
    int contacts=entry.getValue();
    Point3d[] h1=null;
    Point3d[] h2=null;
    h1=SuperPosition.clonePoint3dArray(repeatUnits.get(pair[0]));
    h2=SuperPosition.clonePoint3dArray(repeatUnits.get(pair[1]));
    Matrix4d transformation=SuperPosition.superposeWithTranslation(h1,h2);
    double rmsd=SuperPosition.rmsd(h1,h2);
    double rise=getRise(transformation,repeatUnitCenters.get(pair[0]),repeatUnitCenters.get(pair[1]));
    double angle=getAngle(transformation);
    logger.debug("String_Node_Str",rmsd,rise,Math.toDegrees(angle));
    if (rmsd > parameters.getRmsdThreshold()) {
      continue;
    }
    if (Math.abs(rise) < minRise) {
      continue;
    }
    List<Integer> permutation=getPermutation(transformation);
    if (permutations.contains(permutation)) {
      continue;
    }
    permutations.add(permutation);
    logger.debug("String_Node_Str" + permutation);
    Set<Integer> permSet=new HashSet<Integer>();
    int count=0;
    boolean valid=true;
    for (int i=0; i < permutation.size(); i++) {
      if (permutation.get(i) == i) {
        valid=false;
        break;
      }
      if (permutation.get(i) != -1) {
        permSet.add(permutation.get(i));
        permSet.add(i);
        count++;
      }
    }
    if (!valid) {
      logger.debug("String_Node_Str");
      continue;
    }
    if (permSet.size() != subunits.getSubunitCount()) {
      logger.debug("String_Node_Str");
      continue;
    }
    if (count == permutation.size()) {
      continue;
    }
    List<Point3d> point1=new ArrayList<Point3d>();
    List<Point3d> point2=new ArrayList<Point3d>();
    List<Point3d> centers=subunits.getOriginalCenters();
    for (int j=0; j < permutation.size(); j++) {
      if (permutation.get(j) != -1) {
        point1.add(new Point3d(centers.get(j)));
        point2.add(new Point3d(centers.get(permutation.get(j))));
      }
    }
    h1=new Point3d[point1.size()];
    h2=new Point3d[point2.size()];
    point1.toArray(h1);
    point2.toArray(h2);
    double subunitRmsd=0;
    if (point1.size() > 2) {
      transformation=SuperPosition.superposeWithTranslation(h1,h2);
      subunitRmsd=SuperPosition.rmsd(h1,h2);
      rise=getRise(transformation,repeatUnitCenters.get(pair[0]),repeatUnitCenters.get(pair[1]));
      angle=getAngle(transformation);
      logger.debug("String_Node_Str",subunitRmsd,rise,Math.toDegrees(angle));
      if (subunitRmsd > parameters.getRmsdThreshold()) {
        continue;
      }
      if (Math.abs(rise) < minRise) {
        continue;
      }
      if (subunitRmsd > parameters.getHelixRmsdToRiseRatio() * Math.abs(rise)) {
        continue;
      }
    }
    point1.clear();
    point2.clear();
    List<Point3d[]> traces=subunits.getTraces();
    for (int j=0; j < permutation.size(); j++) {
      if (permutation.get(j) == -1) {
        continue;
      }
      for (      Point3d p : traces.get(j)) {
        point1.add(new Point3d(p));
      }
      for (      Point3d p : traces.get(permutation.get(j))) {
        point2.add(new Point3d(p));
      }
    }
    h1=new Point3d[point1.size()];
    h2=new Point3d[point2.size()];
    point1.toArray(h1);
    point2.toArray(h2);
    Point3d[] h3=SuperPosition.clonePoint3dArray(h1);
    transformation=SuperPosition.superposeWithTranslation(h1,h2);
    Point3d xtrans=SuperPosition.centroid(h3);
    xtrans.negate();
    double traceRmsd=SuperPosition.rmsd(h1,h2);
    rise=getRise(transformation,repeatUnitCenters.get(pair[0]),repeatUnitCenters.get(pair[1]));
    angle=getAngle(transformation);
    logger.debug("String_Node_Str" + traceRmsd);
    logger.debug("String_Node_Str" + rise);
    logger.debug("String_Node_Str" + Math.toDegrees(angle));
    logger.debug("String_Node_Str" + permutation);
    if (traceRmsd > parameters.getRmsdThreshold()) {
      continue;
    }
    if (Math.abs(rise) < minRise) {
      continue;
    }
    if (angle < Math.toRadians(parameters.getMinimumHelixAngle())) {
      continue;
    }
    if (traceRmsd > parameters.getHelixRmsdToRiseRatio() * Math.abs(rise)) {
      continue;
    }
    AxisAngle4d a1=new AxisAngle4d();
    a1.set(transformation);
    Helix helix=new Helix();
    helix.setTransformation(transformation);
    helix.setPermutation(permutation);
    helix.setRise(rise);
    transformation.setElement(3,3,1.0);
    transformation.invert();
    QuatSymmetryScores scores=QuatSuperpositionScorer.calcScores(subunits,transformation,permutation);
    scores.setRmsdCenters(subunitRmsd);
    helix.setScores(scores);
    helix.setFold(fold);
    helix.setContacts(contacts);
    helix.setRepeatUnits(unit.getRepeatUnitIndices());
    logger.debug("String_Node_Str" + helix.getLayerLines());
    for (    List<Integer> line : helix.getLayerLines()) {
      maxLayerLineLength=Math.max(maxLayerLineLength,line.size());
    }
    helixLayers.addHelix(helix);
  }
  if (maxLayerLineLength < 3) {
    helixLayers.clear();
  }
  return;
}

Fixed version (ground truth):
private void solve(){
  if (!preCheck()) {
    return;
  }
  HelicalRepeatUnit unit=new HelicalRepeatUnit(subunits);
  List<Point3d> repeatUnitCenters=unit.getRepeatUnitCenters();
  List<Point3d[]> repeatUnits=unit.getRepeatUnits();
  Set<List<Integer>> permutations=new HashSet<List<Integer>>();
  double minRise=parameters.getMinimumHelixRise() * fold;
  Map<Integer[],Integer> interactionMap=unit.getInteractingRepeatUnits();
  int maxLayerLineLength=0;
  for (  Entry<Integer[],Integer> entry : interactionMap.entrySet()) {
    Integer[] pair=entry.getKey();
    logger.debug("String_Node_Str" + Arrays.toString(pair));
    int contacts=entry.getValue();
    Point3d[] h1=null;
    Point3d[] h2=null;
    h1=SuperPosition.clonePoint3dArray(repeatUnits.get(pair[0]));
    h2=SuperPosition.clonePoint3dArray(repeatUnits.get(pair[1]));
    Matrix4d transformation=SuperPosition.superposeWithTranslation(h1,h2);
    double rmsd=SuperPosition.rmsd(h1,h2);
    double rise=getRise(transformation,repeatUnitCenters.get(pair[0]),repeatUnitCenters.get(pair[1]));
    double angle=getAngle(transformation);
    logger.debug("String_Node_Str",rmsd,rise,Math.toDegrees(angle));
    if (rmsd > parameters.getRmsdThreshold()) {
      continue;
    }
    if (Math.abs(rise) < minRise) {
      continue;
    }
    List<Integer> permutation=getPermutation(transformation);
    if (permutations.contains(permutation)) {
      continue;
    }
    permutations.add(permutation);
    logger.debug("String_Node_Str" + permutation);
    Set<Integer> permSet=new HashSet<Integer>();
    int count=0;
    boolean valid=true;
    for (int i=0; i < permutation.size(); i++) {
      if (permutation.get(i) == i) {
        valid=false;
        break;
      }
      if (permutation.get(i) != -1) {
        permSet.add(permutation.get(i));
        permSet.add(i);
        count++;
      }
    }
    if (!valid) {
      logger.debug("String_Node_Str");
      continue;
    }
    if (permSet.size() != subunits.getSubunitCount()) {
      logger.debug("String_Node_Str");
      continue;
    }
    if (count == permutation.size()) {
      continue;
    }
    List<Point3d> point1=new ArrayList<Point3d>();
    List<Point3d> point2=new ArrayList<Point3d>();
    List<Point3d> centers=subunits.getOriginalCenters();
    for (int j=0; j < permutation.size(); j++) {
      if (permutation.get(j) != -1) {
        point1.add(new Point3d(centers.get(j)));
        point2.add(new Point3d(centers.get(permutation.get(j))));
      }
    }
    h1=new Point3d[point1.size()];
    h2=new Point3d[point2.size()];
    point1.toArray(h1);
    point2.toArray(h2);
    double subunitRmsd=0;
    if (point1.size() > 2) {
      transformation=SuperPosition.superposeWithTranslation(h1,h2);
      subunitRmsd=SuperPosition.rmsd(h1,h2);
      rise=getRise(transformation,repeatUnitCenters.get(pair[0]),repeatUnitCenters.get(pair[1]));
      angle=getAngle(transformation);
      logger.debug("String_Node_Str",subunitRmsd,rise,Math.toDegrees(angle));
      if (subunitRmsd > parameters.getRmsdThreshold()) {
        continue;
      }
      if (Math.abs(rise) < minRise) {
        continue;
      }
      if (subunitRmsd > parameters.getHelixRmsdToRiseRatio() * Math.abs(rise)) {
        continue;
      }
    }
    point1.clear();
    point2.clear();
    List<Point3d[]> traces=subunits.getTraces();
    for (int j=0; j < permutation.size(); j++) {
      if (permutation.get(j) == -1) {
        continue;
      }
      for (      Point3d p : traces.get(j)) {
        point1.add(new Point3d(p));
      }
      for (      Point3d p : traces.get(permutation.get(j))) {
        point2.add(new Point3d(p));
      }
    }
    h1=new Point3d[point1.size()];
    h2=new Point3d[point2.size()];
    point1.toArray(h1);
    point2.toArray(h2);
    Point3d[] h3=SuperPosition.clonePoint3dArray(h1);
    transformation=SuperPosition.superposeWithTranslation(h1,h2);
    Point3d xtrans=Calc.getCentroid(h3);
    xtrans.negate();
    double traceRmsd=SuperPosition.rmsd(h1,h2);
    rise=getRise(transformation,repeatUnitCenters.get(pair[0]),repeatUnitCenters.get(pair[1]));
    angle=getAngle(transformation);
    logger.debug("String_Node_Str" + traceRmsd);
    logger.debug("String_Node_Str" + rise);
    logger.debug("String_Node_Str" + Math.toDegrees(angle));
    logger.debug("String_Node_Str" + permutation);
    if (traceRmsd > parameters.getRmsdThreshold()) {
      continue;
    }
    if (Math.abs(rise) < minRise) {
      continue;
    }
    if (angle < Math.toRadians(parameters.getMinimumHelixAngle())) {
      continue;
    }
    if (traceRmsd > parameters.getHelixRmsdToRiseRatio() * Math.abs(rise)) {
      continue;
    }
    AxisAngle4d a1=new AxisAngle4d();
    a1.set(transformation);
    Helix helix=new Helix();
    helix.setTransformation(transformation);
    helix.setPermutation(permutation);
    helix.setRise(rise);
    transformation.setElement(3,3,1.0);
    transformation.invert();
    QuatSymmetryScores scores=QuatSuperpositionScorer.calcScores(subunits,transformation,permutation);
    scores.setRmsdCenters(subunitRmsd);
    helix.setScores(scores);
    helix.setFold(fold);
    helix.setContacts(contacts);
    helix.setRepeatUnits(unit.getRepeatUnitIndices());
    logger.debug("String_Node_Str" + helix.getLayerLines());
    for (    List<Integer> line : helix.getLayerLines()) {
      maxLayerLineLength=Math.max(maxLayerLineLength,line.size());
    }
    helixLayers.addHelix(helix);
  }
  if (maxLayerLineLength < 3) {
    helixLayers.clear();
  }
  return;
}