Program: 16422
Project: 16422
Buggy source:
/** 
 * Handler for ATOM. Record Format: <pre> ATOM      1  N   ASP A  15     110.964  24.941  59.191  1.00 83.44           N COLUMNS        DATA TYPE       FIELD         DEFINITION --------------------------------------------------------------------------------- 1 -  6        Record name     "ATOM  " 7 - 11        Integer         serial        Atom serial number. 13 - 16        Atom            name          Atom name. 17             Character       altLoc        Alternate location indicator. 18 - 20        Residue name    resName       Residue name. 22             Character       chainID       Chain identifier. 23 - 26        Integer         resSeq        Residue sequence number. 27             AChar           iCode         Code for insertion of residues. 31 - 38        Real(8.3)       x             Orthogonal coordinates for X in Angstroms. 39 - 46        Real(8.3)       y             Orthogonal coordinates for Y in Angstroms. 47 - 54        Real(8.3)       z             Orthogonal coordinates for Z in Angstroms. 55 - 60        Real(6.2)       occupancy     Occupancy. 61 - 66        Real(6.2)       tempFactor    Temperature factor. 73 - 76        LString(4)      segID         Segment identifier, left-justified. 77 - 78        LString(2)      element       Element symbol, right-justified. 79 - 80        LString(2)      charge        Charge on the atom. </pre>
 */
private void pdb_ATOM_Handler(String line){
  if (params.isHeaderOnly())   return;
  String chainName=line.substring(21,22);
  if (chainName.equals("String_Node_Str")) {
    blankChainIdsPresent=true;
  }
  if (currentChain != null && !currentChain.getName().equals(chainName)) {
    startOfMolecule=true;
  }
  if (startOfMolecule) {
    if (currentChain != null) {
      currentModel.add(currentChain);
      if (currentGroup != null) {
        currentChain.addGroup(currentGroup);
      }
    }
    currentChain=new ChainImpl();
    currentChain.setId(chainName);
    currentChain.setName(chainName);
  }
  if (startOfModel) {
    if (currentModel != null) {
      allModels.add(currentModel);
    }
    currentModel=new ArrayList<>();
  }
  String groupCode3=line.substring(17,20).trim();
  String resNum=line.substring(22,26).trim();
  Character iCode=line.substring(26,27).charAt(0);
  if (iCode == ' ')   iCode=null;
  ResidueNumber residueNumber=new ResidueNumber(chainName,Integer.valueOf(resNum),iCode);
  Character aminoCode1=StructureTools.get1LetterCode(groupCode3);
  String recordName=line.substring(0,6).trim();
  boolean isHetAtomInFile=false;
  if (recordName.equals("String_Node_Str")) {
    if (aminoCode1 != null && aminoCode1.equals(StructureTools.UNKNOWN_GROUP_LABEL))     aminoCode1=null;
    isHetAtomInFile=true;
  }
  if (startOfMolecule) {
    currentGroup=getNewGroup(recordName,aminoCode1,groupCode3);
    currentGroup.setPDBName(groupCode3);
    currentGroup.setResidueNumber(residueNumber);
  }
  startOfModel=false;
  startOfMolecule=false;
  Character altLoc=new Character(line.substring(16,17).charAt(0));
  Group altGroup=null;
  if (!residueNumber.equals(currentGroup.getResidueNumber())) {
    currentChain.addGroup(currentGroup);
    currentGroup.trimToSize();
    currentGroup=getNewGroup(recordName,aminoCode1,groupCode3);
    currentGroup.setPDBName(groupCode3);
    currentGroup.setResidueNumber(residueNumber);
    currentGroup.setHetAtomInFile(isHetAtomInFile);
  }
 else {
    if (!altLoc.equals(' ')) {
      logger.debug("String_Node_Str" + currentGroup + "String_Node_Str"+ altGroup);
      altGroup=getCorrectAltLocGroup(altLoc,recordName,aminoCode1,groupCode3);
      if (altGroup.getChain() == null) {
        altGroup.setChain(currentChain);
      }
    }
  }
  atomCount++;
  if (atomCount == atomCAThreshold) {
    logger.warn("String_Node_Str" + atomCAThreshold + "String_Node_Str");
    seqResChains.clear();
    switchCAOnly();
  }
  if (atomCount == loadMaxAtoms) {
    logger.warn("String_Node_Str",loadMaxAtoms,line);
    return;
  }
  if (atomCount > loadMaxAtoms) {
    return;
  }
  String fullname=line.substring(12,16);
  if (parseCAonly) {
    if (!fullname.equals("String_Node_Str")) {
      atomCount--;
      return;
    }
  }
  if (params.getAcceptedAtomNames() != null) {
    boolean found=false;
    for (    String ok : params.getAcceptedAtomNames()) {
      if (ok.equals(fullname.trim())) {
        found=true;
        break;
      }
    }
    if (!found) {
      atomCount--;
      return;
    }
  }
  int pdbnumber=Integer.parseInt(line.substring(6,11).trim());
  AtomImpl atom=new AtomImpl();
  atom.setPDBserial(pdbnumber);
  atom.setAltLoc(altLoc);
  atom.setName(fullname.trim());
  double x=Double.parseDouble(line.substring(30,38).trim());
  double y=Double.parseDouble(line.substring(38,46).trim());
  double z=Double.parseDouble(line.substring(46,54).trim());
  double[] coords=new double[3];
  coords[0]=x;
  coords[1]=y;
  coords[2]=z;
  atom.setCoords(coords);
  float occu=1.0f;
  if (line.length() > 59) {
    try {
      occu=Float.parseFloat(line.substring(54,60).trim());
    }
 catch (    NumberFormatException e) {
    }
  }
  float tempf=0.0f;
  if (line.length() > 65) {
    try {
      tempf=Float.parseFloat(line.substring(60,66).trim());
    }
 catch (    NumberFormatException e) {
    }
  }
  atom.setOccupancy(occu);
  atom.setTempFactor(tempf);
  Element element=Element.R;
  if (line.length() > 77) {
    try {
      element=Element.valueOfIgnoreCase(line.substring(76,78).trim());
    }
 catch (    IllegalArgumentException e) {
    }
  }
 else {
    String elementSymbol=null;
    if (fullname.trim().length() == 4) {
      elementSymbol=fullname.substring(0,1);
    }
 else     if (fullname.trim().length() > 1) {
      elementSymbol=fullname.substring(0,2).trim();
    }
    try {
      if (elementSymbol != null)       element=Element.valueOfIgnoreCase(elementSymbol);
    }
 catch (    IllegalArgumentException e) {
      logger.warn("String_Node_Str",elementSymbol);
    }
  }
  atom.setElement(element);
  if (altGroup != null) {
    altGroup.addAtom(atom);
    altGroup=null;
  }
 else {
    currentGroup.addAtom(atom);
  }
  if (!currentGroup.hasAtom(atom.getName())) {
    currentGroup.addAtom(atom);
  }
}

Fixed version (ground truth):
/** 
 * Handler for ATOM. Record Format: <pre> ATOM      1  N   ASP A  15     110.964  24.941  59.191  1.00 83.44           N COLUMNS        DATA TYPE       FIELD         DEFINITION --------------------------------------------------------------------------------- 1 -  6        Record name     "ATOM  " 7 - 11        Integer         serial        Atom serial number. 13 - 16        Atom            name          Atom name. 17             Character       altLoc        Alternate location indicator. 18 - 20        Residue name    resName       Residue name. 22             Character       chainID       Chain identifier. 23 - 26        Integer         resSeq        Residue sequence number. 27             AChar           iCode         Code for insertion of residues. 31 - 38        Real(8.3)       x             Orthogonal coordinates for X in Angstroms. 39 - 46        Real(8.3)       y             Orthogonal coordinates for Y in Angstroms. 47 - 54        Real(8.3)       z             Orthogonal coordinates for Z in Angstroms. 55 - 60        Real(6.2)       occupancy     Occupancy. 61 - 66        Real(6.2)       tempFactor    Temperature factor. 73 - 76        LString(4)      segID         Segment identifier, left-justified. 77 - 78        LString(2)      element       Element symbol, right-justified. 79 - 80        LString(2)      charge        Charge on the atom. </pre>
 */
private void pdb_ATOM_Handler(String line){
  if (params.isHeaderOnly())   return;
  String chainName=line.substring(21,22);
  if (chainName.equals("String_Node_Str")) {
    blankChainIdsPresent=true;
  }
  if (currentChain != null && !currentChain.getName().equals(chainName)) {
    startOfMolecule=true;
  }
  if (startOfMolecule) {
    if (currentChain != null) {
      currentModel.add(currentChain);
      if (currentGroup != null) {
        currentChain.addGroup(currentGroup);
      }
    }
    currentChain=new ChainImpl();
    currentChain.setId(chainName);
    currentChain.setName(chainName);
  }
  if (startOfModel) {
    if (currentModel != null) {
      allModels.add(currentModel);
    }
    currentModel=new ArrayList<>();
  }
  String groupCode3=line.substring(17,20).trim();
  String resNum=line.substring(22,26).trim();
  Character iCode=line.substring(26,27).charAt(0);
  if (iCode == ' ')   iCode=null;
  ResidueNumber residueNumber=new ResidueNumber(chainName,Integer.valueOf(resNum),iCode);
  Character aminoCode1=StructureTools.get1LetterCode(groupCode3);
  String recordName=line.substring(0,6).trim();
  boolean isHetAtomInFile=false;
  if (recordName.equals("String_Node_Str")) {
    if (aminoCode1 != null && aminoCode1.equals(StructureTools.UNKNOWN_GROUP_LABEL))     aminoCode1=null;
    isHetAtomInFile=true;
  }
  if (startOfMolecule) {
    currentGroup=getNewGroup(recordName,aminoCode1,groupCode3);
    currentGroup.setPDBName(groupCode3);
    currentGroup.setResidueNumber(residueNumber);
    currentGroup.setHetAtomInFile(isHetAtomInFile);
  }
  startOfModel=false;
  startOfMolecule=false;
  Character altLoc=new Character(line.substring(16,17).charAt(0));
  Group altGroup=null;
  if (!residueNumber.equals(currentGroup.getResidueNumber())) {
    currentChain.addGroup(currentGroup);
    currentGroup.trimToSize();
    currentGroup=getNewGroup(recordName,aminoCode1,groupCode3);
    currentGroup.setPDBName(groupCode3);
    currentGroup.setResidueNumber(residueNumber);
    currentGroup.setHetAtomInFile(isHetAtomInFile);
  }
 else {
    if (!altLoc.equals(' ')) {
      logger.debug("String_Node_Str" + currentGroup + "String_Node_Str"+ altGroup);
      altGroup=getCorrectAltLocGroup(altLoc,recordName,aminoCode1,groupCode3);
      if (altGroup.getChain() == null) {
        altGroup.setChain(currentChain);
      }
    }
  }
  atomCount++;
  if (atomCount == atomCAThreshold) {
    logger.warn("String_Node_Str" + atomCAThreshold + "String_Node_Str");
    seqResChains.clear();
    switchCAOnly();
  }
  if (atomCount == loadMaxAtoms) {
    logger.warn("String_Node_Str",loadMaxAtoms,line);
    return;
  }
  if (atomCount > loadMaxAtoms) {
    return;
  }
  String fullname=line.substring(12,16);
  if (parseCAonly) {
    if (!fullname.equals("String_Node_Str")) {
      atomCount--;
      return;
    }
  }
  if (params.getAcceptedAtomNames() != null) {
    boolean found=false;
    for (    String ok : params.getAcceptedAtomNames()) {
      if (ok.equals(fullname.trim())) {
        found=true;
        break;
      }
    }
    if (!found) {
      atomCount--;
      return;
    }
  }
  int pdbnumber=Integer.parseInt(line.substring(6,11).trim());
  AtomImpl atom=new AtomImpl();
  atom.setPDBserial(pdbnumber);
  atom.setAltLoc(altLoc);
  atom.setName(fullname.trim());
  double x=Double.parseDouble(line.substring(30,38).trim());
  double y=Double.parseDouble(line.substring(38,46).trim());
  double z=Double.parseDouble(line.substring(46,54).trim());
  double[] coords=new double[3];
  coords[0]=x;
  coords[1]=y;
  coords[2]=z;
  atom.setCoords(coords);
  float occu=1.0f;
  if (line.length() > 59) {
    try {
      occu=Float.parseFloat(line.substring(54,60).trim());
    }
 catch (    NumberFormatException e) {
    }
  }
  float tempf=0.0f;
  if (line.length() > 65) {
    try {
      tempf=Float.parseFloat(line.substring(60,66).trim());
    }
 catch (    NumberFormatException e) {
    }
  }
  atom.setOccupancy(occu);
  atom.setTempFactor(tempf);
  Element element=Element.R;
  if (line.length() > 77) {
    try {
      element=Element.valueOfIgnoreCase(line.substring(76,78).trim());
    }
 catch (    IllegalArgumentException e) {
    }
  }
 else {
    String elementSymbol=null;
    if (fullname.trim().length() == 4) {
      elementSymbol=fullname.substring(0,1);
    }
 else     if (fullname.trim().length() > 1) {
      elementSymbol=fullname.substring(0,2).trim();
    }
    try {
      if (elementSymbol != null)       element=Element.valueOfIgnoreCase(elementSymbol);
    }
 catch (    IllegalArgumentException e) {
      logger.warn("String_Node_Str",elementSymbol);
    }
  }
  atom.setElement(element);
  if (altGroup != null) {
    altGroup.addAtom(atom);
    altGroup=null;
  }
 else {
    currentGroup.addAtom(atom);
  }
  if (!currentGroup.hasAtom(atom.getName())) {
    currentGroup.addAtom(atom);
  }
}