Program: 17169
Project: 17169
Buggy source:
/** 
 * Handler for ATOM Record Format <pre> 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) throws PDBParseException {
  boolean startOfNewChain=false;
  String chain_id=line.substring(21,22);
  if (current_chain == null) {
    current_chain=new ChainImpl();
    current_chain.setName(chain_id);
    startOfNewChain=true;
    current_model.add(current_chain);
  }
  if (!chain_id.equals(current_chain.getName())) {
    startOfNewChain=true;
    current_chain.addGroup(current_group);
    Chain testchain;
    testchain=isKnownChain(current_chain.getName(),current_model);
    if (testchain != null && testchain.getName().equals(chain_id)) {
    }
 else {
      testchain=isKnownChain(chain_id,current_model);
    }
    if (testchain == null) {
      current_chain=new ChainImpl();
      current_chain.setName(chain_id);
    }
 else {
      current_chain=testchain;
    }
    if (!current_model.contains(current_chain))     current_model.add(current_chain);
  }
  String recordName=line.substring(0,6).trim();
  String residueNumber=line.substring(22,27).trim();
  String groupCode3=line.substring(17,20);
  Character aminoCode1=null;
  if (recordName.equals("String_Node_Str")) {
    aminoCode1=StructureTools.get1LetterCode(groupCode3);
  }
  if (current_group == null) {
    current_group=getNewGroup(recordName,aminoCode1);
    current_group.setPDBCode(residueNumber);
    current_group.setPDBName(groupCode3);
  }
  if (startOfNewChain) {
    current_group=getNewGroup(recordName,aminoCode1);
    current_group.setPDBCode(residueNumber);
    current_group.setPDBName(groupCode3);
  }
  if (!residueNumber.equals(current_group.getPDBCode())) {
    current_chain.addGroup(current_group);
    current_group=getNewGroup(recordName,aminoCode1);
    current_group.setPDBCode(residueNumber);
    current_group.setPDBName(groupCode3);
  }
  if (headerOnly)   return;
  atomCount++;
  if (atomCount == ATOM_CA_THRESHOLD) {
    System.err.println("String_Node_Str" + ATOM_CA_THRESHOLD + "String_Node_Str");
    seqResChains.clear();
    switchCAOnly();
  }
  if (atomCount == MAX_ATOMS) {
    System.err.println("String_Node_Str" + MAX_ATOMS + "String_Node_Str");
    System.err.println("String_Node_Str" + line);
    return;
  }
  if (atomCount > MAX_ATOMS) {
    return;
  }
  String fullname=line.substring(12,16);
  if (parseCAOnly) {
    if (!fullname.equals("String_Node_Str")) {
      atomCount--;
      return;
    }
  }
  int pdbnumber=Integer.parseInt(line.substring(6,11).trim());
  AtomImpl atom=new AtomImpl();
  atom.setPDBserial(pdbnumber);
  Character altLoc=new Character(line.substring(16,17).charAt(0));
  atom.setAltLoc(altLoc);
  atom.setFullName(fullname);
  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);
  double occu=1.0;
  if (line.length() > 59) {
    try {
      occu=Double.parseDouble(line.substring(54,60).trim());
    }
 catch (    NumberFormatException e) {
    }
  }
  double tempf=0.0;
  if (line.length() > 65)   try {
    tempf=Double.parseDouble(line.substring(60,66).trim());
  }
 catch (  NumberFormatException e) {
  }
  atom.setOccupancy(occu);
  atom.setTempFactor(tempf);
  current_group.addAtom(atom);
}

Fixed version (ground truth):
/** 
 * Handler for ATOM Record Format <pre> 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) throws PDBParseException {
  boolean startOfNewChain=false;
  String chain_id=line.substring(21,22);
  if (current_chain == null) {
    current_chain=new ChainImpl();
    current_chain.setName(chain_id);
    startOfNewChain=true;
    current_model.add(current_chain);
  }
  if (!chain_id.equals(current_chain.getName())) {
    startOfNewChain=true;
    current_chain.addGroup(current_group);
    Chain testchain;
    testchain=isKnownChain(current_chain.getName(),current_model);
    if (testchain != null && testchain.getName().equals(chain_id)) {
    }
 else {
      testchain=isKnownChain(chain_id,current_model);
    }
    if (testchain == null) {
      current_chain=new ChainImpl();
      current_chain.setName(chain_id);
    }
 else {
      current_chain=testchain;
    }
    if (!current_model.contains(current_chain))     current_model.add(current_chain);
  }
  String recordName=line.substring(0,6).trim();
  String residueNumber=line.substring(22,27).trim();
  String groupCode3=line.substring(17,20);
  Character aminoCode1=null;
  if (recordName.equals("String_Node_Str")) {
    aminoCode1=StructureTools.get1LetterCode(groupCode3);
  }
 else {
    aminoCode1=StructureTools.get1LetterCode(groupCode3);
    if (aminoCode1.equals(StructureTools.UNKNOWN_GROUP_LABEL))     aminoCode1=null;
  }
  if (current_group == null) {
    current_group=getNewGroup(recordName,aminoCode1);
    current_group.setPDBCode(residueNumber);
    current_group.setPDBName(groupCode3);
  }
  if (startOfNewChain) {
    current_group=getNewGroup(recordName,aminoCode1);
    current_group.setPDBCode(residueNumber);
    current_group.setPDBName(groupCode3);
  }
  if (!residueNumber.equals(current_group.getPDBCode())) {
    current_chain.addGroup(current_group);
    current_group=getNewGroup(recordName,aminoCode1);
    current_group.setPDBCode(residueNumber);
    current_group.setPDBName(groupCode3);
  }
  if (headerOnly)   return;
  atomCount++;
  if (atomCount == ATOM_CA_THRESHOLD) {
    System.err.println("String_Node_Str" + ATOM_CA_THRESHOLD + "String_Node_Str");
    seqResChains.clear();
    switchCAOnly();
  }
  if (atomCount == MAX_ATOMS) {
    System.err.println("String_Node_Str" + MAX_ATOMS + "String_Node_Str");
    System.err.println("String_Node_Str" + line);
    return;
  }
  if (atomCount > MAX_ATOMS) {
    return;
  }
  String fullname=line.substring(12,16);
  if (parseCAOnly) {
    if (!fullname.equals("String_Node_Str")) {
      atomCount--;
      return;
    }
  }
  int pdbnumber=Integer.parseInt(line.substring(6,11).trim());
  AtomImpl atom=new AtomImpl();
  atom.setPDBserial(pdbnumber);
  Character altLoc=new Character(line.substring(16,17).charAt(0));
  atom.setAltLoc(altLoc);
  atom.setFullName(fullname);
  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);
  double occu=1.0;
  if (line.length() > 59) {
    try {
      occu=Double.parseDouble(line.substring(54,60).trim());
    }
 catch (    NumberFormatException e) {
    }
  }
  double tempf=0.0;
  if (line.length() > 65)   try {
    tempf=Double.parseDouble(line.substring(60,66).trim());
  }
 catch (  NumberFormatException e) {
  }
  atom.setOccupancy(occu);
  atom.setTempFactor(tempf);
  current_group.addAtom(atom);
}