Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 599e7ae

Browse files
committed
Docs and minor changes
1 parent 98eff70 commit 599e7ae

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ public StructureInterface(
113113
this.moleculeIds = new Pair<>(firstMoleculeId,secondMoleculeId);
114114
this.contacts = contacts;
115115
this.transforms = new Pair<>(firstTransf, secondTransf);
116+
117+
this.groupAsas1 = new TreeMap<>();
118+
this.groupAsas2 = new TreeMap<>();
116119
}
117120

118121
/**
@@ -290,12 +293,8 @@ protected Atom[] getAtomsForAsa(int cofactorSizeToUse) {
290293
Atom[] atoms2 = getSecondAtomsForAsa(cofactorSizeToUse);
291294

292295
Atom[] atoms = new Atom[atoms1.length+atoms2.length];
293-
for (int i=0;i<atoms1.length;i++) {
294-
atoms[i] = atoms1[i];
295-
}
296-
for (int i=0;i<atoms2.length;i++) {
297-
atoms[i+atoms1.length] = atoms2[i];
298-
}
296+
System.arraycopy(atoms1, 0, atoms, 0, atoms1.length);
297+
System.arraycopy(atoms2, 0, atoms, atoms1.length, atoms2.length);
299298

300299
return atoms;
301300
}
@@ -326,7 +325,7 @@ private static Atom[] getAllNonHAtomArray(Atom[] m, int minSizeHetAtomToInclude)
326325
atoms.add(a);
327326

328327
}
329-
return atoms.toArray(new Atom[atoms.size()]);
328+
return atoms.toArray(new Atom[0]);
330329
}
331330

332331
/**
@@ -425,11 +424,11 @@ public void setFirstGroupAsa(GroupAsa groupAsa) {
425424
groupAsas1.put(groupAsa.getGroup().getResidueNumber(), groupAsa);
426425
}
427426

428-
void setFirstGroupAsas(Map<ResidueNumber, GroupAsa> firstGroupAsas) {
427+
public void setFirstGroupAsas(Map<ResidueNumber, GroupAsa> firstGroupAsas) {
429428
this.groupAsas1 = firstGroupAsas;
430429
}
431430

432-
void setSecondGroupAsas(Map<ResidueNumber, GroupAsa> secondGroupAsas) {
431+
public void setSecondGroupAsas(Map<ResidueNumber, GroupAsa> secondGroupAsas) {
433432
this.groupAsas2 = secondGroupAsas;
434433
}
435434

@@ -587,8 +586,8 @@ public void setCluster(StructureInterfaceCluster cluster) {
587586
}
588587

589588
/**
590-
* Calculates the contact overlap score between this StructureInterface and
591-
* the given one. The calculation assumes that both interfaces come from the same structure. The ouput
589+
* Calculates the Jaccard contact set score (intersection over union) between this StructureInterface and
590+
* the given one. The calculation assumes that both interfaces come from the same structure. The output
592591
* will not necessarily make sense if the two interfaces come from different structures.
593592
* The two sides of the given StructureInterface need to match this StructureInterface
594593
* in the sense that they must come from the same Entity, i.e.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public List<StructureInterfaceCluster> getClusters() {
365365

366366
/**
367367
* Calculate the interface clusters for this StructureInterfaceList
368-
* using a contact overlap score to measure the similarity of interfaces.
368+
* using Jaccard contact set scores to measure the similarity of interfaces.
369369
* Subsequent calls will use the cached value without recomputing the clusters.
370370
* The clusters will be assigned ids by sorting descending by {@link StructureInterfaceCluster#getTotalArea()}
371371
* @param contactOverlapScoreClusterCutoff the contact overlap score above which a pair will be
@@ -382,6 +382,7 @@ public List<StructureInterfaceCluster> getClusters(double contactOverlapScoreClu
382382
// nothing to do if we have no interfaces
383383
if (list.size()==0) return clusters;
384384

385+
logger.debug("Calculating all-vs-all Jaccard scores for {} interfaces", list.size());
385386
double[][] matrix = new double[list.size()][list.size()];
386387

387388
for (int i=0;i<list.size();i++) {
@@ -399,6 +400,7 @@ public List<StructureInterfaceCluster> getClusters(double contactOverlapScoreClu
399400

400401
}
401402

403+
logger.debug("Will now cluster {} interfaces based on full all-vs-all Jaccard scores matrix", list.size());
402404
SingleLinkageClusterer slc = new SingleLinkageClusterer(matrix, true);
403405

404406
Map<Integer, Set<Integer>> clusteredIndices = slc.getClusters(contactOverlapScoreClusterCutoff);
@@ -434,11 +436,11 @@ public List<StructureInterfaceCluster> getClusters(double contactOverlapScoreClu
434436
interf.setCluster(cluster);
435437
}
436438
}
439+
logger.debug("Done clustering {} interfaces based on full all-vs-all Jaccard scores matrix. Found a total of {} clusters", list.size(), clusters.size());
437440

438441
// now we sort by areas (descending) and assign ids based on that sorting
439-
clusters.sort((o1, o2) -> {
440-
return Double.compare(o2.getTotalArea(), o1.getTotalArea()); //note we invert so that sorting is descending
441-
});
442+
clusters.sort((o1, o2) -> Double.compare(o2.getTotalArea(), o1.getTotalArea())); //note we invert so that sorting is descending
443+
442444
int id = 1;
443445
for (StructureInterfaceCluster cluster:clusters) {
444446
cluster.setId(id);

0 commit comments

Comments
 (0)