pal.treesearch
Class FreeBranch

java.lang.Object
  extended by pal.treesearch.FreeBranch
All Implemented Interfaces:
GeneralOptimisable, RootAccess

public final class FreeBranch
extends java.lang.Object
implements RootAccess, GeneralOptimisable


Constructor Summary
FreeBranch(FreeNode left, FreeNode right, double branchLength, GeneralConstructionTool tool)
          A generic constructor given two already defined left and right children
FreeBranch(Node n, FreeNode parent, GeneralConstructionTool tool, GeneralConstraintGroupManager.Store store)
          Continuing recurison constructor for a given tree
FreeBranch(Node n, GeneralConstructionTool tool, GeneralConstraintGroupManager.Store store)
          The starting constructor for building from a given tree
 
Method Summary
 FreeBranch attachTo(FreeBranch attachmentPoint, FreeBranch[] store)
           
 Node buildPALNodeBase()
           
 Node buildPALNodeBase(FreeNode caller)
           
 Node buildPALNodeES()
           
 Node buildPALNodeES(FreeNode caller)
           
 double calculateLogLikelihood(GeneralConstructionTool tool)
           
 double calculateLogLikelihood2(GeneralConstructionTool tool)
           
 SiteDetails calculateSiteDetails(UnconstrainedLikelihoodModel.External calculator, GeneralConstructionTool tool)
           
 boolean doNNI(boolean leftSwapLeft, boolean rightSwapLeft)
          Does not reconstruct patterns
 void doNNI(MersenneTwisterFast r)
           
 void getAllComponents(java.util.ArrayList store, java.lang.Class componentType)
           
 void getAllComponents(java.util.ArrayList store, java.lang.Class componentType, FreeNode caller)
           
 double getBranchLength()
           
 PatternInfo getCenterPatternInfo(GeneralConstructionTool tool)
           
 void getCenterPatternInfo(GeneralConstructionTool tool, PatternInfo store)
           
 ConditionalProbabilityStore getExtendedConditionalProbabilities(FreeNode caller, GeneralConstructionTool tool)
           
 ConditionalProbabilityStore getExtendedConditionalProbabilities(FreeNode caller, UnconstrainedLikelihoodModel.External externalCalculator, ConditionalProbabilityStore extendedStore, GeneralConstructionTool tool)
           
 FreeNode getLeft()
           
 ConditionalProbabilityStore getLeftFlatConditionalProbabilities(GeneralConstructionTool tool)
           
 FreeBranch getLeftLeftBranch()
           
 PatternInfo getLeftPatternInfo(GeneralConstructionTool tool)
           
 FreeBranch getLeftRightBranch()
           
 int getNumberOfOptimisationTypes()
           
 FreeNode getOther(FreeNode caller)
           
 PatternInfo getPatternInfo(GeneralConstructionTool tool, FreeNode caller)
           
 FreeNode getRight()
           
 ConditionalProbabilityStore getRightFlatConditionalProbabilities(GeneralConstructionTool tool)
           
 FreeBranch getRightLeftBranch()
           
 PatternInfo getRightPatternInfo(GeneralConstructionTool tool)
           
 FreeBranch getRightRightBranch()
           
 boolean hasConnection(FreeBranch c, FreeNode caller)
           
 void mark()
          Mark this node, or in other words store information on left and right nodes and branch length for later retreival (via undoToMark())
 double optimise(int optimisationType, UnivariateMinimum minimiser, GeneralConstructionTool tool, int fracDigits)
           
 void setAnnotation(java.lang.Object annotation)
           
 void setBranchLength(double x)
           
 void setNodes(FreeNode left, FreeNode right)
          Does nothing to fix up tree structure
 void swapNode(FreeNode nodeToReplace, FreeNode replacement)
           
 void testLikelihood(FreeNode caller, GeneralConstructionTool tool)
           
 void testLikelihood(GeneralConstructionTool tool)
           
 java.lang.String toString()
           
 java.lang.String toString(FreeNode caller)
           
 void undoToMark()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FreeBranch

public FreeBranch(Node n,
                  GeneralConstructionTool tool,
                  GeneralConstraintGroupManager.Store store)
The starting constructor for building from a given tree

Parameters:
n - The normal PAL node structure to base this tree on
tool - to aid in construction

FreeBranch

public FreeBranch(Node n,
                  FreeNode parent,
                  GeneralConstructionTool tool,
                  GeneralConstraintGroupManager.Store store)
Continuing recurison constructor for a given tree

Parameters:
n - The PAL node structure to base sub tree on
parent - The parent node (sub tree in other direction)
tool - to aid in construction

FreeBranch

public FreeBranch(FreeNode left,
                  FreeNode right,
                  double branchLength,
                  GeneralConstructionTool tool)
A generic constructor given two already defined left and right children

Parameters:
left - The left node
right - The right node
branchLength - The length of connection
tool - to aid in construction
Method Detail

setAnnotation

public void setAnnotation(java.lang.Object annotation)

getLeft

public final FreeNode getLeft()
Returns:
The "right" node of this connection.

getRight

public final FreeNode getRight()
Returns:
The "left" node of this connection.

mark

public final void mark()
Mark this node, or in other words store information on left and right nodes and branch length for later retreival (via undoToMark())


getLeftPatternInfo

public final PatternInfo getLeftPatternInfo(GeneralConstructionTool tool)
Returns:
The pattern info object for the left node leading to this connection

getRightPatternInfo

public final PatternInfo getRightPatternInfo(GeneralConstructionTool tool)
Returns:
The pattern info object for the right node leading to this connection

getPatternInfo

public final PatternInfo getPatternInfo(GeneralConstructionTool tool,
                                        FreeNode caller)

getCenterPatternInfo

public final PatternInfo getCenterPatternInfo(GeneralConstructionTool tool)
Returns:
The pattern info across this connection (for use if this connection is the "root" of the likelihood calculation)

undoToMark

public final void undoToMark()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hasConnection

public boolean hasConnection(FreeBranch c,
                             FreeNode caller)

getLeftLeftBranch

public FreeBranch getLeftLeftBranch()
Returns:
the "left" connection of the left node

getLeftRightBranch

public FreeBranch getLeftRightBranch()
Returns:
the "right" connection of the left node

getRightLeftBranch

public FreeBranch getRightLeftBranch()
Returns:
the "left" connection of the right node

getRightRightBranch

public FreeBranch getRightRightBranch()
Returns:
the "right" connection of the left node

attachTo

public FreeBranch attachTo(FreeBranch attachmentPoint,
                           FreeBranch[] store)
Returns:
connection that by attaching to we would undo this operation, null if operation no successful

buildPALNodeBase

public Node buildPALNodeBase()
Specified by:
buildPALNodeBase in interface RootAccess

buildPALNodeES

public Node buildPALNodeES()
Specified by:
buildPALNodeES in interface RootAccess

buildPALNodeBase

public Node buildPALNodeBase(FreeNode caller)

buildPALNodeES

public Node buildPALNodeES(FreeNode caller)

setNodes

public void setNodes(FreeNode left,
                     FreeNode right)
Does nothing to fix up tree structure


swapNode

public void swapNode(FreeNode nodeToReplace,
                     FreeNode replacement)

getLeftFlatConditionalProbabilities

public final ConditionalProbabilityStore getLeftFlatConditionalProbabilities(GeneralConstructionTool tool)

getRightFlatConditionalProbabilities

public final ConditionalProbabilityStore getRightFlatConditionalProbabilities(GeneralConstructionTool tool)

getBranchLength

public final double getBranchLength()

setBranchLength

public final void setBranchLength(double x)

toString

public java.lang.String toString(FreeNode caller)

testLikelihood

public void testLikelihood(GeneralConstructionTool tool)
Specified by:
testLikelihood in interface RootAccess

testLikelihood

public void testLikelihood(FreeNode caller,
                           GeneralConstructionTool tool)

getExtendedConditionalProbabilities

public ConditionalProbabilityStore getExtendedConditionalProbabilities(FreeNode caller,
                                                                       GeneralConstructionTool tool)

getExtendedConditionalProbabilities

public ConditionalProbabilityStore getExtendedConditionalProbabilities(FreeNode caller,
                                                                       UnconstrainedLikelihoodModel.External externalCalculator,
                                                                       ConditionalProbabilityStore extendedStore,
                                                                       GeneralConstructionTool tool)

getNumberOfOptimisationTypes

public final int getNumberOfOptimisationTypes()
Specified by:
getNumberOfOptimisationTypes in interface GeneralOptimisable

optimise

public double optimise(int optimisationType,
                       UnivariateMinimum minimiser,
                       GeneralConstructionTool tool,
                       int fracDigits)
Specified by:
optimise in interface GeneralOptimisable
minimiser - The single dimensional minimisation tool
tool - The construction tool
fracDigits - the number of fractional digits to converge to
Returns:
The optimised log likelihood, or >0 if not optimisation occured

getAllComponents

public void getAllComponents(java.util.ArrayList store,
                             java.lang.Class componentType)
Specified by:
getAllComponents in interface RootAccess

getAllComponents

public void getAllComponents(java.util.ArrayList store,
                             java.lang.Class componentType,
                             FreeNode caller)

getCenterPatternInfo

public void getCenterPatternInfo(GeneralConstructionTool tool,
                                 PatternInfo store)

getOther

public FreeNode getOther(FreeNode caller)

doNNI

public final void doNNI(MersenneTwisterFast r)

doNNI

public boolean doNNI(boolean leftSwapLeft,
                     boolean rightSwapLeft)
Does not reconstruct patterns


calculateLogLikelihood

public double calculateLogLikelihood(GeneralConstructionTool tool)
Specified by:
calculateLogLikelihood in interface RootAccess

calculateLogLikelihood2

public double calculateLogLikelihood2(GeneralConstructionTool tool)

calculateSiteDetails

public SiteDetails calculateSiteDetails(UnconstrainedLikelihoodModel.External calculator,
                                        GeneralConstructionTool tool)