FORESTER 1.6

forester.tools
Class DistanceCalculator

java.lang.Object
  |
  +--forester.tools.DistanceCalculator

public class DistanceCalculator
extends java.lang.Object

Version:
1.001 -- last modified: 12/04/00
Author:
Christian M. Zmasek

Field Summary
static double DEFAULT
           
 
Constructor Summary
DistanceCalculator()
          Default constructor.
DistanceCalculator(Tree t)
          Constructor.
DistanceCalculator(Tree t, java.util.Vector ext_nodes)
          Constructor.
 
Method Summary
 double getDistanceToLCA(java.lang.String seq_name)
          Calculates the distance of the Node with seq name seq_name to the LCA of ext_nodes, which has been set either with constructor DistanceCalculator(Tree,Vector) or method setTreeAndExtNodes(Tree,Vector).
 double getDistanceToNode(Node outer, Node inner)
          Calculates the distance of Node outer to Node inner.
 double getDistanceToNode(java.lang.String seq_name, Node inner)
          Calculates the distance of the Node with seq name seq_name to Node inner.
 double getDistanceToRoot(Node n)
          Calculates the distance of Node n to the root of Tree t which has been set either with a constructor, setTree(Tree), or setTreeAndExtNodes(Tree,Vector).
 double getDistanceToRoot(java.lang.String seq_name)
          Calculates the distance of the Node with seq name seq_name to the root of Tree t, which has been set either with a constructor, setTree(Tree), or setTreeAndExtNodes(Tree,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(java.lang.String[] args)
           
 void setTree(Tree t)
          Sets the rooted Tree t for which the mean distance to the root and its variance and standard deviation are calculated.
 void setTreeAndExtNodes(Tree t, java.util.ArrayList ext_nodes)
          Sets the rooted Tree 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(Tree t, java.util.Vector ext_nodes)
          Sets the rooted Tree 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
Constructor Detail

DistanceCalculator

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

DistanceCalculator

public DistanceCalculator(Tree t)
Constructor. Sets the rooted Tree 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 Tree for which the mean distance to the root and its variance and standard deviation are calculated

DistanceCalculator

public DistanceCalculator(Tree t,
                          java.util.Vector ext_nodes)
Constructor. Sets the rooted Tree 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 Tree 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

setTree

public void setTree(Tree t)
Sets the rooted Tree 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 Tree for which the mean distance to the root and its variance and standard deviation are calculated

setTreeAndExtNodes

public void setTreeAndExtNodes(Tree t,
                               java.util.Vector ext_nodes)
Sets the rooted Tree 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 Tree 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

setTreeAndExtNodes

public void setTreeAndExtNodes(Tree t,
                               java.util.ArrayList ext_nodes)
Sets the rooted Tree 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 Tree 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

getDistanceToRoot

public double getDistanceToRoot(Node n)
Calculates the distance of Node n to the root of Tree t which has been set either with a constructor, setTree(Tree), or setTreeAndExtNodes(Tree,Vector). (Last modified: 12/01/00)
Parameters:
n - the Node for which the distance to the root is to be calculated
Returns:
distance of Node n to the root
See Also:
DistanceCalculator(Tree), DistanceCalculator(Tree,Vector), setTree(Tree), setTreeAndExtNodes(Tree,Vector)

getDistanceToNode

public double getDistanceToNode(Node outer,
                                Node inner)
                         throws java.lang.Exception
Calculates the distance of Node outer to Node inner. Node inner must be closer to the root than Node outer and on the same "path". (Last modified: 12/01/00)
Parameters:
outer - a Node
inner - a Node closer to the root than outer
Returns:
distance of Node outer to Node inner

getDistanceToRoot

public double getDistanceToRoot(java.lang.String seq_name)
                         throws java.lang.Exception
Calculates the distance of the Node with seq name seq_name to the root of Tree t, which has been set either with a constructor, setTree(Tree), or setTreeAndExtNodes(Tree,Vector). Throws an exception if no Node 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 Node for which the distance to the root is to be calculated
Returns:
distance of Node with seq name seq_name to the root
See Also:
DistanceCalculator(Tree), DistanceCalculator(Tree,Vector), setTree(Tree), setTreeAndExtNodes(Tree,Vector), setTreeAndExtNodes(Tree,ArrayList)

getDistanceToLCA

public double getDistanceToLCA(java.lang.String seq_name)
                        throws java.lang.Exception
Calculates the distance of the Node with seq name seq_name to the LCA of ext_nodes, which has been set either with constructor DistanceCalculator(Tree,Vector) or method setTreeAndExtNodes(Tree,Vector). Throws an exception if no Node 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 Node for which the distance to the LCA is to be calculated
Returns:
distance of Node with seq name seq_name to the LCA of Nodes in ext_nodes
See Also:
DistanceCalculator(Tree,Vector), setTreeAndExtNodes(Tree,Vector), setTreeAndExtNodes(Tree,ArrayList)

getDistanceToNode

public double getDistanceToNode(java.lang.String seq_name,
                                Node inner)
                         throws java.lang.Exception
Calculates the distance of the Node with seq name seq_name to Node inner. Node inner must be closer to the root than the Node with seq name seq_name and on the same "path". Throws an exception if no Node 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 Node further from the root than Node inner
inner - a Node
Returns:
distance of Node with seq name seq_nam to Node inner

getMean

public double getMean()
Returns the mean distance. If constructor DistanceCalculator(Tree) or method setTree(Tree) have been used, it is the mean of the distances from the root to all external Nodes. If constructor DistanceCalculator(Tree,Vector) or method setTreeAndExtNodes(Tree,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(Tree), DistanceCalculator(Tree,Vector), setTree(Tree), setTreeAndExtNodes(Tree,Vector), setTreeAndExtNodes(Tree,ArrayList)

getVariance

public double getVariance()
Returns the variance. ( 1/(N - 1) * Sum((x-mean)^2) ) If constructor DistanceCalculator(Tree) or method setTree(Tree) have been used, it is the variance of the distances from the root to all external Nodes. If constructor DistanceCalculator(Tree,Vector) or method setTreeAndExtNodes(Tree,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(Tree), DistanceCalculator(Tree,Vector), setTree(Tree), setTreeAndExtNodes(Tree,Vector), setTreeAndExtNodes(Tree,ArrayList)

getStandardDeviation

public double getStandardDeviation()
Returns the standard deviation. If constructor DistanceCalculator(Tree) or method setTree(Tree) have been used, it is the standard deviation of the distances from the root to all external Nodes. If constructor DistanceCalculator(Tree,Vector) or method setTreeAndExtNodes(Tree,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(Tree), DistanceCalculator(Tree,Vector), setTree(Tree), setTreeAndExtNodes(Tree,Vector), setTreeAndExtNodes(Tree,ArrayList)

getN

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

main

public static void main(java.lang.String[] args)

FORESTER 1.6