Program: 16906
Project: 16906
Buggy source:
public TreeMap<String,Entity> findEntities(){
  TreeMap<String,Entity> chainIds2entities=new TreeMap<String,Entity>();
  List<String> chainIds=new ArrayList<String>();
  for (  Chain c : s.getChains()) {
    chainIds.add(c.getChainID());
  }
  Collections.sort(chainIds);
  try {
    outer:     for (int i=0; i < chainIds.size(); i++) {
      for (int j=i + 1; j < chainIds.size(); j++) {
        Chain c1=null;
        Chain c2=null;
        try {
          c1=s.getChainByPDB(chainIds.get(i));
          c2=s.getChainByPDB(chainIds.get(j));
        }
 catch (        StructureException e) {
          logger.error("String_Node_Str",e);
        }
        ProteinSequence s1=new ProteinSequence(c1.getAtomSequence());
        ProteinSequence s2=new ProteinSequence(c2.getAtomSequence());
        SequencePair<ProteinSequence,AminoAcidCompound> pair=align(s1,s2);
        int nonGaps=pair.getLength() - getNumGaps(pair);
        double identity=(double)pair.getNumIdenticals() / (double)nonGaps;
        logger.debug("String_Node_Str",c1.getChainID(),c2.getChainID(),identity);
        if (identity > 0.99999) {
          if (!chainIds2entities.containsKey(c1.getChainID()) && !chainIds2entities.containsKey(c2.getChainID())) {
            logger.debug("String_Node_Str",c1.getChainID(),c2.getChainID());
            if (areResNumbersAligned(c1,c2)) {
              Entity ent=new Entity();
              ent.addMember(c1);
              ent.setRepresentative(c1);
              ent.addMember(c2);
              chainIds2entities.put(c1.getChainID(),ent);
              chainIds2entities.put(c2.getChainID(),ent);
            }
 else {
              logger.warn("String_Node_Str");
            }
          }
 else {
            Entity ent=chainIds2entities.get(c1.getChainID());
            if (ent == null) {
              logger.debug("String_Node_Str",c1.getChainID(),c2.getChainID());
              ent=chainIds2entities.get(c2.getChainID());
              if (areResNumbersAligned(c1,c2)) {
                ent.addMember(c1);
                chainIds2entities.put(c1.getChainID(),ent);
              }
 else {
                logger.warn("String_Node_Str");
              }
            }
 else {
              logger.debug("String_Node_Str",c2.getChainID(),c1.getChainID());
              if (areResNumbersAligned(c1,c2)) {
                ent.addMember(c2);
                chainIds2entities.put(c2.getChainID(),ent);
              }
 else {
                logger.warn("String_Node_Str");
              }
            }
          }
        }
 else         if (identity > 0.95) {
          logger.info("String_Node_Str",c1.getChainID(),c2.getChainID(),nonGaps - pair.getNumIdenticals(),nonGaps,identity);
          logger.info("String_Node_Str" + pair.toString(100));
        }
 else         if (identity > 1) {
          logger.warn("String_Node_Str",c1.getChainID(),c2.getChainID(),pair.getNumIdenticals(),nonGaps,identity);
          logger.warn("String_Node_Str" + pair.toString(100));
        }
        if (chainIds2entities.size() == s.getChains().size())         break outer;
      }
    }
    for (    Chain c : s.getChains()) {
      if (!chainIds2entities.containsKey(c.getChainID())) {
        logger.debug("String_Node_Str" + c.getChainID());
        chainIds2entities.put(c.getChainID(),getTrivialEntity(c));
      }
    }
  }
 catch (  CompoundNotFoundException e) {
    logger.warn("String_Node_Str" + e.getMessage());
    return getTrivialEntities();
  }
  return chainIds2entities;
}

Fixed version (ground truth):
public TreeMap<String,Entity> findEntities(){
  TreeMap<String,Entity> chainIds2entities=new TreeMap<String,Entity>();
  List<String> chainIds=new ArrayList<String>();
  for (  Chain c : s.getChains()) {
    if (c.getAtomGroups(GroupType.AMINOACID).size() > 1 && c.getAtomGroups(GroupType.NUCLEOTIDE).size() < 1) {
      chainIds.add(c.getChainID());
    }
  }
  Collections.sort(chainIds);
  try {
    outer:     for (int i=0; i < chainIds.size(); i++) {
      for (int j=i + 1; j < chainIds.size(); j++) {
        Chain c1=null;
        Chain c2=null;
        try {
          c1=s.getChainByPDB(chainIds.get(i));
          c2=s.getChainByPDB(chainIds.get(j));
        }
 catch (        StructureException e) {
          logger.error("String_Node_Str",e);
        }
        ProteinSequence s1=new ProteinSequence(c1.getAtomSequence());
        ProteinSequence s2=new ProteinSequence(c2.getAtomSequence());
        SequencePair<ProteinSequence,AminoAcidCompound> pair=align(s1,s2);
        int nonGaps=pair.getLength() - getNumGaps(pair);
        double identity=(double)pair.getNumIdenticals() / (double)nonGaps;
        logger.debug("String_Node_Str",c1.getChainID(),c2.getChainID(),identity);
        if (identity > 0.99999) {
          if (!chainIds2entities.containsKey(c1.getChainID()) && !chainIds2entities.containsKey(c2.getChainID())) {
            logger.debug("String_Node_Str",c1.getChainID(),c2.getChainID());
            if (areResNumbersAligned(c1,c2)) {
              Entity ent=new Entity();
              ent.addMember(c1);
              ent.setRepresentative(c1);
              ent.addMember(c2);
              chainIds2entities.put(c1.getChainID(),ent);
              chainIds2entities.put(c2.getChainID(),ent);
            }
 else {
              logger.warn("String_Node_Str");
            }
          }
 else {
            Entity ent=chainIds2entities.get(c1.getChainID());
            if (ent == null) {
              logger.debug("String_Node_Str",c1.getChainID(),c2.getChainID());
              ent=chainIds2entities.get(c2.getChainID());
              if (areResNumbersAligned(c1,c2)) {
                ent.addMember(c1);
                chainIds2entities.put(c1.getChainID(),ent);
              }
 else {
                logger.warn("String_Node_Str");
              }
            }
 else {
              logger.debug("String_Node_Str",c2.getChainID(),c1.getChainID());
              if (areResNumbersAligned(c1,c2)) {
                ent.addMember(c2);
                chainIds2entities.put(c2.getChainID(),ent);
              }
 else {
                logger.warn("String_Node_Str");
              }
            }
          }
        }
 else         if (identity > 0.95) {
          logger.info("String_Node_Str",c1.getChainID(),c2.getChainID(),nonGaps - pair.getNumIdenticals(),nonGaps,identity);
          logger.info("String_Node_Str" + pair.toString(100));
        }
 else         if (identity > 1) {
          logger.warn("String_Node_Str",c1.getChainID(),c2.getChainID(),pair.getNumIdenticals(),nonGaps,identity);
          logger.warn("String_Node_Str" + pair.toString(100));
        }
        if (chainIds2entities.size() == chainIds.size())         break outer;
      }
    }
    for (    Chain c : s.getChains()) {
      if (!chainIds2entities.containsKey(c.getChainID())) {
        logger.debug("String_Node_Str" + c.getChainID());
        chainIds2entities.put(c.getChainID(),getTrivialEntity(c));
      }
    }
  }
 catch (  CompoundNotFoundException e) {
    logger.warn("String_Node_Str" + e.getMessage());
    return getTrivialEntities();
  }
  return chainIds2entities;
}