Program: 16807
Project: 16807
Buggy source:
/** 
 * Calculates the contact overlap score between this StructureInterface and the given one.  The two sides of the given StructureInterface need to match this StructureInterface in the sense that they must come from the same Compound (Entity), i.e. their residue numbers need to align with 100% identity, except for unobserved  density residues.
 * @param other
 * @param invert if false the comparison will be done first-to-first and second-to-second, if true the match will be first-to-second and second-to-first
 * @return the contact overlap score, range [0.0,1.0]
 */
public double getContactOverlapScore(StructureInterface other,boolean invert){
  Structure thisStruct=getParentStructure();
  Structure otherStruct=other.getParentStructure();
  if (thisStruct != otherStruct) {
    logger.warn("String_Node_Str");
    return 0;
  }
  Pair<Chain> thisChains=getParentChains();
  Pair<Chain> otherChains=other.getParentChains();
  Pair<Compound> thisCompounds=new Pair<Compound>(thisChains.getFirst().getCompound(),thisChains.getSecond().getCompound());
  Pair<Compound> otherCompounds=new Pair<Compound>(otherChains.getFirst().getCompound(),otherChains.getSecond().getCompound());
  if (((thisCompounds.getFirst() == otherCompounds.getFirst()) && (thisCompounds.getSecond() == otherCompounds.getSecond())) || ((thisCompounds.getFirst() == otherCompounds.getSecond()) && (thisCompounds.getSecond() == otherCompounds.getFirst()))) {
    int common=0;
    GroupContactSet thisContacts=getGroupContacts();
    GroupContactSet otherContacts=other.getGroupContacts();
    for (    GroupContact thisContact : thisContacts) {
      ResidueIdentifier first=null;
      ResidueIdentifier second=null;
      if (!invert) {
        first=new ResidueIdentifier(thisContact.getPair().getFirst().getResidueNumber().getSeqNum(),thisContact.getPair().getFirst().getResidueNumber().getInsCode());
        second=new ResidueIdentifier(thisContact.getPair().getSecond().getResidueNumber().getSeqNum(),thisContact.getPair().getSecond().getResidueNumber().getInsCode());
      }
 else {
        first=new ResidueIdentifier(thisContact.getPair().getSecond().getResidueNumber().getSeqNum(),thisContact.getPair().getSecond().getResidueNumber().getInsCode());
        second=new ResidueIdentifier(thisContact.getPair().getFirst().getResidueNumber().getSeqNum(),thisContact.getPair().getFirst().getResidueNumber().getInsCode());
      }
      if (otherContacts.hasContact(first,second)) {
        common++;
      }
    }
    return (2.0 * common) / (thisContacts.size() + otherContacts.size());
  }
 else {
    logger.debug("String_Node_Str",thisChains.getFirst().getChainID(),thisChains.getSecond().getChainID(),otherChains.getFirst().getChainID(),otherChains.getSecond().getChainID());
    return 0.0;
  }
}

Fixed version (ground truth):
/** 
 * Calculates the contact overlap score between this StructureInterface and the given one.  The two sides of the given StructureInterface need to match this StructureInterface in the sense that they must come from the same Compound (Entity), i.e. their residue numbers need to align with 100% identity, except for unobserved  density residues.
 * @param other
 * @param invert if false the comparison will be done first-to-first and second-to-second, if true the match will be first-to-second and second-to-first
 * @return the contact overlap score, range [0.0,1.0]
 */
public double getContactOverlapScore(StructureInterface other,boolean invert){
  Structure thisStruct=getParentStructure();
  Structure otherStruct=other.getParentStructure();
  if (thisStruct != otherStruct) {
    logger.warn("String_Node_Str");
    return 0;
  }
  Pair<Chain> thisChains=getParentChains();
  Pair<Chain> otherChains=other.getParentChains();
  if (thisChains.getFirst().getCompound() == null || thisChains.getSecond().getCompound() == null || otherChains.getFirst().getCompound() == null || otherChains.getSecond().getCompound() == null) {
    logger.warn("String_Node_Str",this.getId(),other.getId());
    return 0;
  }
  Pair<Compound> thisCompounds=new Pair<Compound>(thisChains.getFirst().getCompound(),thisChains.getSecond().getCompound());
  Pair<Compound> otherCompounds=new Pair<Compound>(otherChains.getFirst().getCompound(),otherChains.getSecond().getCompound());
  if (((thisCompounds.getFirst() == otherCompounds.getFirst()) && (thisCompounds.getSecond() == otherCompounds.getSecond())) || ((thisCompounds.getFirst() == otherCompounds.getSecond()) && (thisCompounds.getSecond() == otherCompounds.getFirst()))) {
    int common=0;
    GroupContactSet thisContacts=getGroupContacts();
    GroupContactSet otherContacts=other.getGroupContacts();
    for (    GroupContact thisContact : thisContacts) {
      ResidueIdentifier first=null;
      ResidueIdentifier second=null;
      if (!invert) {
        first=new ResidueIdentifier(thisContact.getPair().getFirst().getResidueNumber().getSeqNum(),thisContact.getPair().getFirst().getResidueNumber().getInsCode());
        second=new ResidueIdentifier(thisContact.getPair().getSecond().getResidueNumber().getSeqNum(),thisContact.getPair().getSecond().getResidueNumber().getInsCode());
      }
 else {
        first=new ResidueIdentifier(thisContact.getPair().getSecond().getResidueNumber().getSeqNum(),thisContact.getPair().getSecond().getResidueNumber().getInsCode());
        second=new ResidueIdentifier(thisContact.getPair().getFirst().getResidueNumber().getSeqNum(),thisContact.getPair().getFirst().getResidueNumber().getInsCode());
      }
      if (otherContacts.hasContact(first,second)) {
        common++;
      }
    }
    return (2.0 * common) / (thisContacts.size() + otherContacts.size());
  }
 else {
    logger.debug("String_Node_Str",thisChains.getFirst().getChainID(),thisChains.getSecond().getChainID(),otherChains.getFirst().getChainID(),otherChains.getSecond().getChainID());
    return 0.0;
  }
}