All Packages Class Hierarchy This Package Previous Next Index
Class mesquite.lib.MesquiteTree
java.lang.Object
|
+----mesquite.lib.Listened
|
+----mesquite.lib.Associable
|
+----mesquite.lib.MesquiteTree
- public class MesquiteTree
- extends mesquite.lib.Associable
- implements mesquite.lib.AdjustableTree, mesquite.lib.Listable, mesquite.lib.Renamable, mesquite.lib.Commandable, mesquite.lib.MesquiteListener, mesquite.lib.CompatibilityChecker, mesquite.lib.Identifiable
The basic Tree class of Mesquite. Nodes are represented by integers (Object representation of nodes is too
memory-costly). Node relationships use the first daughter/next sister system to accommodate polytomies easily.
Thus a recursive method can take the following form and be called initially by recurse(tree, tree.getRoot()); :
- void recurse (Tree tree, int N) {
- for (int d = tree.firstDaughterOfNode(N); tree.nodeExists(d); d = tree.nextSisterOfNode(d))
- recurse(tree, d);
- }
Daughters, sisters and parents of a node can be found using public methods.
Information can be stored at the nodes of the tree in the following ways. The first two storage sites are directly embedded within the Tree. Modules
cannot store their own private information directly in the Tree, but they can use the other storage methods.
- Arrays embedded within the Tree object storing which nodes are mother, sister, daughter, etc.
These arrays are always instantiated and are private; they are accessed via methods such as motherOfNode(node).
- Arrays storing branch lengths and any String label attached to the node.
These arrays are instantiated as needed and are private, but their information can be set and gotten using methods provided.
- Because Tree extends Associable, arrays (LongArray, DoubleArray, ObjectArray or Bits) can be requested that will be attached to the tree and maintained (i.e. the array sizes
will be automatically adjusted if the tree's size changes). This is useful place to store information that is to follow the tree around, to be stuck\
to the tree like lichen. When the tree is written, this information will be written within the tree description String in special comments
associated with each node. When such a tree description is read, the information will be read without assistance from modules. Thus, the information
is of restricted forms, but is public and persistent. Some things that currently use this associable storage are: whether the branch is selected,
the color of the branch, the width of the lineage. Branch selection is given special status because it is used in various calculations, and thus has
streamlined methods to access the information. The information is stored just as is the other Associable information.
- There is a special vector that allows objects to be associated with the tree, called the "sensitiveAttachments". It is private, but objects can be attached, removed
or retrieved from it using the methods provided. Such information is "sensitive" in the sense that it it to be detached as soon as the tree is
altered. This system is still immature; it was invented for information that was to be attached to the tree and used by other modules, but
the information would become untrustworthy as soon as the tree changed. Since the module attaching it to the tree would find it difficult to follow the tree
as it is subsequently used, it attaches the information with the understanding that the information is to be destroyed as soon as the tree changes
(this is done in incrementVersion()).
- All of the above information is referenced directly or indirectly from the Tree object, and thus follows the tree object around. Most modules will
find it useful to have private information that is associated with the tree. They can do this by maintaining arrays that have as many elements
as numNodeSpaces in the tree, with the ith element of the array being associated with the ith node. The size of the array can be checked, and readjusted
if needed, each time a tree is passed.
Support for special sorts of trees:
- Reticulate trees: Support is incomplete. For each node, only one mother node is designated, but if additional parents are specified, they are added to the set
of parents of the node. Thus, calculations needing non-reticulate trees can simply use the mother node and pretend
like the additional parents don't exist. Calculations needing reticulate trees can ask for the parents. (The set of parents
should be built to include the mother node.) Tree reading of reticulate nodes is incomplete.
- Observed taxa fixed as ancestors: not yet supported.
- Truly unrooted trees, with node-rings storage and recursion used by PHYLIP: not yet supported. There are some special methods whose names end in
UR that allow access to the tree as if unrooted.
-
checkIntegrity
- If true then after branch moves, etc., tree integrity is checked.
-
polytomyDefaultHard
- True if default behavior for polytomies is as hard polytomy
-
totalCreated
- A counter of the total number of Trees created (for debugging/memory leaks)
-
totalDisposed
- A counter of the total number of Trees disposed (for debugging/memory leaks)
-
MesquiteTree(Taxa)
- The constructor, passed the Taxa on which the tree is based
-
MesquiteTree(Taxa, int, int, long)
- The constructor, passed the Taxa on which the tree is based.
-
accumulateTerminals(int, int[], MesquiteInteger)
- Places into the passed array (which must have been sized correctly in advance) the taxon numbers in the clade
-
allLengthsAssigned()
- Returns true if tree has all nodes with branch lengths assigned.
-
anyAttachedSensitive(Class)
- Returns whether there are any sensitive attachments of the given class or a subclass
-
anySelectedInClade(int)
- Returns whether there are any selected nodes in the clade
-
attachToSensitives(Object)
- Attach the object to the sensitive attachments
-
branchingAncestor(int)
- Returns the closest ancestor that has more than one daughter.
-
branchingDescendant(int)
- Returns the closest descendant that has more than one daughter, or is terminal.
-
branchLengthUnassigned(int)
- Returns whether branch length of node is unassigned.
-
changed(Object, Object, int, int[])
- For MesquiteListener interface.
-
cloneTree()
- Returns a clone of the tree.
-
collapseAllBranches(int, boolean)
- Collapses all internal branches within clade above node, to yield bush.
-
collapseBranch(int, boolean)
- Collapses branch to yield polytomy.
-
daughterOf(int, int)
- Returns true if branchD is an immediate daughter of branchA
-
daughtersOfNode(int)
- Returns the array of daughters of a node.
-
deleteClade(int, boolean)
- Excise node and clade above it from tree, zeroing information at each node in clade.
-
depthToAncestor(int, int)
- Returns depth of second branch below first; -1 if not ancestral.
-
descendantOf(int, int)
- Returns true iff first branch is a descendant of second branch.
-
dispose()
- Disconnects listeners
-
disposing(Object)
- For MesquiteListener interface.
-
doCommand(String, String, CommandRecord, CommandChecker)
- For Commandable interface; currently responds to set branch length messages and tree description writing
-
equalsCoreArrays(MesquiteTree)
- Returns true if passed tree has same core array storage (same root, mothers, firstDaughter, nextSister, taxonNumber).
-
firstDaughterOfNode(int)
- Returns the first (left-most) daughter of node.
-
firstDaughterOfNodeUR(int, int)
- Returns the first (left-most) daughter of node in an UNROOTED sense where the node
is treated as descendant from anc.
-
getAttachedSensitive(Class, int)
- Returns the indexTH sensitive attachment of the given class or a subclass
-
getBranchLength(int)
- Returns the branch length of the node.
-
getBranchLength(int, double)
- Returns the branch length of the node.
-
getBranchLengthsVersion()
- Returns branch lengths version number of tree.
-
getFirstSelected(int)
- Gets the first node selected in clade of node node
-
getID()
- Returns the unique id number of this tree
-
getListAttachedSensitives()
- Lists attached sensitives
-
getName()
- Returns the name of the tree, or "Untitled" if no name has been set.
-
getNodeLabel(int)
- Gets the node label of the node
-
getNumNodeSpaces()
- Returns the number of node spaces available in storage arrays within tree object.
-
getNumTaxa()
- Returns the number of terminal taxa in the Taxa to which the tree refers.
-
getRoot()
- Returns the root of the tree (i.e., the most recent common ancestor of the terminal taxa in the tree.
-
getRooted()
- Returns whether tree is rooted.
-
getSubRoot()
- Returns the subRoot of the tree (the mother of the most recent common ancestral node of the tree).
-
getTaxa()
- Returns the Taxa to which the tree refers.
-
getTerminalTaxa(int)
- Returns list of terminal taxa of clade of node.
-
getTopologyVersion()
- Returns topology version number of tree.
-
getTreeReference(TreeReference)
-
-
getTreeVector()
- Gets the tree vector to which the tree belongs.
-
graftClade(int, int, boolean)
- Attach node fromN (and any clade to attached to it) along node toN.
-
graftTaxon(int, int, boolean)
- Attach terminal taxon to tree along given branch.
-
grandmotherOfNode(int)
- Returns the node's mother's mother.
-
hasBranchLengths()
- Returns true if tree has branch lengths.
-
hasNodeLabels()
- Returns whether the tree has node labels
-
hasPolytomies(int)
- Returns whether clade has polytomies.
-
inBounds(int)
- Overriding method of Associable.
-
indexedDaughterOfNode(int, int)
- Returns the indexTH daughter of node (zero based).
-
insertNode(int, boolean)
- Inserts a new node on the branch represented by "node", and returns the number of the inserted node
-
interchangeBranches(int, int, boolean)
- Interchanges two branches of tree.
-
isCompatible(Object, MesquiteProject, EmployerEmployee)
- returns true if object is set of taxa on which tree is based.
-
isDefined()
-
-
isLocked()
- Returns whether tree is locked.
-
lastDaughterOfNode(int)
- Returns the right-most daughter of node.
-
lastDaughterOfNodeUR(int, int)
- Returns the first (left-most) daughter of node in an UNROOTED sense where the node
is treated as descendant from anc.
-
leftmostTerminalOfNode(int)
- Returns the left-most terminal that is descendant from node.
-
makeAllRootings(int, TreeVector)
- makes trees for all rootings of clade above node given, and places them into TreeVector
-
motherOfNode(int)
- Returns the immediate ancestor of node (mother) if node is non-reticulate.
-
moveBranch(int, int, boolean)
- Move branch so as to excise branchFrom from its current position, and attach it to branch beneath
node branchTo.
-
mrca(int, int)
- Returns most recent common ancestor of two branches.
-
nextAroundUR(int, int)
- Returns the next (clockwise) to node connected to anc.
-
nextSisterOfNode(int)
- Returns the node's sister immediately to the right.
-
nextSisterOfNodeUR(int, int, int)
- Returns the node's sister immediately to the right in an UNROOTED sense where the node
is treated as descendant from anc, which is descendant from ancAnc.
-
nodeExists(int)
- Returns true if N is a valid node designation in tree.
-
nodeHasLabel(int)
- Returns whether the node has a label
-
nodeInTraversal(int)
- Returns indexTH node in tree traversal
-
nodeInTraversal(int, int)
- Returns indexTH node in traversal through clade
-
nodeInTree(int)
- Returns whether node is part of tree.
-
nodeIsFirstDaughter(int)
- Returns true if node is the first (leftmost) daughter of its mother.
-
nodeIsHard(int)
- Returns true if the node has one descendant, two, or is a hard polytomy.
-
nodeIsInternal(int)
- Returns true if node is an internal node.
-
nodeIsPolytomous(int)
- Returns true if the node is polytomous (has more than two daughters).
-
nodeIsSoft(int)
- Returns true if the node is a soft polytomy.
-
nodeIsTerminal(int)
- Returns true if node is a terminal node.
-
nodeOfBranchUR(int, int)
- Returns what node number in Mesquite's standard rooted sense corresponds to the anc-node branch.
-
nodeOfLabel(String)
- Finds the node with the given label
-
nodeOfLabel(String, boolean)
- Finds the node with the given label
-
nodeOfTaxonNumber(int)
- Returns the terminal node corresponding to the given taxon number; 0 if the taxon is not part of the tree.
-
nodesAreSisters(int, int)
- Returns true if branch1 and branch2 are sisters by their mother (i.e., primary parent).
-
numberAttachedSensitive(Class)
- Returns the number of sensitive attachments of the given class or a subclass
-
numberOfDaughtersOfNode(int)
- Returns the number of daughters of the node.
-
numberOfDichotomousTrees(int)
- returns the number of dichotomous trees with the passed number of terminal taxa.
-
numberOfInternalsInClade(int)
- Returns number of internal nodes in clade.
-
numberOfNodesInClade(int)
- Returns number of total nodes (internal and external) in clade.
-
numberOfParentsOfNode(int)
- Returns the number of parents of node.
-
numberOfTerminalsInClade(int)
- Returns number of terminal taxa in clade.
-
numberSelectedInClade(int)
- Returns the number of nodes selected in the clade
-
OK(Tree)
- Returns false if tree is null, has no nodes, or is locked.
-
okToDispose(Object, int)
- For MesquiteListener interface.
-
parentOfNode(int, int)
- Returns the indexTH parent of node.
-
parentsOfNode(int)
- Returns the array of parents of node.
-
previousSisterOfNode(int)
- Returns the node's sister immediately to the left.
-
readTree(String)
- Reads the tree description string and sets the tree object to store the tree described.
-
removeAllSensitives()
- Remove all objects from the sensitive attachments
-
removeFromSensitives(Object)
- Remove the object from the sensitive attachments
-
reroot(int, int, boolean)
- reroot the clade below node atNode.
-
rightmostTerminalOfNode(int)
- Returns the right-most terminal that is descendant from node.
-
sameTreeVersions(TreeReference, boolean, boolean)
-
-
scaleAllBranchLengths(double, boolean)
- Sets the branch length of node.
-
setAllBranchLengths(double, boolean)
- Sets the branch length of node.
-
setAsDefined(boolean)
-
-
setBranchLength(int, double, boolean)
- Sets the branch length of node.
-
setBranchLength(int, int, boolean)
- Sets the branch length of node (stored as a double internally).
-
setLocked()
- Locks the tree (Currently, not used properly!!!!).
-
setName(String)
- Sets the name of the tree.
-
setNameLock(boolean)
- Sets whether name is locked
-
setNodeLabel(String, int)
- Sets the node label to the passed string (doesn't copy string; just uses reference)
-
setParentOfNode(int, int, boolean)
- Sets par to be an additional parent of node.
-
setRooted(boolean, boolean)
- Sets whether tree is rooted.
-
setTaxonNumber(int, int, boolean)
- Sets the taxon number for the node.
-
setToClone(MesquiteTree)
- Sets this tree to be a clone of that passed.
-
setToDefaultBush(int, boolean)
- Sets the tree to be a default bush.
-
setToDefaultLadder(int, boolean)
- Sets the tree to be a default ladder.
-
setToFirstInSequence()
- Returns the first tree in the sequence of all possible trees (polytomies are set to first resolution)
-
setToNextInSequence()
- Returns the next tree in the sequence of all possible trees (polytomies are set to first resolution)
-
setTreeVector(TreeVector)
- Sets the tree vector to which the tree belongs.
-
shortestPathAboveNode(int, double)
- returns total of branchlengths from node up to shortest terminal, with unassigned lengths given value "perUnassignedLength"
-
snipClade(int, boolean)
- Excise node and clade above it from tree but leave the clade intact, in case it is to be attached elsewhere.
-
splitTerminal(int, int, boolean)
- Branches a terminal node off taxon number taxonNum, and assigns it taxon newNumber
-
sproutDaughter(int, boolean)
- Sprouts a new daughter from node and returns it.
-
standardize(int, boolean)
- Puts clade in standard arrangement, such that smaller clades to left,
and if sister clades have same number of terminals, then with one with lowest numbered terminal to left.
-
standardNumNodeSpaces(int)
- Returns the base numNodeSpaces used for a tree of numTaxa taxa; a convenient starting point for modules that need to allocate space
for storage for nodes but which don't yet have a tree in hand.
-
standardNumNodeSpaces(Taxa)
- Returns the base numNodeSpaces used for a tree for the passed taxa; a convenient starting point for modules that need to allocate space
for storage for nodes but which don't yet have a tree in hand.
-
tallestPathAboveNode(int)
- returns total of branchlengths from node up to tallest terminal
-
tallestPathAboveNode(int, double)
- returns total of branchlengths from node up to tallest terminal, with unassigned lengths given value "perUnassignedLength"
-
tallestPathAboveNodeUR(int, int)
- returns total of branchlengths from node up to tallest terminal
-
tallestPathAboveNodeUR(int, int, double)
- returns total of branchlengths from node up to tallest terminal
-
taxonInTree(int)
- Returns whether taxon is part of tree.
-
taxonNumberOfNode(int)
- Returns the taxon number of the node.
-
toExternal(int)
- Translates internal numbering system to external (currently, 0 based to 1 based)
-
toInternal(int)
- Translates external numbering system to internal (currently, 1 based to 0 based)
-
toString()
- Outputs as string; currently returns name if the tree exists, otherwise calls super.toString()
-
upToDateWithTaxa()
-
-
whichDaughter(int)
- Returns the index of the node among its sisters (i.e., if it is daughter number 0 of
its mother, 1, 2, etc.
-
whichDaughterDescendantOf(int, int)
- Returns if branchD is descendant of branchA, then which daughter of branchA does it descend from?
Returns 0 if not descendant.
-
writeTree()
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
numbers to refer to the taxa.
-
writeTree(int)
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
names or numbers to refer to the taxa, depending on the boolean parameter byNames.
-
writeTree(int, boolean)
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
names or numbers to refer to the taxa, depending on the boolean parameter byNames.
-
writeTree(int, boolean, boolean, boolean, boolean, String)
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
names or numbers to refer to the taxa, depending on the boolean parameter byNames.
-
writeTreeWithNodeNumbers()
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
numbers to refer to the taxa.
polytomyDefaultHard
public static boolean polytomyDefaultHard
- True if default behavior for polytomies is as hard polytomy
totalCreated
public static long totalCreated
- A counter of the total number of Trees created (for debugging/memory leaks)
totalDisposed
public static long totalDisposed
- A counter of the total number of Trees disposed (for debugging/memory leaks)
checkIntegrity
public static boolean checkIntegrity
- If true then after branch moves, etc., tree integrity is checked.
MesquiteTree
public MesquiteTree(mesquite.lib.Taxa taxa)
- The constructor, passed the Taxa on which the tree is based
MesquiteTree
public MesquiteTree(mesquite.lib.Taxa taxa,
int numTaxa,
int numNodeSpaces,
long taxaVersion)
- The constructor, passed the Taxa on which the tree is based. This initializer is used only for cloning,
as it prepares for an exact copy of the tree even if it's currently out of date
cloneTree
public mesquite.lib.MesquiteTree cloneTree()
- Returns a clone of the tree.
setToClone
public void setToClone(mesquite.lib.MesquiteTree tree)
- Sets this tree to be a clone of that passed.
upToDateWithTaxa
public boolean upToDateWithTaxa()
equalsCoreArrays
public boolean equalsCoreArrays(mesquite.lib.MesquiteTree tree)
- Returns true if passed tree has same core array storage (same root, mothers, firstDaughter, nextSister, taxonNumber).
standardNumNodeSpaces
public static int standardNumNodeSpaces(int numTaxa)
- Returns the base numNodeSpaces used for a tree of numTaxa taxa; a convenient starting point for modules that need to allocate space
for storage for nodes but which don't yet have a tree in hand.
standardNumNodeSpaces
public static int standardNumNodeSpaces(mesquite.lib.Taxa taxa)
- Returns the base numNodeSpaces used for a tree for the passed taxa; a convenient starting point for modules that need to allocate space
for storage for nodes but which don't yet have a tree in hand.
getID
public long getID()
- Returns the unique id number of this tree
getName
public java.lang.String getName()
- Returns the name of the tree, or "Untitled" if no name has been set.
setName
public void setName(java.lang.String name)
- Sets the name of the tree.
setNameLock
public void setNameLock(boolean lock)
- Sets whether name is locked
getTopologyVersion
public long getTopologyVersion()
- Returns topology version number of tree. Version number should be incremented with each change in topology.
getBranchLengthsVersion
public long getBranchLengthsVersion()
- Returns branch lengths version number of tree. Version number should be incremented with each change in branch lengths.
sameTreeVersions
public boolean sameTreeVersions(mesquite.lib.TreeReference tr,
boolean checkBranchLengths,
boolean exact)
getTreeReference
public mesquite.lib.TreeReference getTreeReference(mesquite.lib.TreeReference tr)
getTaxa
public mesquite.lib.Taxa getTaxa()
- Returns the Taxa to which the tree refers.
isCompatible
public boolean isCompatible(java.lang.Object obj,
mesquite.lib.MesquiteProject project,
mesquite.lib.EmployerEmployee prospectiveEmployer)
- returns true if object is set of taxa on which tree is based. For CompatibilityChecker interface
isDefined
public boolean isDefined()
setAsDefined
public void setAsDefined(boolean defined)
OK
public static boolean OK(mesquite.lib.Tree tree)
- Returns false if tree is null, has no nodes, or is locked.
setTreeVector
public void setTreeVector(mesquite.lib.TreeVector treeVector)
- Sets the tree vector to which the tree belongs.
getTreeVector
public mesquite.lib.TreeVector getTreeVector()
- Gets the tree vector to which the tree belongs.
dispose
public void dispose()
- Disconnects listeners
- Overrides:
- dispose in class mesquite.lib.Associable
doCommand
public java.lang.Object doCommand(java.lang.String commandName,
java.lang.String arguments,
mesquite.lib.CommandRecord commandRec,
mesquite.lib.CommandChecker checker)
- For Commandable interface; currently responds to set branch length messages and tree description writing
- Overrides:
- doCommand in class mesquite.lib.Associable
getRoot
public int getRoot()
- Returns the root of the tree (i.e., the most recent common ancestor of the terminal taxa in the tree.
getSubRoot
public int getSubRoot()
- Returns the subRoot of the tree (the mother of the most recent common ancestral node of the tree).
The subroot exists so that some traversals (including for drawing the root branch)
don't choke when they come to the root and look for an ancestor.
setRooted
public void setRooted(boolean rooted,
boolean notify)
- Sets whether tree is rooted.
getRooted
public boolean getRooted()
- Returns whether tree is rooted.
getNumTaxa
public int getNumTaxa()
- Returns the number of terminal taxa in the Taxa to which the tree refers. This is not necessarily the
number of terminal taxa in the tree itself (for that, call numberOfTerminalsInClade(root)).
getNumNodeSpaces
public int getNumNodeSpaces()
- Returns the number of node spaces available in storage arrays within tree object.
nodeExists
public boolean nodeExists(int node)
- Returns true if N is a valid node designation in tree.
inBounds
protected boolean inBounds(int node)
- Overriding method of Associable.
- Overrides:
- inBounds in class mesquite.lib.Associable
nodeIsInternal
public boolean nodeIsInternal(int node)
- Returns true if node is an internal node.
nodeIsTerminal
public boolean nodeIsTerminal(int node)
- Returns true if node is a terminal node.
taxonNumberOfNode
public int taxonNumberOfNode(int node)
- Returns the taxon number of the node. This is -1 if the node is internal,
the taxon number if terminal.
nodeOfTaxonNumber
public int nodeOfTaxonNumber(int taxonNum)
- Returns the terminal node corresponding to the given taxon number; 0 if the taxon is not part of the tree.
setTaxonNumber
public void setTaxonNumber(int node,
int num,
boolean notify)
- Sets the taxon number for the node. If the node is internal, the number should
be set to -1. Otherwise it should be set to the taxon corresponding to the node.
NOTE: this should be used with caution, since it doesn't check for tree integrity. Intended primarily
for internal use (with MesquiteTree).
motherOfNode
public int motherOfNode(int node)
- Returns the immediate ancestor of node (mother) if node is non-reticulate.
If node is reticulate, returns the first (primary) parent.
grandmotherOfNode
public int grandmotherOfNode(int node)
- Returns the node's mother's mother.
numberOfParentsOfNode
public int numberOfParentsOfNode(int node)
- Returns the number of parents of node.
parentOfNode
public int parentOfNode(int node,
int index)
- Returns the indexTH parent of node.
parentsOfNode
public int[] parentsOfNode(int node)
- Returns the array of parents of node. If node is not reticulate, the array returned contains
only the mother node.
setParentOfNode
public void setParentOfNode(int node,
int par,
boolean notify)
- Sets par to be an additional parent of node. Used to make reticulations. Currently there
is no way to subtract parents, nor to rearrange trees that contain reticulations.
descendantOf
public boolean descendantOf(int branchD,
int branchA)
- Returns true iff first branch is a descendant of second branch.
depthToAncestor
public int depthToAncestor(int branchD,
int branchA)
- Returns depth of second branch below first; -1 if not ancestral.
firstDaughterOfNode
public int firstDaughterOfNode(int node)
- Returns the first (left-most) daughter of node.
lastDaughterOfNode
public int lastDaughterOfNode(int node)
- Returns the right-most daughter of node.
daughtersOfNode
public int[] daughtersOfNode(int node)
- Returns the array of daughters of a node. Normally it will be best to cycle through the
daughters as shown in the recursion example in the documentation for the Tree class.
daughterOf
public boolean daughterOf(int branchD,
int branchA)
- Returns true if branchD is an immediate daughter of branchA
nodeIsFirstDaughter
public boolean nodeIsFirstDaughter(int node)
- Returns true if node is the first (leftmost) daughter of its mother.
whichDaughter
public int whichDaughter(int node)
- Returns the index of the node among its sisters (i.e., if it is daughter number 0 of
its mother, 1, 2, etc. (zero based).
indexedDaughterOfNode
public int indexedDaughterOfNode(int node,
int index)
- Returns the indexTH daughter of node (zero based).
numberOfDaughtersOfNode
public int numberOfDaughtersOfNode(int node)
- Returns the number of daughters of the node.
whichDaughterDescendantOf
public int whichDaughterDescendantOf(int branchD,
int branchA)
- Returns if branchD is descendant of branchA, then which daughter of branchA does it descend from?
Returns 0 if not descendant.
nextSisterOfNode
public int nextSisterOfNode(int node)
- Returns the node's sister immediately to the right. If the node has no
sister to the right, returns 0 (which is not a valid node designation).
previousSisterOfNode
public int previousSisterOfNode(int node)
- Returns the node's sister immediately to the left. If the node has no
sister to the right, returns 0 (which is not a valid node designation).
nodesAreSisters
public boolean nodesAreSisters(int branch1,
int branch2)
- Returns true if branch1 and branch2 are sisters by their mother (i.e., primary parent).
There is currently no method to return whether two nodes share at least one parent.
hasPolytomies
public boolean hasPolytomies(int node)
- Returns whether clade has polytomies.
nodeIsPolytomous
public boolean nodeIsPolytomous(int node)
- Returns true if the node is polytomous (has more than two daughters).
nodeIsHard
public boolean nodeIsHard(int node)
- Returns true if the node has one descendant, two, or is a hard polytomy.
nodeIsSoft
public boolean nodeIsSoft(int node)
- Returns true if the node is a soft polytomy.
numberOfNodesInClade
public int numberOfNodesInClade(int node)
- Returns number of total nodes (internal and external) in clade.
numberOfTerminalsInClade
public int numberOfTerminalsInClade(int node)
- Returns number of terminal taxa in clade.
numberOfInternalsInClade
public int numberOfInternalsInClade(int node)
- Returns number of internal nodes in clade.
leftmostTerminalOfNode
public int leftmostTerminalOfNode(int node)
- Returns the left-most terminal that is descendant from node.
rightmostTerminalOfNode
public int rightmostTerminalOfNode(int node)
- Returns the right-most terminal that is descendant from node.
getTerminalTaxa
public int[] getTerminalTaxa(int node)
- Returns list of terminal taxa of clade of node.
nodeInTree
public boolean nodeInTree(int sought)
- Returns whether node is part of tree. Differs from nodeExists by doing full recursion (more reliable, slower).
taxonInTree
public boolean taxonInTree(int taxonNum)
- Returns whether taxon is part of tree.
nodeInTraversal
public int nodeInTraversal(int index)
- Returns indexTH node in tree traversal
nodeInTraversal
public int nodeInTraversal(int index,
int cladeRoot)
- Returns indexTH node in traversal through clade
mrca
public int mrca(int branchA,
int branchB)
- Returns most recent common ancestor of two branches.
branchingAncestor
public int branchingAncestor(int node)
- Returns the closest ancestor that has more than one daughter.
branchingDescendant
public int branchingDescendant(int node)
- Returns the closest descendant that has more than one daughter, or is terminal.
nextAroundUR
public int nextAroundUR(int anc,
int node)
- Returns the next (clockwise) to node connected to anc. This is one of the UR procedures, designed
to allow unrooted style traversal through the tree
firstDaughterOfNodeUR
public int firstDaughterOfNodeUR(int anc,
int node)
- Returns the first (left-most) daughter of node in an UNROOTED sense where the node
is treated as descendant from anc. This is one of the UR procedures, designed
to allow unrooted style traversal through the tree
nextSisterOfNodeUR
public int nextSisterOfNodeUR(int ancAnc,
int anc,
int node)
- Returns the node's sister immediately to the right in an UNROOTED sense where the node
is treated as descendant from anc, which is descendant from ancAnc. If the node has no
sister to the right, returns 0 (which is not a valid node designation). This is one of the UR procedures, designed
to allow unrooted style traversal through the tree
lastDaughterOfNodeUR
public int lastDaughterOfNodeUR(int anc,
int node)
- Returns the first (left-most) daughter of node in an UNROOTED sense where the node
is treated as descendant from anc. This is one of the UR procedures, designed
to allow unrooted style traversal through the tree
nodeOfBranchUR
public int nodeOfBranchUR(int anc,
int node)
- Returns what node number in Mesquite's standard rooted sense corresponds to the anc-node branch.
hasBranchLengths
public boolean hasBranchLengths()
- Returns true if tree has branch lengths.
allLengthsAssigned
public boolean allLengthsAssigned()
- Returns true if tree has all nodes with branch lengths assigned.
getBranchLength
public double getBranchLength(int node)
- Returns the branch length of the node.
getBranchLength
public double getBranchLength(int node,
double ifUnassigned)
- Returns the branch length of the node. If the branch length is unassigned, pass back the double passed in
setAllBranchLengths
public void setAllBranchLengths(double length,
boolean notify)
- Sets the branch length of node.
scaleAllBranchLengths
public void scaleAllBranchLengths(double factor,
boolean notify)
- Sets the branch length of node.
setBranchLength
public void setBranchLength(int node,
int length,
boolean notify)
- Sets the branch length of node (stored as a double internally).
setBranchLength
public void setBranchLength(int node,
double length,
boolean notify)
- Sets the branch length of node.
branchLengthUnassigned
public boolean branchLengthUnassigned(int node)
- Returns whether branch length of node is unassigned.
tallestPathAboveNode
public double tallestPathAboveNode(int node)
- returns total of branchlengths from node up to tallest terminal
tallestPathAboveNodeUR
public double tallestPathAboveNodeUR(int anc,
int node)
- returns total of branchlengths from node up to tallest terminal
tallestPathAboveNodeUR
public double tallestPathAboveNodeUR(int anc,
int node,
double perUnassignedLength)
- returns total of branchlengths from node up to tallest terminal
tallestPathAboveNode
public double tallestPathAboveNode(int node,
double perUnassignedLength)
- returns total of branchlengths from node up to tallest terminal, with unassigned lengths given value "perUnassignedLength"
shortestPathAboveNode
public double shortestPathAboveNode(int node,
double perUnassignedLength)
- returns total of branchlengths from node up to shortest terminal, with unassigned lengths given value "perUnassignedLength"
readTree
public void readTree(java.lang.String TreeDescription)
- Reads the tree description string and sets the tree object to store the tree described.
setToDefaultBush
public void setToDefaultBush(int numTaxa,
boolean notify)
- Sets the tree to be a default bush.
setToDefaultLadder
public void setToDefaultLadder(int numTaxa,
boolean notify)
- Sets the tree to be a default ladder.
writeTree
public java.lang.String writeTree(int byWhat,
boolean associatedUseComments,
boolean includeBranchLengths,
boolean includeNodeLabels,
boolean zeroBased,
java.lang.String delimiter)
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
names or numbers to refer to the taxa, depending on the boolean parameter byNames.
toString
public java.lang.String toString()
- Outputs as string; currently returns name if the tree exists, otherwise calls super.toString()
- Overrides:
- toString in class java.lang.Object
writeTreeWithNodeNumbers
public java.lang.String writeTreeWithNodeNumbers()
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
numbers to refer to the taxa.
writeTree
public java.lang.String writeTree()
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
numbers to refer to the taxa.
writeTree
public java.lang.String writeTree(int byWhat)
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
names or numbers to refer to the taxa, depending on the boolean parameter byNames.
writeTree
public java.lang.String writeTree(int byWhat,
boolean associatedUseComments)
- Returns a string describing the tree in standard parenthesis notation (Newick standard), using taxon
names or numbers to refer to the taxa, depending on the boolean parameter byNames.
splitTerminal
public synchronized void splitTerminal(int taxonNum,
int newNumber,
boolean notify)
- Branches a terminal node off taxon number taxonNum, and assigns it taxon newNumber
sproutDaughter
public synchronized int sproutDaughter(int node,
boolean notify)
- Sprouts a new daughter from node and returns it.
standardize
public synchronized boolean standardize(int node,
boolean notify)
- Puts clade in standard arrangement, such that smaller clades to left,
and if sister clades have same number of terminals, then with one with lowest numbered terminal to left.
NOTE: in future will pass two booleans to control sort order
interchangeBranches
public synchronized boolean interchangeBranches(int node,
int otherNode,
boolean notify)
- Interchanges two branches of tree.
collapseBranch
public synchronized boolean collapseBranch(int node,
boolean notify)
- Collapses branch to yield polytomy.
collapseAllBranches
public synchronized boolean collapseAllBranches(int node,
boolean notify)
- Collapses all internal branches within clade above node, to yield bush.
deleteClade
public synchronized boolean deleteClade(int node,
boolean notify)
- Excise node and clade above it from tree, zeroing information at each node in clade.
snipClade
public synchronized boolean snipClade(int node,
boolean notify)
- Excise node and clade above it from tree but leave the clade intact, in case it is to be attached elsewhere.
graftTaxon
public synchronized boolean graftTaxon(int taxon,
int toN,
boolean notify)
- Attach terminal taxon to tree along given branch.
graftClade
public synchronized int graftClade(int fromN,
int toN,
boolean notify)
- Attach node fromN (and any clade to attached to it) along node toN. Returns the new node created to attach fromN
moveBranch
public synchronized boolean moveBranch(int branchFrom,
int branchTo,
boolean notify)
- Move branch so as to excise branchFrom from its current position, and attach it to branch beneath
node branchTo. If successful, rename as given (to ensure renamed before notified).
insertNode
public synchronized int insertNode(int node,
boolean notify)
- Inserts a new node on the branch represented by "node", and returns the number of the inserted node
reroot
public synchronized boolean reroot(int atNode,
int cladeRoot,
boolean notify)
- reroot the clade below node atNode.
makeAllRootings
public void makeAllRootings(int cladeRoot,
mesquite.lib.TreeVector trees)
- makes trees for all rootings of clade above node given, and places them into TreeVector
accumulateTerminals
public void accumulateTerminals(int node,
int terminals[],
mesquite.lib.MesquiteInteger next)
- Places into the passed array (which must have been sized correctly in advance) the taxon numbers in the clade
setToFirstInSequence
public void setToFirstInSequence()
- Returns the first tree in the sequence of all possible trees (polytomies are set to first resolution)
setToNextInSequence
public boolean setToNextInSequence()
- Returns the next tree in the sequence of all possible trees (polytomies are set to first resolution)
hasNodeLabels
public boolean hasNodeLabels()
- Returns whether the tree has node labels
setNodeLabel
public void setNodeLabel(java.lang.String s,
int node)
- Sets the node label to the passed string (doesn't copy string; just uses reference)
getNodeLabel
public java.lang.String getNodeLabel(int node)
- Gets the node label of the node
nodeHasLabel
public boolean nodeHasLabel(int node)
- Returns whether the node has a label
nodeOfLabel
public int nodeOfLabel(java.lang.String s)
- Finds the node with the given label
nodeOfLabel
public int nodeOfLabel(java.lang.String s,
boolean caseSensitive)
- Finds the node with the given label
isLocked
public boolean isLocked()
- Returns whether tree is locked.
setLocked
public void setLocked()
- Locks the tree (Currently, not used properly!!!!).
anySelectedInClade
public boolean anySelectedInClade(int node)
- Returns whether there are any selected nodes in the clade
numberSelectedInClade
public int numberSelectedInClade(int node)
- Returns the number of nodes selected in the clade
getFirstSelected
public int getFirstSelected(int node)
- Gets the first node selected in clade of node node
attachToSensitives
public void attachToSensitives(java.lang.Object obj)
- Attach the object to the sensitive attachments
removeFromSensitives
public void removeFromSensitives(java.lang.Object obj)
- Remove the object from the sensitive attachments
removeAllSensitives
public void removeAllSensitives()
- Remove all objects from the sensitive attachments
anyAttachedSensitive
public boolean anyAttachedSensitive(java.lang.Class c)
- Returns whether there are any sensitive attachments of the given class or a subclass
numberAttachedSensitive
public int numberAttachedSensitive(java.lang.Class c)
- Returns the number of sensitive attachments of the given class or a subclass
getAttachedSensitive
public java.lang.Object getAttachedSensitive(java.lang.Class c,
int index)
- Returns the indexTH sensitive attachment of the given class or a subclass
getListAttachedSensitives
public java.lang.String getListAttachedSensitives()
- Lists attached sensitives
changed
public void changed(java.lang.Object caller,
java.lang.Object obj,
int code,
int parameters[])
- For MesquiteListener interface. Passes which object changed, along with optional integer (e.g. for character)
disposing
public void disposing(java.lang.Object obj)
- For MesquiteListener interface. Passes which object was disposed
okToDispose
public boolean okToDispose(java.lang.Object obj,
int queryUser)
- For MesquiteListener interface. Asks whether it's ok to delete the object as far as the listener is concerned (e.g., is it in use?)
toExternal
public static int toExternal(int i)
- Translates internal numbering system to external (currently, 0 based to 1 based)
toInternal
public static int toInternal(int i)
- Translates external numbering system to internal (currently, 1 based to 0 based)
numberOfDichotomousTrees
public static java.math.BigInteger numberOfDichotomousTrees(int numTaxa)
- returns the number of dichotomous trees with the passed number of terminal taxa. At 12 this is greater than the maximum int.
All Packages Class Hierarchy This Package Previous Next Index