JAL-2418 add GPL to main sources
[jalview.git] / src / jalview / analysis / AverageDistanceTree.java
index 7e3cfe1..c726627 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
 package jalview.analysis;
 
 import jalview.api.analysis.ScoreModelI;
@@ -5,6 +25,10 @@ import jalview.api.analysis.SimilarityParamsI;
 import jalview.datamodel.SequenceNode;
 import jalview.viewmodel.AlignmentViewport;
 
+/**
+ * This class implements distance calculations used in constructing a Average
+ * Distance tree (also known as UPGMA)
+ */
 public class AverageDistanceTree extends TreeBuilder
 {
   /**
@@ -42,8 +66,8 @@ public class AverageDistanceTree extends TreeBuilder
     {
       if ((l != i) && (l != j))
       {
-        newdist[l] = ((distances.getValue(i, l) * noi) + (distances
-                .getValue(j, l) * noj)) / (noi + noj);
+        newdist[l] = ((distances.getValue(i, l) * noi)
+                + (distances.getValue(j, l) * noj)) / (noi + noj);
       }
       else
       {
@@ -55,17 +79,11 @@ public class AverageDistanceTree extends TreeBuilder
     {
       distances.setValue(i, ii, newdist[ii]);
       distances.setValue(ii, i, newdist[ii]);
-      System.out.println(String.format(
-              "findClusterDistance(%d, %d) newdist to %d is %f", i, j, ii,
-              newdist[ii]));
     }
   }
 
   /**
-   * Returns the minimum distance between two clusters, and also sets the
-   * indices of the clusters in fields mini and minj
-   * 
-   * @return DOCUMENT ME!
+   * {@inheritDoc}
    */
   @Override
   protected double findMinDistance()
@@ -88,30 +106,21 @@ public class AverageDistanceTree extends TreeBuilder
         }
       }
     }
-    System.out.println("findMinDistance found " + min + " at " + mini + ","
-            + minj);
     return min;
   }
 
   /**
-   * DOCUMENT ME!
-   * 
-   * @param tmpi
-   *          DOCUMENT ME!
-   * @param tmpj
-   *          DOCUMENT ME!
-   * @param dist
-   *          DOCUMENT ME!
+   * {@inheritDoc}
    */
   @Override
-  protected void findNewDistances(SequenceNode tmpi, SequenceNode tmpj,
+  protected void findNewDistances(SequenceNode nodei, SequenceNode nodej,
           double dist)
   {
     double ih = 0;
     double jh = 0;
 
-    SequenceNode sni = tmpi;
-    SequenceNode snj = tmpj;
+    SequenceNode sni = nodei;
+    SequenceNode snj = nodej;
 
     while (sni != null)
     {
@@ -125,10 +134,8 @@ public class AverageDistanceTree extends TreeBuilder
       snj = (SequenceNode) snj.left();
     }
 
-    tmpi.dist = ((dist / 2) - ih);
-    tmpj.dist = ((dist / 2) - jh);
-    System.out.println("findNewDistances set tmpi to " + tmpi.dist
-            + ", tmpj to " + tmpj.dist);
+    nodei.dist = ((dist / 2) - ih);
+    nodej.dist = ((dist / 2) - jh);
   }
 
 }