Program: 16622
Project: 16622
Buggy source:
/** 
 * A minimal helix is defined by two consecutive n-turns. For example, a 4-helix, of minimal length 4 from residues  i to (i+3), requires turns (of type 4) at residues (i-1) and i. <p> Note that the orignal DSSP implementation does not assign helix type to residue (i-1) and residue (i+n+1), although  they contain a helix turn. As they state in the original paper, "the helices are one residue shorter than they would be according to rule 6.3 of IUPAC-IUB".
 * @param n
 * @param type
 */
private void checkSetHelix(int n,SecStrucType type){
  int idx=n - 3;
  logger.debug("String_Node_Str" + type + "String_Node_Str"+ n+ "String_Node_Str"+ idx);
  for (int i=1; i < groups.length; i++) {
    SecStrucState state=getSecStrucState(i);
    SecStrucState previousState=getSecStrucState(i - 1);
    char turn=state.getTurn()[idx];
    char pturn=previousState.getTurn()[idx];
    if (turn == '>' && pturn == '>') {
      if (!DSSP_HELICES)       setSecStrucType(i - 1,type);
      i++;
      SecStrucState nextState=getSecStrucState(i);
      char nturn=nextState.getTurn()[idx];
      boolean closing=false;
      boolean stop=false;
      while (!stop) {
        setSecStrucType(i - 1,type);
        i++;
        nextState=getSecStrucState(i);
        nturn=nextState.getTurn()[idx];
        if (!closing && nturn == '<')         closing=true;
        if (closing && nturn == '>')         stop=true;
        if (nturn == ' ')         stop=true;
      }
      if (!DSSP_HELICES)       setSecStrucType(i - 1,type);
    }
  }
}

Fixed version (ground truth):
/** 
 * A minimal helix is defined by two consecutive n-turns. For example, a 4-helix, of minimal length 4 from residues  i to (i+3), requires turns (of type 4) at residues (i-1) and i. <p> Note that the orignal DSSP implementation does not assign helix type to residue (i-1) and residue (i+n+1), although  they contain a helix turn. As they state in the original paper, "the helices are one residue shorter than they would be according to rule 6.3 of IUPAC-IUB".
 * @param n
 * @param type
 */
private void checkSetHelix(int n,SecStrucType type){
  int idx=n - 3;
  logger.debug("String_Node_Str" + type + "String_Node_Str"+ n+ "String_Node_Str"+ idx);
  for (int i=1; i < groups.length - 1; i++) {
    SecStrucState state=getSecStrucState(i);
    SecStrucState previousState=getSecStrucState(i - 1);
    if (state.type.isHelixType())     continue;
    if (getSecStrucState(i + 1).type.isHelixType())     continue;
    char turn=state.getTurn()[idx];
    char pturn=previousState.getTurn()[idx];
    if ((turn == '>' || turn == 'X') && (pturn == '>' || pturn == 'X')) {
      if (!DSSP_HELICES)       setSecStrucType(i - 1,type);
      i++;
      SecStrucState nextState=getSecStrucState(i);
      char nturn=nextState.getTurn()[idx];
      int counter=2;
      boolean closing=false;
      while (counter > 0) {
        setSecStrucType(i - 1,type);
        i++;
        if (nturn == 'X' && closing)         counter--;
        if (nturn == '<')         counter--;
        if (nturn == '>')         counter++;
        if (nturn == '<')         closing=true;
        nextState=getSecStrucState(i);
        nturn=nextState.getTurn()[idx];
      }
      i--;
      if (!DSSP_HELICES)       setSecStrucType(i,type);
      i--;
    }
  }
}