Package pal.tree

Class TreeManipulator

    • Field Detail

      • MIMIC_CONSTRUCTION

        public static final int MIMIC_CONSTRUCTION
        Construct tree with same multification as original
        See Also:
        Constant Field Values
      • EXPAND_CONSTRUCTION

        public static final int EXPAND_CONSTRUCTION
        Construct tree, but convert general multifications to a series of bifications
        See Also:
        Constant Field Values
      • REDUCE_CONSTRUCTION

        public static final int REDUCE_CONSTRUCTION
        Construct tree, but convert bificating nodes that appear as multifications (due to very short branchlengths) to multifications
        See Also:
        Constant Field Values
    • Constructor Detail

      • TreeManipulator

        public TreeManipulator​(Tree base,
                               int constructionMode)
        Construct a TreeManipulator based around a normal tree
        Parameters:
        base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
        constructionMode - the way in which the internal tree representation is constructed
      • TreeManipulator

        public TreeManipulator​(Tree base)
        Construct a TreeManipulator based around a normal tree
        Parameters:
        base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
      • TreeManipulator

        public TreeManipulator​(Node base)
        Units will be Units.UNKNOWN
      • TreeManipulator

        public TreeManipulator​(Node base,
                               int units)
        Construct a TreeManipulator based around a normal tree
        Parameters:
        base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
        units - , the units of generated trees. Not really of concern if only Node trees built
      • TreeManipulator

        public TreeManipulator​(Node base,
                               int units,
                               int constructionMode)
        Construct a TreeManipulator based around a normal tree
        Parameters:
        base - The base tree, which can be rooted or unrooted (will be treated as unrooted either way)
        units - , the units of generated trees. Not really of concern if only Node trees built
    • Method Detail

      • getMidPointRooted

        public Node getMidPointRooted()
        Returns:
        the MidPoint rooted tree (as root node);
      • getDefaultRoot

        public Node getDefaultRoot()
        Returns:
        a tree rooted around the node it was originally rooted around (if originally rooted),
      • getAsInputRooting

        public Node getAsInputRooting()
        A method for recovering the input (construction) tree (with the EXPANSION/MIMIC/REDUCED differences)
        Returns:
        An unrooted tree if the input tree was unrooted, otherwise the default rooting
      • getAsInputRootingTree

        public Tree getAsInputRootingTree()
        A method for recovering the input (construction) tree (with the EXPANSION/MIMIC/REDUCED differences)
        Returns:
        An unrooted tree if the input tree was unrooted, otherwise the default rooting
      • getDefaultRootTree

        public Tree getDefaultRootTree()
        Returns:
        a tree rooted around the node it was originally rooted around (if originally rooted),
      • getMidPointRootedTree

        public Tree getMidPointRootedTree()
        Returns:
        the MidPoint rooted tree
      • getUnrooted

        public Node getUnrooted()
        return unrooted node
      • getUnrootedTree

        public Tree getUnrootedTree()
        return unrooted node
      • getRootedBy

        public Node getRootedBy​(java.lang.String[] outgroupNames)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        Returns:
        the tree rooted by an outgroup defined by the mrca of a set of nodes
        Throws:
        IllegalArgument - exception if outgroup names does not contain any valid node names
      • instructRootedBy

        public void instructRootedBy​(RootedTreeInterface rootedInterface,
                                     java.lang.String[] outgroupNames)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        Throws:
        IllegalArgument - exception if outgroup names does not contain any valid node names
      • getRootedBy

        public Node getRootedBy​(java.lang.String[] outgroupNames,
                                double ingroupBranchLength)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        ingroupBranchLength - the maximum length of the branch leading to the ingroup clade
        Returns:
        the tree rooted by an outgroup defined by the mrca of a set of nodes
        Throws:
        IllegalArgument - exception if outgroup names does not contain any valid node names
      • getAllRootedBy

        public Node[] getAllRootedBy​(java.lang.String[] outgroupNames)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        Returns:
        all the trees rooted by an outgroup defined by the mrca of a set of nodes
        Throws:
        IllegalArgument - exception if outgroup names does not contain any valid node names
      • getTreeRootedBy

        public Tree getTreeRootedBy​(java.lang.String[] outgroupNames)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        Returns:
        the tree rooted by an outgroup defined by the mrca of a set of nodes
      • getTreeRootedBy

        public Tree getTreeRootedBy​(java.lang.String[] outgroupNames,
                                    double ingroupBranchLength)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        ingroupBranchLength - the maximum length of the branch leading to the ingroup clade
        Returns:
        the tree rooted by an outgroup defined by the mrca of a set of nodes
      • getAllTreesRootedBy

        public Tree[] getAllTreesRootedBy​(java.lang.String[] outgroupNames)
        Parameters:
        outgroupNames - the names of the members of the outgroup
        Returns:
        all the possible rootings defined by the outgroup
      • getEveryRootIterator

        public TreeIterator getEveryRootIterator()
        Returns:
        a tree iterator that returns each and every possible root of the base tree (as a new tree object each time)
      • getBranchAccess

        public TreeManipulator.BranchAccess[] getBranchAccess()
        Obtain access to individual branches
        Returns:
        an array of branch access objects
      • getEveryRoot

        public Tree[] getEveryRoot()
        Returns:
        each and every possible root of the base tree
      • getRootedAbove

        public Node getRootedAbove​(Node base)
        Parameters:
        Node - n, a node from the original base tree that this TreeManipulator was constructed on
        Throws:
        Illegal - argument exception if input node was not in original base tree
      • getTreeRootedAbove

        public Tree getTreeRootedAbove​(Node n)
        Parameters:
        Node - n, a node from the original base tree that this TreeManipulator was constructed on
        Throws:
        Illegal - argument exception if input node was not in original base tree
      • getUnrooted

        public static final Tree getUnrooted​(Tree base)
        Unroots a tree
        Parameters:
        base - The input tree that may or may not be unrooted
        Returns:
        an unrooted tree (has a trification at base)
      • getMidpointRooted

        public static final Tree getMidpointRooted​(Tree base)
        Returns the mid point rooting of a tree. This is the rooting that divides the data between the two most distinct taxa
        Parameters:
        base - The input tree that may or may not be unrooted
        Returns:
        an unrooted tree (has a trification at base)
      • getEveryRoot

        public static final Tree[] getEveryRoot​(Tree base)
        Obtains every rooting of a base tree
        Parameters:
        base - The input tree that may or may not be unrooted
      • getEveryRootIterator

        public static final TreeIterator getEveryRootIterator​(Tree base)
        Obtains every rooting of a base tree
        Parameters:
        base - The input tree that may or may not be unrooted
      • getRootedBy

        public static final Tree getRootedBy​(Tree base,
                                             java.lang.String[] outgroupNames)
        Roots a tree by an outgroup
        Parameters:
        base - The input tree that may or may not be unrooted
        outgroupNames - The names of the members of the outgroup. Names not matching taxa in the tree are ignored. The node that is the MCRA of members of the outgroup will influence the rooting.
        Throws:
        java.lang.IllegalArgumentException - if no members of the tree appear in the outgroup
      • getRootedBy

        public static final Tree getRootedBy​(Tree base,
                                             java.lang.String[] outgroupNames,
                                             double ingroupBranchLength)
        Roots a tree by an outgroup
        Parameters:
        base - The input tree that may or may not be unrooted
        outgroupNames - The names of the members of the outgroup. Names not matching taxa in the tree are ignored. The node that is the MCRA of members of the outgroup will influence the rooting.
        Throws:
        java.lang.IllegalArgumentException - if no members of the tree appear in the outgroup
      • getAllRootingsBy

        public static final Tree[] getAllRootingsBy​(Tree base,
                                                    java.lang.String[] outgroupNames)
        Roots a tree by an outgroup
        Parameters:
        base - The input tree that may or may not be unrooted
        ingroupBranchLength - the maximum length of the branch leading to the ingroup clade
        outgroupNames - The names of the members of the outgroup. Names not matching taxa in the tree are ignored. The node that is the MCRA of members of the outgroup will influence the rooting.
        Returns:
        every possible interpretation of rooting a tree by the given outgroup. If the outgroup is well defined there will be only one tree.
        Throws:
        java.lang.IllegalArgumentException - if no members of the tree appear in the outgroup