org.forester.sdi
Class DistanceCalculator

java.lang.Object
  extended by org.forester.sdi.DistanceCalculator

public class DistanceCalculator
extends Object


Field Summary
static double DEFAULT
           
 
Constructor Summary
DistanceCalculator()
          Default constructor.
DistanceCalculator(Phylogeny t)
          Constructor.
DistanceCalculator(Phylogeny t, Vector<PhylogenyNode> ext_nodes)
          Constructor.
 
Method Summary
 double getDistanceToLCA(String seq_name)
          Calculates the distance of the PhylogenyNode with seq name seq_name to the LCA of ext_nodes, which has been set either with constructor DistanceCalculator(Phylogeny,Vector) or method setTreeAndExtNodes(Phylogeny,Vector).
 double getDistanceToNode(PhylogenyNode outer, PhylogenyNode inner)
          Calculates the distance of PhylogenyNode outer to PhylogenyNode inner.
 double getDistanceToNode(String seq_name, PhylogenyNode inner)
          Calculates the distance of the PhylogenyNode with seq name seq_name to PhylogenyNode inner.
 double getDistanceToRoot(PhylogenyNode n)
          Calculates the distance of PhylogenyNode n to the root of Phylogeny t which has been set either with a constructor, setTree(Phylogeny), or setTreeAndExtNodes(Phylogeny,Vector).
 double getDistanceToRoot(String seq_name)
          Calculates the distance of the PhylogenyNode with seq name seq_name to the root of Phylogeny t, which has been set either with a constructor, setTree(Phylogeny), or setTreeAndExtNodes(Phylogeny,Vector).
 double getMean()
          Returns the mean distance.
 int getN()
          Returns the sum of all Nodes used to calculate the mean.
 double getStandardDeviation()
          Returns the standard deviation.
 double getVariance()
          Returns the variance.
static void main(String[] args)
           
 void setTree(Phylogeny t)
          Sets the rooted Phylogeny t for which the mean distance to the root and its variance and standard deviation are calculated.
 void setTreeAndExtNodes(Phylogeny t, ArrayList<PhylogenyNode> ext_nodes)
          Sets the rooted Phylogeny t and the external Nodes ext_nodes for which the mean distance to their lowest common ancestor and its variance and standard deviation are calculated.
 void setTreeAndExtNodes(Phylogeny t, Vector<PhylogenyNode> ext_nodes)
          Sets the rooted Phylogeny t and the external Nodes ext_nodes for which the mean distance to their lowest common ancestor and its variance and standard deviation are calculated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

public static final double DEFAULT
See Also:
Constant Field Values
Constructor Detail

DistanceCalculator

public DistanceCalculator()
Default constructor. (Last modified: 11/30/00)


DistanceCalculator

public DistanceCalculator(Phylogeny t)
Constructor. Sets the rooted Phylogeny t for which the mean distance to the root and its variance and standard deviation are calculated. (Last modified: 12/01/00)

Parameters:
t - the rooted Phylogeny for which the mean distance to the root and its variance and standard deviation are calculated

DistanceCalculator

public DistanceCalculator(Phylogeny t,
                          Vector<PhylogenyNode> ext_nodes)
Constructor. Sets the rooted Phylogeny t and the external Nodes ext_nodes for which the mean distance to their lowest common ancestor and its variance and standard deviation are calculated. (Last modified: 12/01/00)

Parameters:
t - the rooted Phylogeny containing Nodes in Vector ext_nodes
ext_nodes - a Vector of Nodes of t, the mean distance to their lowest common ancestor and its variance and standard deviation are calculated
Method Detail

getDistanceToLCA

public double getDistanceToLCA(String seq_name)
Calculates the distance of the PhylogenyNode with seq name seq_name to the LCA of ext_nodes, which has been set either with constructor DistanceCalculator(Phylogeny,Vector) or method setTreeAndExtNodes(Phylogeny,Vector). Throws an exception if no PhylogenyNode with seq name_seq name is found or if seq_name is not unique. (Last modified: 12/03/00)

Parameters:
seq_name - the seq name for the PhylogenyNode for which the distance to the LCA is to be calculated
Returns:
distance of PhylogenyNode with seq name seq_name to the LCA of Nodes in ext_nodes
See Also:
DistanceCalculator(Phylogeny,Vector), setTreeAndExtNodes(Phylogeny,Vector), setTreeAndExtNodes(Phylogeny,ArrayList)

getDistanceToNode

public double getDistanceToNode(PhylogenyNode outer,
                                PhylogenyNode inner)
Calculates the distance of PhylogenyNode outer to PhylogenyNode inner. PhylogenyNode inner must be closer to the root than PhylogenyNode outer and on the same "path". (Last modified: 12/01/00)

Parameters:
outer - a PhylogenyNode
inner - a PhylogenyNode closer to the root than outer
Returns:
distance of PhylogenyNode outer to PhylogenyNode inner

getDistanceToNode

public double getDistanceToNode(String seq_name,
                                PhylogenyNode inner)
Calculates the distance of the PhylogenyNode with seq name seq_name to PhylogenyNode inner. PhylogenyNode inner must be closer to the root than the PhylogenyNode with seq name seq_name and on the same "path". Throws an exception if no PhylogenyNode with seq name_seq name is found or if seq_name is not unique. (Last modified: 12/01/00)

Parameters:
seq_name - the seq name of a PhylogenyNode further from the root than PhylogenyNode inner
inner - a PhylogenyNode
Returns:
distance of PhylogenyNode with seq name seq_nam to PhylogenyNode inner

getDistanceToRoot

public double getDistanceToRoot(PhylogenyNode n)
Calculates the distance of PhylogenyNode n to the root of Phylogeny t which has been set either with a constructor, setTree(Phylogeny), or setTreeAndExtNodes(Phylogeny,Vector). (Last modified: 12/01/00)

Parameters:
n - the PhylogenyNode for which the distance to the root is to be calculated
Returns:
distance of PhylogenyNode n to the root
See Also:
DistanceCalculator(Phylogeny), DistanceCalculator(Phylogeny,Vector), setTree(Phylogeny), setTreeAndExtNodes(Phylogeny,Vector)

getDistanceToRoot

public double getDistanceToRoot(String seq_name)
Calculates the distance of the PhylogenyNode with seq name seq_name to the root of Phylogeny t, which has been set either with a constructor, setTree(Phylogeny), or setTreeAndExtNodes(Phylogeny,Vector). Throws an exception if no PhylogenyNode with seq name_seq name is found or if seq_name is not unique. (Last modified: 12/01/00)

Parameters:
seq_name - the seq name for the PhylogenyNode for which the distance to the root is to be calculated
Returns:
distance of PhylogenyNode with seq name seq_name to the root
See Also:
DistanceCalculator(Phylogeny), DistanceCalculator(Phylogeny,Vector), setTree(Phylogeny), setTreeAndExtNodes(Phylogeny,Vector), setTreeAndExtNodes(Phylogeny,ArrayList)

getMean

public double getMean()
Returns the mean distance. If constructor DistanceCalculator(Phylogeny) or method setTree(Phylogeny) have been used, it is the mean of the distances from the root to all external Nodes. If constructor DistanceCalculator(Phylogeny,Vector) or method setTreeAndExtNodes(Phylogeny,Vector) have been used, it is the mean of the distances from the external nodes ext_nodes to their lowest common ancestor. (Last modified: 11/30/00)

Returns:
mean distance
See Also:
DistanceCalculator(Phylogeny), DistanceCalculator(Phylogeny,Vector), setTree(Phylogeny), setTreeAndExtNodes(Phylogeny,Vector), setTreeAndExtNodes(Phylogeny,ArrayList)

getN

public int getN()
Returns the sum of all Nodes used to calculate the mean. (Last modified: 12/01/00)

Returns:
n

getStandardDeviation

public double getStandardDeviation()
Returns the standard deviation. If constructor DistanceCalculator(Phylogeny) or method setTree(Phylogeny) have been used, it is the standard deviation of the distances from the root to all external Nodes. If constructor DistanceCalculator(Phylogeny,Vector) or method setTreeAndExtNodes(Phylogeny,Vector) have been used, it is the standard deviation of the distances from the external nodes ext_nodes to their lowest common ancestor. (Last modified: 11/30/00)

Returns:
standard deviation
See Also:
DistanceCalculator(Phylogeny), DistanceCalculator(Phylogeny,Vector), setTree(Phylogeny), setTreeAndExtNodes(Phylogeny,Vector), setTreeAndExtNodes(Phylogeny,ArrayList)

getVariance

public double getVariance()
Returns the variance. ( 1/(N - 1) * Sum((x-mean)^2) ) If constructor DistanceCalculator(Phylogeny) or method setTree(Phylogeny) have been used, it is the variance of the distances from the root to all external Nodes. If constructor DistanceCalculator(Phylogeny,Vector) or method setTreeAndExtNodes(Phylogeny,Vector) have been used, it is the variance of the distances from the external nodes ext_nodes to their lowest common ancestor. (Last modified: 11/30/00)

Returns:
variance
See Also:
DistanceCalculator(Phylogeny), DistanceCalculator(Phylogeny,Vector), setTree(Phylogeny), setTreeAndExtNodes(Phylogeny,Vector), setTreeAndExtNodes(Phylogeny,ArrayList)

setTree

public void setTree(Phylogeny t)
Sets the rooted Phylogeny t for which the mean distance to the root and its variance and standard deviation are calculated. (Last modified: 12/01/00)

Parameters:
t - the rooted Phylogeny for which the mean distance to the root and its variance and standard deviation are calculated

setTreeAndExtNodes

public void setTreeAndExtNodes(Phylogeny t,
                               ArrayList<PhylogenyNode> ext_nodes)
Sets the rooted Phylogeny t and the external Nodes ext_nodes for which the mean distance to their lowest common ancestor and its variance and standard deviation are calculated. (Last modified: 12/03/00)

Parameters:
t - the rooted Phylogeny containing Nodes in Vector ext_nodes
ext_nodes - a ArrayList of Nodes of t, the mean distance to their lowest common ancestor and its variance and standard deviation are calculated

setTreeAndExtNodes

public void setTreeAndExtNodes(Phylogeny t,
                               Vector<PhylogenyNode> ext_nodes)
Sets the rooted Phylogeny t and the external Nodes ext_nodes for which the mean distance to their lowest common ancestor and its variance and standard deviation are calculated. (Last modified: 12/03/00)

Parameters:
t - the rooted Phylogeny containing Nodes in Vector ext_nodes
ext_nodes - a Vector of Nodes of t, the mean distance to their lowest common ancestor and its variance and standard deviation are calculated

main

public static void main(String[] args)