JAL-3490 match count independent of contiguous matches count
[jalview.git] / src / jalview / analysis / NJTree.java
index 82e0284..522c2b1 100644 (file)
@@ -26,10 +26,8 @@ import jalview.datamodel.SequenceNode;
 import jalview.viewmodel.AlignmentViewport;
 
 /**
- * DOCUMENT ME!
- * 
- * @author $author$
- * @version $Revision$
+ * This class implements distance calculations used in constructing a Neighbour
+ * Joining tree
  */
 public class NJTree extends TreeBuilder
 {
@@ -47,16 +45,12 @@ public class NJTree extends TreeBuilder
   {
     super(av, sm, scoreParameters);
   }
-  // private long _lycount = 0, _lylimit = 0;
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @return DOCUMENT ME!
+   * {@inheritDoc}
    */
   @Override
-  protected
-  double findMinDistance()
+  protected double findMinDistance()
   {
     double min = Double.MAX_VALUE;
 
@@ -84,36 +78,26 @@ public class NJTree extends TreeBuilder
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param tmpi
-   *          DOCUMENT ME!
-   * @param tmpj
-   *          DOCUMENT ME!
-   * @param dist
-   *          DOCUMENT ME!
+   * {@inheritDoc}
    */
   @Override
-  protected
-  void findNewDistances(SequenceNode tmpi, SequenceNode tmpj, double dist)
+  protected void findNewDistances(SequenceNode nodei, SequenceNode nodej,
+          double dist)
   {
+    nodei.dist = ((dist + ri) - rj) / 2;
+    nodej.dist = (dist - nodei.dist);
 
-    tmpi.dist = ((dist + ri) - rj) / 2;
-    tmpj.dist = (dist - tmpi.dist);
-
-    if (tmpi.dist < 0)
+    if (nodei.dist < 0)
     {
-      tmpi.dist = 0;
+      nodei.dist = 0;
     }
 
-    if (tmpj.dist < 0)
+    if (nodej.dist < 0)
     {
-      tmpj.dist = 0;
+      nodej.dist = 0;
     }
   }
 
-
-
   /**
    * Calculates and saves the distance between the combination of cluster(i) and
    * cluster(j) and all other clusters. The new distance to cluster k is
@@ -124,25 +108,25 @@ public class NJTree extends TreeBuilder
    * @param j
    */
   @Override
-  protected
-  void findClusterDistance(int i, int j)
+  protected void findClusterDistance(int i, int j)
   {
     // New distances from cluster i to others
     double[] newdist = new double[noseqs];
-  
+
     double ijDistance = distances.getValue(i, j);
     for (int l = 0; l < noseqs; l++)
     {
       if ((l != i) && (l != j))
       {
-        newdist[l] = (distances.getValue(i, l) + distances.getValue(j, l) - ijDistance) / 2;
+        newdist[l] = (distances.getValue(i, l) + distances.getValue(j, l)
+                - ijDistance) / 2;
       }
       else
       {
         newdist[l] = 0;
       }
     }
-  
+
     for (int ii = 0; ii < noseqs; ii++)
     {
       distances.setValue(i, ii, newdist[ii]);