X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAverageDistanceTree.java;h=760962e988682adecbcbbfbbb5a03e9f94cf2723;hb=d0aee5b0b2cbd0805c3dec027c6f2d2ac0148e66;hp=5b0e20aad9a4658213845a5bb43be3d4d238f54e;hpb=a547c517480867ed1bbb2334ee7c51e642588a41;p=jalview.git diff --git a/src/jalview/analysis/AverageDistanceTree.java b/src/jalview/analysis/AverageDistanceTree.java index 5b0e20a..760962e 100644 --- a/src/jalview/analysis/AverageDistanceTree.java +++ b/src/jalview/analysis/AverageDistanceTree.java @@ -1,10 +1,34 @@ +/* + * 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 . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.analysis; import jalview.api.analysis.ScoreModelI; import jalview.api.analysis.SimilarityParamsI; -import jalview.datamodel.SequenceNode; +import jalview.datamodel.BinaryNode; 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 { @@ -59,10 +83,7 @@ public class AverageDistanceTree extends TreeBuilder } /** - * 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() @@ -89,39 +110,32 @@ public class AverageDistanceTree 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, + protected void findNewDistances(BinaryNode nodei, BinaryNode nodej, double dist) { double ih = 0; double jh = 0; - SequenceNode sni = tmpi; - SequenceNode snj = tmpj; + BinaryNode sni = nodei; + BinaryNode snj = nodej; while (sni != null) { ih = ih + sni.dist; - sni = (SequenceNode) sni.left(); + sni = (BinaryNode) sni.left(); } while (snj != null) { jh = jh + snj.dist; - snj = (SequenceNode) snj.left(); + snj = (BinaryNode) snj.left(); } - tmpi.dist = ((dist / 2) - ih); - tmpj.dist = ((dist / 2) - jh); + nodei.dist = ((dist / 2) - ih); + nodej.dist = ((dist / 2) - jh); } }