Program: 16484
Project: 16484
Buggy source:
/** 
 * Converts an Atom object to an   {@link AtomSite} object.
 * @param a
 * @param model
 * @param chainId
 * @param internalChainId
 * @param atomId the atom id to be written to AtomSite
 * @return
 */
public static AtomSite convertAtomToAtomSite(Atom a,int model,String chainId,String internalChainId,int atomId){
  Group g=a.getGroup();
  String record;
  if (g.getType().equals(GroupType.HETATM)) {
    record="String_Node_Str";
  }
 else {
    record="String_Node_Str";
  }
  String entityId="String_Node_Str";
  String labelSeqId=Integer.toString(g.getResidueNumber().getSeqNum());
  if (g.getChain() != null && g.getChain().getCompound() != null) {
    entityId=Integer.toString(g.getChain().getCompound().getMolId());
    labelSeqId=Integer.toString(g.getChain().getCompound().getAlignedResIndex(g,g.getChain()));
  }
  Character altLoc=a.getAltLoc();
  String altLocStr=altLoc.toString();
  if (altLoc == null || altLoc == ' ') {
    altLocStr=MMCIF_DEFAULT_VALUE;
  }
  Element e=a.getElement();
  String eString=e.toString().toUpperCase();
  if (e.equals(Element.R)) {
    eString="String_Node_Str";
  }
  String insCode=MMCIF_MISSING_VALUE;
  if (g.getResidueNumber().getInsCode() != null) {
    insCode=Integer.toString(g.getResidueNumber().getInsCode());
  }
  AtomSite atomSite=new AtomSite();
  atomSite.setGroup_PDB(record);
  atomSite.setId(Integer.toString(atomId));
  atomSite.setType_symbol(eString);
  atomSite.setLabel_atom_id(a.getName());
  atomSite.setLabel_alt_id(altLocStr);
  atomSite.setLabel_comp_id(g.getPDBName());
  atomSite.setLabel_asym_id(internalChainId);
  atomSite.setLabel_entity_id(entityId);
  atomSite.setLabel_seq_id(labelSeqId);
  atomSite.setPdbx_PDB_ins_code(insCode);
  atomSite.setCartn_x(FileConvert.d3.format(a.getX()));
  atomSite.setCartn_y(FileConvert.d3.format(a.getY()));
  atomSite.setCartn_z(FileConvert.d3.format(a.getZ()));
  atomSite.setOccupancy(FileConvert.d2.format(a.getOccupancy()));
  atomSite.setB_iso_or_equiv(FileConvert.d2.format(a.getTempFactor()));
  atomSite.setAuth_seq_id(Integer.toString(g.getResidueNumber().getSeqNum()));
  atomSite.setAuth_comp_id(g.getPDBName());
  atomSite.setAuth_asym_id(chainId);
  atomSite.setAuth_atom_id(a.getName());
  atomSite.setPdbx_PDB_model_num(Integer.toString(model));
  return atomSite;
}

Fixed version (ground truth):
/** 
 * Converts an Atom object to an   {@link AtomSite} object.
 * @param a
 * @param model
 * @param chainId
 * @param internalChainId
 * @param atomId the atom id to be written to AtomSite
 * @return
 */
public static AtomSite convertAtomToAtomSite(Atom a,int model,String chainId,String internalChainId,int atomId){
  Group g=a.getGroup();
  String record;
  if (g.getType().equals(GroupType.HETATM)) {
    record="String_Node_Str";
  }
 else {
    record="String_Node_Str";
  }
  String entityId="String_Node_Str";
  String labelSeqId=Integer.toString(g.getResidueNumber().getSeqNum());
  if (g.getChain() != null && g.getChain().getCompound() != null) {
    entityId=Integer.toString(g.getChain().getCompound().getMolId());
    labelSeqId=Integer.toString(g.getChain().getCompound().getAlignedResIndex(g,g.getChain()));
  }
  Character altLoc=a.getAltLoc();
  String altLocStr=altLoc.toString();
  if (altLoc == null || altLoc == ' ') {
    altLocStr=MMCIF_DEFAULT_VALUE;
  }
  Element e=a.getElement();
  String eString=e.toString().toUpperCase();
  if (e.equals(Element.R)) {
    eString="String_Node_Str";
  }
  String insCode=MMCIF_MISSING_VALUE;
  if (g.getResidueNumber().getInsCode() != null) {
    insCode=Character.toString(g.getResidueNumber().getInsCode());
  }
  AtomSite atomSite=new AtomSite();
  atomSite.setGroup_PDB(record);
  atomSite.setId(Integer.toString(atomId));
  atomSite.setType_symbol(eString);
  atomSite.setLabel_atom_id(a.getName());
  atomSite.setLabel_alt_id(altLocStr);
  atomSite.setLabel_comp_id(g.getPDBName());
  atomSite.setLabel_asym_id(internalChainId);
  atomSite.setLabel_entity_id(entityId);
  atomSite.setLabel_seq_id(labelSeqId);
  atomSite.setPdbx_PDB_ins_code(insCode);
  atomSite.setCartn_x(FileConvert.d3.format(a.getX()));
  atomSite.setCartn_y(FileConvert.d3.format(a.getY()));
  atomSite.setCartn_z(FileConvert.d3.format(a.getZ()));
  atomSite.setOccupancy(FileConvert.d2.format(a.getOccupancy()));
  atomSite.setB_iso_or_equiv(FileConvert.d2.format(a.getTempFactor()));
  atomSite.setAuth_seq_id(Integer.toString(g.getResidueNumber().getSeqNum()));
  atomSite.setAuth_comp_id(g.getPDBName());
  atomSite.setAuth_asym_id(chainId);
  atomSite.setAuth_atom_id(a.getName());
  atomSite.setPdbx_PDB_model_num(Integer.toString(model));
  return atomSite;
}