X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAverageDistanceEngine.java;h=d81dd44687d286542f4576034ca76307efdd2e63;hb=b798682af83d8fb1d7c7f4b45388572899b31cac;hp=e6a763b62d2b97909c476ef6f6fb7218b911cf6d;hpb=43281ae2821768ea283161f12ab0eb91ea6bb3b5;p=jalview.git diff --git a/src/jalview/analysis/AverageDistanceEngine.java b/src/jalview/analysis/AverageDistanceEngine.java index e6a763b..d81dd44 100644 --- a/src/jalview/analysis/AverageDistanceEngine.java +++ b/src/jalview/analysis/AverageDistanceEngine.java @@ -44,29 +44,31 @@ public class AverageDistanceEngine extends TreeEngine AlignmentAnnotation aa; + // 0 - normalised dot product + // 1 - L1 - ie (abs(v_1-v_2)/dim(v)) + // L1 is more rational - since can reason about value of difference, + // normalised dot product might give cleaner clusters, but more difficult to + // understand. + + int mode = 1; + /** * compute cosine distance matrix for a given contact matrix and create a * UPGMA tree - * * @param cm + * @param cosineOrDifference false - dot product : true - L1 */ public AverageDistanceEngine(AlignmentViewport av, AlignmentAnnotation aa, - ContactMatrixI cm) + ContactMatrixI cm, boolean cosineOrDifference) { this.av = av; this.aa = aa; this.cm = cm; + mode = (cosineOrDifference) ? 1 :0; calculate(cm); } - // 0 - normalised dot product - // 1 - L1 - ie (abs(v_1-v_2)/dim(v)) - // L1 is more rational - since can reason about value of difference, - // normalised dot product might give cleaner clusters, but more difficult to - // understand. - - int mode = 1; public void calculate(ContactMatrixI cm) { @@ -100,11 +102,18 @@ public class AverageDistanceEngine extends TreeEngine // compute distance matrix element ContactListI ith = cm.getContactList(i); - + distances.setValue(i, i, 0); + if (ith==null) + { + continue; + } for (int j = 0; j < i; j++) { - distances.setValue(i, i, 0); ContactListI jth = cm.getContactList(j); + if (jth == null) + { + break; + } double prd = 0; for (int indx = 0; indx < cm.getHeight(); indx++) {