Program: 16904
Project: 16904
Buggy source:
/** 
 * a simple matching approach that tries to do a 1:1 mapping between SEQRES and ATOM records returns true if this simple matching approach worked fine
 * @param seqRes
 * @param atomList
 * @return
 */
private List<Group> trySimpleMatch(List<Group> seqResGroups,List<Group> atmResGroups){
  @SuppressWarnings("String_Node_Str") List<Group> newSeqResGroups=(ArrayList<Group>)((ArrayList<Group>)seqResGroups).clone();
  boolean startAt1=true;
  for (int atomResPos=0; atomResPos < atmResGroups.size(); atomResPos++) {
    Group atomResGroup=atmResGroups.get(atomResPos);
    String threeLetterCode=atomResGroup.getPDBName();
    if (excludeTypes.contains(threeLetterCode)) {
      continue;
    }
    ResidueNumber atomResNum=atomResGroup.getResidueNumber();
    int seqResPos=atomResNum.getSeqNum();
    if (seqResPos < 0) {
      logger.debug("String_Node_Str",seqResPos);
      return null;
    }
    if (seqResPos == 0) {
      Group seqResGroup=seqResGroups.get(0);
      if (seqResGroup.getPDBName().equals(atomResGroup.getPDBName())) {
        startAt1=false;
      }
 else {
        logger.debug("String_Node_Str",seqResGroup.getPDBName(),atomResGroup.getPDBName());
        return null;
      }
    }
    if (startAt1)     seqResPos--;
    if (startAt1 && seqResPos >= seqResGroups.size()) {
      if (atomResGroup instanceof AminoAcid) {
        logger.debug("String_Node_Str" + seqResPos + "String_Node_Str"+ seqResGroups.size()+ "String_Node_Str"+ atomResGroup);
        return null;
      }
 else       if (atomResGroup instanceof NucleotideImpl) {
        logger.debug("String_Node_Str" + seqResPos + "String_Node_Str"+ seqResGroups.size()+ "String_Node_Str"+ atomResGroup);
        return null;
      }
 else {
        continue;
      }
    }
    if (seqResPos >= seqResGroups.size()) {
      logger.debug("String_Node_Str" + seqResPos);
      if (atomResGroup instanceof AminoAcid)       return null;
 else       continue;
    }
    Group seqResGroup=seqResGroups.get(seqResPos);
    if (!seqResGroup.getPDBName().trim().equals(atomResGroup.getPDBName().trim())) {
      logger.debug("String_Node_Str" + seqResPos + "String_Node_Str"+ atomResGroup+ "String_Node_Str"+ seqResGroup);
      return null;
    }
    logger.trace("String_Node_Str",seqResPos,atomResGroup);
    newSeqResGroups.set(seqResPos,atomResGroup);
  }
  return newSeqResGroups;
}

Fixed version (ground truth):
/** 
 * A simple matching approach that tries to do a 1:1 mapping between SEQRES and ATOM records
 * @param seqRes
 * @param atomList
 * @return the matching or null if the matching didn't work
 */
private List<Group> trySimpleMatch(List<Group> seqResGroups,List<Group> atmResGroups){
  @SuppressWarnings("String_Node_Str") List<Group> newSeqResGroups=(ArrayList<Group>)((ArrayList<Group>)seqResGroups).clone();
  boolean startAt1=true;
  for (int atomResPos=0; atomResPos < atmResGroups.size(); atomResPos++) {
    Group atomResGroup=atmResGroups.get(atomResPos);
    String threeLetterCode=atomResGroup.getPDBName();
    if (excludeTypes.contains(threeLetterCode)) {
      continue;
    }
    ResidueNumber atomResNum=atomResGroup.getResidueNumber();
    int seqResPos=atomResNum.getSeqNum();
    if (seqResPos < 0) {
      logger.debug("String_Node_Str",seqResPos);
      return null;
    }
    if (seqResPos == 0) {
      Group seqResGroup=seqResGroups.get(0);
      if (seqResGroup.getPDBName().equals(atomResGroup.getPDBName())) {
        startAt1=false;
      }
 else {
        logger.debug("String_Node_Str",seqResGroup.getPDBName(),atomResGroup.getPDBName());
        return null;
      }
    }
    if (startAt1)     seqResPos--;
    if (startAt1 && seqResPos >= seqResGroups.size()) {
      if (atomResGroup instanceof AminoAcid) {
        logger.debug("String_Node_Str" + seqResPos + "String_Node_Str"+ seqResGroups.size()+ "String_Node_Str"+ atomResGroup);
        return null;
      }
 else       if (atomResGroup instanceof NucleotideImpl) {
        logger.debug("String_Node_Str" + seqResPos + "String_Node_Str"+ seqResGroups.size()+ "String_Node_Str"+ atomResGroup);
        return null;
      }
 else {
        continue;
      }
    }
    if (seqResPos >= seqResGroups.size()) {
      logger.debug("String_Node_Str" + seqResPos);
      if (atomResGroup instanceof AminoAcid)       return null;
 else       continue;
    }
    Group seqResGroup=seqResGroups.get(seqResPos);
    if (!seqResGroup.getPDBName().trim().equals(atomResGroup.getPDBName().trim())) {
      logger.debug("String_Node_Str" + seqResPos + "String_Node_Str"+ atomResGroup+ "String_Node_Str"+ seqResGroup);
      return null;
    }
    Group replacedGroup=newSeqResGroups.set(seqResPos,atomResGroup);
    logger.debug("String_Node_Str",seqResPos,replacedGroup.getResidueNumber(),replacedGroup.getPDBName(),atomResGroup.getResidueNumber(),atomResGroup.getPDBName());
  }
  return newSeqResGroups;
}