Skip to content

Commit afd98d4

Browse files
committed
Now possible to compare interfaces coming from different copies of same structure
1 parent 66ca010 commit afd98d4

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,8 @@ public void setCluster(StructureInterfaceCluster cluster) {
583583

584584
/**
585585
* Calculates the contact overlap score between this StructureInterface and
586-
* the given one.
586+
* the given one. The calculation assumes that both interfaces come from the same structure. The ouput
587+
* will not necessarily make sense if the two interfaces come from different structures.
587588
* The two sides of the given StructureInterface need to match this StructureInterface
588589
* in the sense that they must come from the same Entity, i.e.
589590
* their residue numbers need to align with 100% identity, except for unobserved
@@ -597,17 +598,6 @@ public void setCluster(StructureInterfaceCluster cluster) {
597598
*/
598599
public double getContactOverlapScore(StructureInterface other, boolean invert) {
599600

600-
Structure thisStruct = getParentStructure();
601-
Structure otherStruct = other.getParentStructure();
602-
603-
if (thisStruct!=otherStruct) {
604-
// in the current implementation, comparison between different structure doesn't make much sense
605-
// and won't even work since the compounds of both will never match. We warn because it
606-
// really is not what this is intended for at the moment
607-
logger.warn("Comparing interfaces from different structures, contact overlap score will be 0");
608-
return 0;
609-
}
610-
611601
Pair<Chain> thisChains = getParentChains();
612602
Pair<Chain> otherChains = other.getParentChains();
613603

@@ -622,19 +612,19 @@ public double getContactOverlapScore(StructureInterface other, boolean invert) {
622612
Pair<EntityInfo> thisCompounds = new Pair<EntityInfo>(thisChains.getFirst().getEntityInfo(), thisChains.getSecond().getEntityInfo());
623613
Pair<EntityInfo> otherCompounds = new Pair<EntityInfo>(otherChains.getFirst().getEntityInfo(), otherChains.getSecond().getEntityInfo());
624614

625-
if ( ( (thisCompounds.getFirst() == otherCompounds.getFirst()) &&
626-
(thisCompounds.getSecond() == otherCompounds.getSecond()) ) ||
627-
( (thisCompounds.getFirst() == otherCompounds.getSecond()) &&
628-
(thisCompounds.getSecond() == otherCompounds.getFirst()) ) ) {
615+
if ( ( (thisCompounds.getFirst().getMolId() == otherCompounds.getFirst().getMolId()) &&
616+
(thisCompounds.getSecond().getMolId() == otherCompounds.getSecond().getMolId()) ) ||
617+
( (thisCompounds.getFirst().getMolId() == otherCompounds.getSecond().getMolId()) &&
618+
(thisCompounds.getSecond().getMolId() == otherCompounds.getFirst().getMolId()) ) ) {
629619

630620
int common = 0;
631621
GroupContactSet thisContacts = getGroupContacts();
632622
GroupContactSet otherContacts = other.getGroupContacts();
633623

634624
for (GroupContact thisContact:thisContacts) {
635625

636-
ResidueIdentifier first = null;
637-
ResidueIdentifier second = null;
626+
ResidueIdentifier first;
627+
ResidueIdentifier second;
638628

639629
if (!invert) {
640630
first = new ResidueIdentifier(thisContact.getPair().getFirst());

biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterfaceList.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class StructureInterfaceList implements Serializable, Iterable<StructureI
7474

7575
private static final long serialVersionUID = 1L;
7676

77-
private List<StructureInterface> list;
77+
private final List<StructureInterface> list;
7878

7979
private List<StructureInterfaceCluster> clusters = null;
8080
private List<StructureInterfaceCluster> clustersNcs = null;
@@ -93,6 +93,10 @@ public int size() {
9393
return this.list.size();
9494
}
9595

96+
public List<StructureInterface> getList() {
97+
return list;
98+
}
99+
96100
/**
97101
* Gets the interface corresponding to given id.
98102
* The ids go from 1 to n

0 commit comments

Comments
 (0)