+/*
+ * 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;
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
{
/**
{
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
{
{
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()
}
}
}
- 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)
{
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);
}
}