JAL-4386_Added changes in similarity score calculation for different cases of sequenc...
[jalview.git] / src / jalview / analysis / AverageDistanceEngine.java
index f4d69d5..286d589 100644 (file)
@@ -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;
@@ -101,7 +104,7 @@ public class AverageDistanceEngine extends TreeEngine
       // compute distance matrix element
       ContactListI ith = cm.getContactList(i);
       distances.setValue(i, i, 0);
-      if (ith==null)
+      if (ith == null)
       {
         continue;
       }