pal.treesearch
Class PivotNode

java.lang.Object
  extended by pal.treesearch.AbstractParentableConstrainedNode
      extended by pal.treesearch.PivotNode
All Implemented Interfaces:
FreeNode, GeneralOptimisable, GeneralTreeComponent, GroupLeader, ParentableConstrainedNode, RootAccess

public class PivotNode
extends AbstractParentableConstrainedNode
implements GeneralOptimisable, ParentableConstrainedNode, FreeNode, RootAccess, GroupLeader


Constructor Summary
PivotNode(Node tree, FreeBranch parentConnection, GeneralConstructionTool tool, GeneralConstraintGroupManager constraintGroupManager, GeneralConstraintGroupManager.Store store)
          The subtree constructor with a connection to the rest of the tree
PivotNode(Node subTree, GeneralConstructionTool tool, GeneralConstraintGroupManager groupManager, GeneralConstraintGroupManager.Store store)
          The root constructor, only used when the whole tree is constrained
 
Method Summary
 Node buildPALNodeBase()
           
 Node buildPALNodeBase(double branchLength_, FreeBranch caller)
           
 Node buildPALNodeES()
           
 Node buildPALNodeES(double branchLength_, FreeBranch caller)
           
 double calculateLogLikelihood(GeneralConstructionTool tool)
           
 FreeBranch extract(FreeBranch caller)
          We can't extract
 void getAllComponents(java.util.ArrayList store, java.lang.Class componentType, FreeBranch caller)
          Recurse to all neighbours but caller
 ConditionalProbabilityStore getAscendentExtended(double baseHeight, ConstrainedNode childCaller, GeneralConstructionTool tool, boolean allowCaching)
           
 ConditionalProbabilityStore getAscendentFlat(ConstrainedNode childCaller, GeneralConstructionTool tool, boolean allowCaching)
           
 PatternInfo getAscendentPatternInfo(ConstrainedNode childCaller, GeneralConstructionTool tool)
           
 ConditionalProbabilityStore getExtendedConditionalProbabilities(double distance, FreeBranch caller, GeneralConstructionTool tool)
           
 ConditionalProbabilityStore getExtendedConditionalProbabilities(double distance, FreeBranch caller, UnconstrainedLikelihoodModel.External external, ConditionalProbabilityStore resultStore, GeneralConstructionTool tool)
           
 ConditionalProbabilityStore getFlatConditionalProbabilities(FreeBranch caller, GeneralConstructionTool tool)
           
 FreeBranch getLeftBranch(FreeBranch caller)
           
 PatternInfo getLeftPatternInfo(GeneralConstructionTool tool, FreeBranch caller)
           
 void getNonSubTreeComponents(java.util.ArrayList store, java.lang.Class componentType)
           
 int getNumberOfOptimisationTypes()
           
 PatternInfo getPatternInfo(GeneralConstructionTool tool, FreeBranch caller)
           
 FreeBranch getRightBranch(FreeBranch caller)
           
 PatternInfo getRightPatternInfo(GeneralConstructionTool tool, FreeBranch caller)
           
 boolean hasConnection(FreeBranch c, FreeBranch caller)
           
 boolean hasDirectConnection(FreeBranch query)
           
 double optimise(int optimisationType, UnivariateMinimum minimiser, GeneralConstructionTool tool, int fracDigits)
           
 void postSetupNotify(ConstraintModel.GroupManager groupConstraints)
          Tell the group leader that the groupConstraints have been set up (parameter wise), and that internal node heights for example may be calculated
 void setConnectingBranches(FreeBranch[] store, int number)
           
 void swapConnection(FreeBranch original, FreeBranch newConnection)
          Should not do anything but swap branches around
 void swapConnection(FreeBranch original, FreeNode nodeToReplace, FreeBranch newConnection)
          Should preserve tree integrity
 void testLikelihood(FreeBranch caller, GeneralConstructionTool tool)
           
 void testLikelihood(GeneralConstructionTool tool)
           
 java.lang.String toString()
           
 java.lang.String toString(FreeBranch caller)
           
 
Methods inherited from class pal.treesearch.AbstractParentableConstrainedNode
adjustNodeHeight, buildDescendentPALNodeBase, buildDescendentPALNodeES, buildLeftDecendentPALNodeBase, buildRightDecendentPALNodeBase, getAllComponents, getConstrainedInternal, getDescendentExtendedConditionals, getDescendentExtendedConditionalsWithAdjustedInternalHeights, getDescendentFlatConditionals, getDescendentLogLikelihood, getDescendentPatternInfo, getLeftChild, getLeftChildPatternInfo, getLeftDescendentExtendedConditionals, getLeftDescendentExtendedConditionals, getMaxChildHeight, getMaxOriginalDescendentLeafHeight, getMinimumChildSeperation, getMinimumChildSeperation, getMinimumDirectChildDistance, getMinimumLeafChildSeperation, getMinimumLeafChildSeperation, getMinOriginalDescendentLeafHeight, getNodeHeight, getNonSubTreeOfChildComponents, getRightChild, getRightChildPatternInfo, getRightDescendentExtendedConditionals, getRightDescendentExtendedConditionals, getSubTreeComponents, isLeftChild, obtainConstrainedExternalCalculator, obtainLeafInformation, rebuildDescendentPattern, recursivelyAdjustNodeHeight, recursivelySetChildrenParentPivot, setNodeHeight, setupInternalNodeHeights, toStringHeights, toStringLengths, toStringLengths
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface pal.treesearch.ParentableConstrainedNode
getNodeHeight, getNonSubTreeOfChildComponents
 
Methods inherited from interface pal.treesearch.GeneralTreeComponent
getAllComponents
 
Methods inherited from interface pal.treesearch.RootAccess
getAllComponents
 
Methods inherited from interface pal.treesearch.GroupLeader
obtainLeafInformation
 

Constructor Detail

PivotNode

public PivotNode(Node tree,
                 FreeBranch parentConnection,
                 GeneralConstructionTool tool,
                 GeneralConstraintGroupManager constraintGroupManager,
                 GeneralConstraintGroupManager.Store store)
The subtree constructor with a connection to the rest of the tree

Parameters:
tree - the PAL node tree to base this tree on
parentConnection - The connection with the rest of tree (must be free, otherwise this shouldn't be the pivot)
tool - A general construction tool object for objtaining/building various components
groupConstraints - The constraints object that manages the leaf constraints

PivotNode

public PivotNode(Node subTree,
                 GeneralConstructionTool tool,
                 GeneralConstraintGroupManager groupManager,
                 GeneralConstraintGroupManager.Store store)
The root constructor, only used when the whole tree is constrained

Parameters:
tool - A general construction tool object for objtaining/building various components
subTree - The subtree
groupConstraints - The constraints object that manages the leaf constraints
Method Detail

postSetupNotify

public void postSetupNotify(ConstraintModel.GroupManager groupConstraints)
Description copied from interface: GroupLeader
Tell the group leader that the groupConstraints have been set up (parameter wise), and that internal node heights for example may be calculated

Specified by:
postSetupNotify in interface GroupLeader

buildPALNodeBase

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

buildPALNodeES

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

toString

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

getAscendentExtended

public ConditionalProbabilityStore getAscendentExtended(double baseHeight,
                                                        ConstrainedNode childCaller,
                                                        GeneralConstructionTool tool,
                                                        boolean allowCaching)
Specified by:
getAscendentExtended in interface ParentableConstrainedNode

getAscendentFlat

public ConditionalProbabilityStore getAscendentFlat(ConstrainedNode childCaller,
                                                    GeneralConstructionTool tool,
                                                    boolean allowCaching)
Specified by:
getAscendentFlat in interface ParentableConstrainedNode

getAscendentPatternInfo

public PatternInfo getAscendentPatternInfo(ConstrainedNode childCaller,
                                           GeneralConstructionTool tool)
Specified by:
getAscendentPatternInfo in interface ParentableConstrainedNode

calculateLogLikelihood

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

getPatternInfo

public PatternInfo getPatternInfo(GeneralConstructionTool tool,
                                  FreeBranch caller)
Specified by:
getPatternInfo in interface FreeNode

hasConnection

public boolean hasConnection(FreeBranch c,
                             FreeBranch caller)
Specified by:
hasConnection in interface FreeNode

getLeftBranch

public FreeBranch getLeftBranch(FreeBranch caller)
Specified by:
getLeftBranch in interface FreeNode

getRightBranch

public FreeBranch getRightBranch(FreeBranch caller)
Specified by:
getRightBranch in interface FreeNode

getAllComponents

public void getAllComponents(java.util.ArrayList store,
                             java.lang.Class componentType,
                             FreeBranch caller)
Description copied from interface: FreeNode
Recurse to all neighbours but caller

Specified by:
getAllComponents in interface FreeNode

testLikelihood

public void testLikelihood(FreeBranch caller,
                           GeneralConstructionTool tool)
Specified by:
testLikelihood in interface FreeNode

testLikelihood

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

getLeftPatternInfo

public PatternInfo getLeftPatternInfo(GeneralConstructionTool tool,
                                      FreeBranch caller)
Specified by:
getLeftPatternInfo in interface FreeNode
Returns:
Get the pattern info for the relative left (from the caller's perspective), or null if not left pattern info

getRightPatternInfo

public PatternInfo getRightPatternInfo(GeneralConstructionTool tool,
                                       FreeBranch caller)
Specified by:
getRightPatternInfo in interface FreeNode
Returns:
Get the pattern info for the relative right (from the caller's perspective), or null if not right pattern info

getExtendedConditionalProbabilities

public ConditionalProbabilityStore getExtendedConditionalProbabilities(double distance,
                                                                       FreeBranch caller,
                                                                       GeneralConstructionTool tool)
Specified by:
getExtendedConditionalProbabilities in interface FreeNode

getExtendedConditionalProbabilities

public ConditionalProbabilityStore getExtendedConditionalProbabilities(double distance,
                                                                       FreeBranch caller,
                                                                       UnconstrainedLikelihoodModel.External external,
                                                                       ConditionalProbabilityStore resultStore,
                                                                       GeneralConstructionTool tool)
Specified by:
getExtendedConditionalProbabilities in interface FreeNode

extract

public FreeBranch extract(FreeBranch caller)
We can't extract

Specified by:
extract in interface FreeNode
Parameters:
caller - should be the same as free connection!
Returns:
null

buildPALNodeES

public Node buildPALNodeES(double branchLength_,
                           FreeBranch caller)
Specified by:
buildPALNodeES in interface FreeNode

buildPALNodeBase

public Node buildPALNodeBase(double branchLength_,
                             FreeBranch caller)
Specified by:
buildPALNodeBase in interface FreeNode

getFlatConditionalProbabilities

public ConditionalProbabilityStore getFlatConditionalProbabilities(FreeBranch caller,
                                                                   GeneralConstructionTool tool)
Specified by:
getFlatConditionalProbabilities in interface FreeNode

toString

public java.lang.String toString(FreeBranch caller)
Specified by:
toString in interface FreeNode

setConnectingBranches

public void setConnectingBranches(FreeBranch[] store,
                                  int number)
Specified by:
setConnectingBranches in interface FreeNode

hasDirectConnection

public boolean hasDirectConnection(FreeBranch query)
Specified by:
hasDirectConnection in interface FreeNode

swapConnection

public void swapConnection(FreeBranch original,
                           FreeBranch newConnection)
Should not do anything but swap branches around

Specified by:
swapConnection in interface FreeNode

swapConnection

public void swapConnection(FreeBranch original,
                           FreeNode nodeToReplace,
                           FreeBranch newConnection)
Should preserve tree integrity

Specified by:
swapConnection in interface FreeNode

getNonSubTreeComponents

public void getNonSubTreeComponents(java.util.ArrayList store,
                                    java.lang.Class componentType)
Specified by:
getNonSubTreeComponents in class AbstractParentableConstrainedNode

getNumberOfOptimisationTypes

public 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