Program: 16791
Project: 16791
Buggy source:
/** 
 * Get the predominant   {@link GroupType} for a given Chain, following these rules:<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} is returned </li><li>if there is no  {@link GroupType} that is above the threshold then the {@link GroupType} with most members is chosen, logging it</li> See also  {@link ChemComp#getPolymerType()} and {@link ChemComp#getResidueType()} which follow the PDB chemical component dictionary and provide a much more accurate description of  groups and their linking.
 * @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 fullSize=sizeAminos + sizeNucleotides + sizeHetatoms - sizeWaters;
  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)(sizeHetatoms - sizeWaters) / (double)fullSize > RATIO_RESIDUES_TO_TOTAL)   return GroupType.HETATM;
  GroupType max;
  if (sizeNucleotides > sizeAminos) {
    if (sizeNucleotides > sizeHetatoms) {
      max=GroupType.NUCLEOTIDE;
    }
 else {
      max=GroupType.HETATM;
    }
  }
 else {
    if (sizeAminos > sizeHetatoms) {
      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,sizeHetatoms,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 these rules:<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} is returned </li><li>if there is no  {@link GroupType} that is above the threshold then the {@link GroupType} with most members is chosen, logging it</li> <p> See also  {@link ChemComp#getPolymerType()} and {@link ChemComp#getResidueType()} which follow the PDB chemical component dictionary 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;
}