Program: 16401
Project: 16401
Buggy source:
/** 
 * Get the predominant   {@link GroupType} for a given Chain, following theserules: <li>if the ratio of number of residues of a certain {@link GroupType} to total non-water residues is above the threshold{@value #RATIO_RESIDUES_TO_TOTAL}, then that   {@link GroupType} isreturned</li> <li>if there is no  {@link GroupType} that is above thethreshold then the  {@link GroupType} with most members is chosen, loggingit</li> <p> See also  {@link ChemComp#getPolymerType()} and{@link ChemComp#getResidueType()} which follow the PDB chemical componentdictionary and provide a much more accurate description of groups and their linking. </p>
 * @param c
 * @return
 */
public static GroupType getPredominantGroupType(Chain c){
  int sizeAminos=c.getAtomGroups(GroupType.AMINOACID).size();
  int sizeNucleotides=c.getAtomGroups(GroupType.NUCLEOTIDE).size();
  List<Group> hetAtoms=c.getAtomGroups(GroupType.HETATM);
  int sizeHetatoms=hetAtoms.size();
  int sizeWaters=0;
  for (  Group g : hetAtoms) {
    if (g.isWater())     sizeWaters++;
  }
  int sizeHetatomsWithoutWater=sizeHetatoms - sizeWaters;
  int fullSize=sizeAminos + sizeNucleotides + sizeHetatomsWithoutWater;
  if ((double)sizeAminos / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.AMINOACID;
  if ((double)sizeNucleotides / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.NUCLEOTIDE;
  if ((double)(sizeHetatomsWithoutWater) / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.HETATM;
  GroupType max;
  if (sizeNucleotides > sizeAminos) {
    if (sizeNucleotides > sizeHetatomsWithoutWater) {
      max=GroupType.NUCLEOTIDE;
    }
 else {
      max=GroupType.HETATM;
    }
  }
 else {
    if (sizeAminos > sizeHetatomsWithoutWater) {
      max=GroupType.AMINOACID;
    }
 else {
      max=GroupType.HETATM;
    }
  }
  logger.debug("String_Node_Str" + "String_Node_Str" + "String_Node_Str",c.getChainID(),RATIO_RESIDUES_TO_TOTAL,max,sizeAminos,sizeNucleotides,sizeHetatomsWithoutWater,sizeWaters,(double)sizeAminos / (double)fullSize,(double)sizeNucleotides / (double)fullSize);
  return max;
}

Fixed version (ground truth):
/** 
 * Get the predominant   {@link GroupType} for a given Chain, following theserules: <li>if the ratio of number of residues of a certain {@link GroupType} to total non-water residues is above the threshold{@value #RATIO_RESIDUES_TO_TOTAL}, then that   {@link GroupType} isreturned</li> <li>if there is no  {@link GroupType} that is above thethreshold then the  {@link GroupType} with most members is chosen, loggingit</li> <p> See also  {@link ChemComp#getPolymerType()} and{@link ChemComp#getResidueType()} which follow the PDB chemical componentdictionary and provide a much more accurate description of groups and their linking. </p>
 * @param c
 * @return
 */
public static GroupType getPredominantGroupType(Chain c){
  int sizeAminos=c.getAtomGroups(GroupType.AMINOACID).size();
  int sizeNucleotides=c.getAtomGroups(GroupType.NUCLEOTIDE).size();
  List<Group> hetAtoms=c.getAtomGroups(GroupType.HETATM);
  int sizeHetatoms=hetAtoms.size();
  int sizeWaters=0;
  for (  Group g : hetAtoms) {
    if (g.isWater())     sizeWaters++;
  }
  int sizeHetatomsWithoutWater=sizeHetatoms - sizeWaters;
  int fullSize=sizeAminos + sizeNucleotides + sizeHetatomsWithoutWater;
  if ((double)sizeAminos / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.AMINOACID;
  if ((double)sizeNucleotides / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.NUCLEOTIDE;
  if ((double)(sizeHetatomsWithoutWater) / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.HETATM;
  GroupType max;
  if (sizeNucleotides > sizeAminos) {
    if (sizeNucleotides > sizeHetatomsWithoutWater) {
      max=GroupType.NUCLEOTIDE;
    }
 else {
      max=GroupType.HETATM;
    }
  }
 else {
    if (sizeAminos > sizeHetatomsWithoutWater) {
      max=GroupType.AMINOACID;
    }
 else {
      max=GroupType.HETATM;
    }
  }
  logger.debug("String_Node_Str" + "String_Node_Str" + "String_Node_Str",c.getId(),RATIO_RESIDUES_TO_TOTAL,max,sizeAminos,sizeNucleotides,sizeHetatomsWithoutWater,sizeWaters,(double)sizeAminos / (double)fullSize,(double)sizeNucleotides / (double)fullSize);
  return max;
}