Package org.forester.phylogeny
Class PhylogenyNode
java.lang.Object
org.forester.phylogeny.PhylogenyNode
- All Implemented Interfaces:
 Comparable<PhylogenyNode>
Warning. Implementation of method 'compareTo' only looks at
 node name. Thus, use of this class in SortedSets might lead
 to unexpected behavior.
- 
Nested Class Summary
Nested Classes - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddAsChild(PhylogenyNode node) Adds PhylogenyNode n to the list of child nodes and sets the _parent of n to this.final intfinal doublefinal intfinal PhylogenyNodeReturns a new PhylogenyNode which has its data copied from this PhylogenyNode.final PhylogenyNodeReturns a new PhylogenyNode which has the same data as this PhylogenyNode.static PhylogenyNodestatic PhylogenyNodecreateInstanceFromNhxString(String nhx, NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction) static PhylogenyNodecreateInstanceFromNhxString(String nhx, NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction, boolean replace_underscores) final booleanfinal List<PhylogenyNode>final List<PhylogenyNode>Returns a List containing references to all external children of this PhylogenyNode.Returns a List containing references to all names of the external children of this PhylogenyNode.final BranchDatafinal PhylogenyNodegetChildNode(int i) This return child node n of this node.final PhylogenyNodeConvenience method.final PhylogenyNodeConvenience method.final intThis gets the child node index of this node.final intgetChildNodeIndex(PhylogenyNode parent) This gets the child node index of this node, given that parent is its parentfinal List<PhylogenyNode>final doubleReturns the length of the branch leading to the _parent of this PhylogenyNode (double).final PhylogenyNodeConvenience method.final longgetId()Returns the ID (int) of this PhylogenyNode.final byteReturns the _indicator value of this PhylogenyNode.final PhylogenyNodeConvenience method.final PhylogenyNodegetLink()Returns a refernce to the linked PhylogenyNode of this PhylogenyNode.final StringgetName()final PhylogenyNodeReturns a refernce to the next external PhylogenyNode of this PhylogenyNode.final PhylogenyNodestatic final longReturns the total number of all Nodes created so far.final NodeDatafinal intfinal intReturns the total number of external Nodes originating from this PhylogenyNode (int).final intfinal PhylogenyNodeReturns a refernce to the parent PhylogenyNode of this PhylogenyNode.final PhylogenyNodeReturns a refernce to the next external PhylogenyNode of this PhylogenyNode.final floatUsed for drawing of Trees.final floatfinal floatUsed for drawing of Trees.final floatfinal inthashCode()final booleanReturns whether this PhylogenyNode should be drawn as collapsed.final booleanReturns true if this PhylogenyNode represents a _duplication event, false otherwise.booleanisEmpty()final booleanChecks whether this PhylogenyNode is external (tip).final booleanfinal booleanfinal booleanReturns whether a _duplication or speciation event has been assigned for this PhylogenyNode.final booleanChecks whether this PhylogenyNode is internal (tip).final booleanReturns true if this node is the last child node of its _parent.final booleanfinal booleanisRoot()Checks whether this PhylogenyNode is a root.final booleanvoidPrints to the console the subtree originating from this PhylogenyNode in preorder.final voidremoveChildNode(int i) final voidremoveChildNode(PhylogenyNode remove_me) voidfinal voidsetBranchData(BranchData branch_data) final voidSets the first child PhylogenyNode of this PhylogenyNode to n.final voidSets the second child PhylogenyNode of this PhylogenyNode to n.final voidsetChildNode(int i, PhylogenyNode node) Inserts PhylogenyNode n at the specified position i into the list of child nodes.final voidsetCollapse(boolean b) Sets whether this PhylogenyNode should be drawn as collapsed.final voidsetDistanceToParent(double d) Sets the length of the branch leading to the _parent of this PhylogenyNode to double d.protected final voidsetId(long i) Sets the Id of this PhylogenyNode to i.final voidsetIndicator(byte i) Sets the _indicator value of this PhylogenyNode to i.final voidSets the linked PhylogenyNode of this PhylogenyNode to n.final voidSets the name of this node.final voidSets the _parent PhylogenyNode of this PhylogenyNode to n.final voidsetSumExtNodes(int i) Sets the total number of external Nodes originating from this PhylogenyNode to i (int).final voidsetXcoord(float x) Used for drawing of Trees.final voidsetXSecondary(float x_secondary) final voidsetYcoord(float y) Used for drawing of Trees.final voidsetYSecondary(float y_secondary) final voidSwaps the the two childern of a PhylogenyNode node of this Phylogeny.final StringtoNewHampshire(boolean write_distance_to_parent, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE svs) final StringConverts this PhylogenyNode to a New Hampshire X (NHX) String representation.final StringtoString() 
- 
Constructor Details
- 
PhylogenyNode
public PhylogenyNode()Default constructor for PhylogenyNode. - 
PhylogenyNode
 
 - 
 - 
Method Details
- 
addAsChild
Adds PhylogenyNode n to the list of child nodes and sets the _parent of n to this.- Parameters:
 n- the PhylogenyNode to add
 - 
calculateDepth
public final int calculateDepth() - 
calculateDistanceToRoot
public final double calculateDistanceToRoot() - 
compareTo
- Specified by:
 compareToin interfaceComparable<PhylogenyNode>
 - 
copyNodeData
Returns a new PhylogenyNode which has its data copied from this PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT copied (e.g. _link to _parent). Field "_link" IS copied.- See Also:
 
 - 
copyNodeDataShallow
Returns a new PhylogenyNode which has the same data as this PhylogenyNode. Links to the other Nodes in the same Phylogeny are NOT copied (e.g. _link to _parent). Field "_link" IS copied.- See Also:
 
 - 
equals
 - 
getAllDescendants
 - 
getAllExternalDescendants
Returns a List containing references to all external children of this PhylogenyNode.- Returns:
 - List of references to external Nodes
 
 - 
getAllExternalDescendantsNames
Returns a List containing references to all names of the external children of this PhylogenyNode.- Returns:
 - List of references to names of external Nodes
 
 - 
getBranchData
 - 
getChildNode
This return child node n of this node.- Parameters:
 n- the index of the child to get- Returns:
 - the child node with index n
 - Throws:
 IllegalArgumentException- if n is out of bounds
 - 
getChildNode1
Convenience method. Returns the first child PhylogenyNode of this PhylogenyNode. - 
getChildNode2
Convenience method. Returns the second child PhylogenyNode of this PhylogenyNode.[last modified May 18, 2005 by CMZ]
 - 
getChildNodeIndex
public final int getChildNodeIndex()This gets the child node index of this node.- Returns:
 - the child node index of this node
 - Throws:
 UnsupportedOperationException- if this node is a root node
 - 
getChildNodeIndex
This gets the child node index of this node, given that parent is its parent[last modified Aug 14, 2006 by CMZ]
- Returns:
 - the child node index of this node
 - Throws:
 UnsupportedOperationException- if this node is a root node
 - 
getDescendants
 - 
getDistanceToParent
public final double getDistanceToParent()Returns the length of the branch leading to the _parent of this PhylogenyNode (double). - 
getFirstChildNode
Convenience method. Returns the first child node of this node.[last modified May 18, 2005 by CMZ]
- Returns:
 - the first child node of this node
 
 - 
getId
public final long getId()Returns the ID (int) of this PhylogenyNode. - 
getIndicator
public final byte getIndicator()Returns the _indicator value of this PhylogenyNode. - 
getLastChildNode
Convenience method. Returns the last child node of this node.[last modified May 18, 2005 by CMZ]
- Returns:
 - the last child node of this node
 
 - 
getLink
Returns a refernce to the linked PhylogenyNode of this PhylogenyNode. Currently, this method is only used for the speciation-_duplication assignment algorithms. - 
getName
 - 
getNextExternalNode
Returns a refernce to the next external PhylogenyNode of this PhylogenyNode. TODO should be in Phylogeny. Returns null if no next external node is available. - 
getNextExternalNodeWhileTakingIntoAccountCollapsedNodes
 - 
getNodeData
 - 
getNumberOfDescendants
public final int getNumberOfDescendants() - 
getNumberOfExternalNodes
public final int getNumberOfExternalNodes()Returns the total number of external Nodes originating from this PhylogenyNode (int). - 
getNumberOfParents
public final int getNumberOfParents() - 
getParent
Returns a refernce to the parent PhylogenyNode of this PhylogenyNode. - 
getPreviousExternalNode
Returns a refernce to the next external PhylogenyNode of this PhylogenyNode. TODO should be in Phylogeny. Returns null if no next external node is available. - 
getXcoord
public final float getXcoord()Used for drawing of Trees. - 
getXSecondary
public final float getXSecondary() - 
getYcoord
public final float getYcoord()Used for drawing of Trees. - 
getYSecondary
public final float getYSecondary() - 
hashCode
public final int hashCode() - 
isCollapse
public final boolean isCollapse()Returns whether this PhylogenyNode should be drawn as collapsed. - 
isDuplication
public final boolean isDuplication()Returns true if this PhylogenyNode represents a _duplication event, false otherwise. - 
isEmpty
public boolean isEmpty() - 
isExternal
public final boolean isExternal()Checks whether this PhylogenyNode is external (tip).- Returns:
 - true if this PhylogenyNode is external, false otherwise
 
 - 
isFirstChildNode
public final boolean isFirstChildNode() - 
isFirstExternalNode
public final boolean isFirstExternalNode() - 
isHasAssignedEvent
public final boolean isHasAssignedEvent()Returns whether a _duplication or speciation event has been assigned for this PhylogenyNode. - 
isInternal
public final boolean isInternal()Checks whether this PhylogenyNode is internal (tip).- Returns:
 - true if this PhylogenyNode is external, false otherwise
 
 - 
isLastChildNode
public final boolean isLastChildNode()Returns true if this node is the last child node of its _parent.[last modified June 01, 2005 by CMZ]
- Returns:
 - true if this node is the last child node of its _parent, false otherwise
 
 - 
isLastExternalNode
public final boolean isLastExternalNode() - 
isRoot
public final boolean isRoot()Checks whether this PhylogenyNode is a root.- Returns:
 - true if this PhylogenyNode is the root, false otherwise
 
 - 
isSpeciation
public final boolean isSpeciation() - 
preorderPrint
public void preorderPrint()Prints to the console the subtree originating from this PhylogenyNode in preorder. - 
removeChildNode
public final void removeChildNode(int i)  - 
removeChildNode
 - 
removeConnections
public void removeConnections() - 
setBranchData
 - 
setChild1
Sets the first child PhylogenyNode of this PhylogenyNode to n. - 
setChild2
Sets the second child PhylogenyNode of this PhylogenyNode to n. - 
setChildNode
Inserts PhylogenyNode n at the specified position i into the list of child nodes. This does not allow null slots in the list of child nodes: If i is larger than the number of child nodes, n is just added to the list, not place at index i.- Parameters:
 i- the index of position where to add the childn- the PhylogenyNode to add
 - 
setCollapse
public final void setCollapse(boolean b) Sets whether this PhylogenyNode should be drawn as collapsed. - 
setDistanceToParent
public final void setDistanceToParent(double d) Sets the length of the branch leading to the _parent of this PhylogenyNode to double d. - 
setIndicator
public final void setIndicator(byte i) Sets the _indicator value of this PhylogenyNode to i. - 
setLink
Sets the linked PhylogenyNode of this PhylogenyNode to n. Currently, this method is only used for the speciation-_duplication assignment algorithms. - 
setName
Sets the name of this node. - 
setParent
Sets the _parent PhylogenyNode of this PhylogenyNode to n. - 
setSumExtNodes
public final void setSumExtNodes(int i) Sets the total number of external Nodes originating from this PhylogenyNode to i (int). - 
setXcoord
public final void setXcoord(float x) Used for drawing of Trees. - 
setXSecondary
public final void setXSecondary(float x_secondary)  - 
setYcoord
public final void setYcoord(float y) Used for drawing of Trees. - 
setYSecondary
public final void setYSecondary(float y_secondary)  - 
swapChildren
Swaps the the two childern of a PhylogenyNode node of this Phylogeny.- Throws:
 RuntimeException
 - 
toNewHampshire
public final String toNewHampshire(boolean write_distance_to_parent, PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE svs)  - 
toNewHampshireX
Converts this PhylogenyNode to a New Hampshire X (NHX) String representation. - 
toString
 - 
setId
protected final void setId(long i) Sets the Id of this PhylogenyNode to i. In most cases, this number should not be set to values lower than getNodeCount() -- which this method does not allow. - 
createInstanceFromNhxString
public static PhylogenyNode createInstanceFromNhxString(String nhx) throws NHXFormatException, PhyloXmlDataFormatException  - 
createInstanceFromNhxString
public static PhylogenyNode createInstanceFromNhxString(String nhx, NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction) throws NHXFormatException, PhyloXmlDataFormatException  - 
createInstanceFromNhxString
public static PhylogenyNode createInstanceFromNhxString(String nhx, NHXParser.TAXONOMY_EXTRACTION taxonomy_extraction, boolean replace_underscores) throws NHXFormatException, PhyloXmlDataFormatException  - 
getNodeCount
public static final long getNodeCount()Returns the total number of all Nodes created so far.- Returns:
 - total number of Nodes (long)
 
 
 -