jebl.evolution.trees
Class ClusteringTreeBuilder<T extends Tree>

java.lang.Object
  extended by jebl.evolution.trees.ClusteringTreeBuilder<T>
All Implemented Interfaces:
TreeBuilder<T>
Direct Known Subclasses:
NeighborJoiningTreeBuilder

public abstract class ClusteringTreeBuilder<T extends Tree>
extends Object
implements TreeBuilder<T>

An abstract base class for clustering algorithms from pairwise distances

Author:
Andrew Rambaut, Alexei Drummond, Joseph Heled Adapted from Alexei Drummond BEAST code.

Field Summary
protected  int[] alias
           
protected  int besti
           
protected  int bestj
           
protected  Node[] clusters
           
protected  double[][] distance
           
protected  DistanceMatrix distanceMatrix
           
protected  int minimumTaxa
           
protected  Node newCluster
           
protected  int numClusters
           
protected  int[] tipCount
           
 
Constructor Summary
protected ClusteringTreeBuilder(DistanceMatrix distanceMatrix, int minimumTaxa)
          Constructor
 
Method Summary
 void addProgressListener(ProgressListener listener)
           
 T build()
           
protected abstract  Node createExternalNode(Taxon taxon)
           
protected abstract  Node createInternalNode(Node[] nodes, double[] distances)
           
protected  void findNextPair()
          Find next two clusters to join.
protected  void finish()
           
 void fireSetProgress(double fractionCompleted)
           
static ClusteringTreeBuilder getBuilder(TreeBuilderFactory.Method method, DistanceMatrix distances)
          A factory method to create a ClusteringTreeBuilder
protected  double getDist(int a, int b)
           
protected abstract  T getTree()
           
protected  void init(DistanceMatrix distanceMatrix)
           
protected abstract  double[] joinClusters()
          Inform derived class that clusters besti,bestj are being joinded into a new cluster.
protected  void newCluster()
           
 void removeProgressListener(ProgressListener listener)
           
protected abstract  double updatedDistance(int k)
          compute updated distance between the new cluster (besti,bestj) to any other cluster k.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

distanceMatrix

protected final DistanceMatrix distanceMatrix

numClusters

protected int numClusters

clusters

protected Node[] clusters

newCluster

protected Node newCluster

besti

protected int besti

bestj

protected int bestj

tipCount

protected int[] tipCount

alias

protected int[] alias

distance

protected double[][] distance

minimumTaxa

protected int minimumTaxa
Constructor Detail

ClusteringTreeBuilder

protected ClusteringTreeBuilder(DistanceMatrix distanceMatrix,
                                int minimumTaxa)
                         throws IllegalArgumentException
Constructor

Parameters:
distanceMatrix -
minimumTaxa -
Throws:
IllegalArgumentException
Method Detail

build

public T build()
Specified by:
build in interface TreeBuilder<T extends Tree>

addProgressListener

public void addProgressListener(ProgressListener listener)
Specified by:
addProgressListener in interface TreeBuilder<T extends Tree>

removeProgressListener

public void removeProgressListener(ProgressListener listener)
Specified by:
removeProgressListener in interface TreeBuilder<T extends Tree>

fireSetProgress

public void fireSetProgress(double fractionCompleted)

getBuilder

public static ClusteringTreeBuilder getBuilder(TreeBuilderFactory.Method method,
                                               DistanceMatrix distances)
A factory method to create a ClusteringTreeBuilder

Parameters:
method - build method to use.
distances - Pre computed pairwise distances.
Returns:
A tree builder using method and distance matrix

getTree

protected abstract T getTree()

createExternalNode

protected abstract Node createExternalNode(Taxon taxon)

createInternalNode

protected abstract Node createInternalNode(Node[] nodes,
                                           double[] distances)

joinClusters

protected abstract double[] joinClusters()
Inform derived class that clusters besti,bestj are being joinded into a new cluster. New cluster will be (the smaller) besti while clusters greater than bestj are shifted one space back.

Returns:
branch distances to new internal node [besti - dist , bestj dist]

updatedDistance

protected abstract double updatedDistance(int k)
compute updated distance between the new cluster (besti,bestj) to any other cluster k. (i,j,k) are cluster indices in [0..numClusters-1]


getDist

protected double getDist(int a,
                         int b)

init

protected void init(DistanceMatrix distanceMatrix)

findNextPair

protected void findNextPair()
Find next two clusters to join. set shared best{i,j}.


newCluster

protected void newCluster()

finish

protected void finish()