X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAverageDistanceEngine.java;h=286d589c45617c630a334a479edcb7e6b99f008d;hb=a73dbb370e06bfaae2caf3487fde655d9b177045;hp=20b3e83678cd53c1f82a05a806279037556d5aa6;hpb=80b889f0cca49103e1b20ed806755a0719789906;p=jalview.git diff --git a/src/jalview/analysis/AverageDistanceEngine.java b/src/jalview/analysis/AverageDistanceEngine.java index 20b3e83..286d589 100644 --- a/src/jalview/analysis/AverageDistanceEngine.java +++ b/src/jalview/analysis/AverageDistanceEngine.java @@ -44,30 +44,33 @@ 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) { this.cm = cm; @@ -100,10 +103,13 @@ 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) {