Package pal.tree
Class SimpleNode
java.lang.Object
pal.tree.SimpleNode
- All Implemented Interfaces:
Serializable
,AttributeNode
,Node
- Direct Known Subclasses:
PositionedNode
data structure for a node (includes branch) in a binary/non-binary
rooted/unrooted tree
- Version:
- $Id: SimpleNode.java,v 1.27 2003/10/19 02:35:26 matt Exp $
- Author:
- Korbinian Strimmer, Alexei Drummond
- See Also:
-
Field Summary
Fields inherited from interface pal.tree.AttributeNode
CLADE_PROBABILITY, MEAN_CLADE_HEIGHT, NODE_HEIGHT_SE, SUBTREE_PROBABILITY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionconstructor default nodeSimpleNode
(String name, double branchLength) SimpleNode
(Node n) constructor used to clone a node and all childrenprotected
SimpleNode
(Node[] children) protected
SimpleNode
(Node[] children, double branchLength) ConstructorSimpleNode
(Node n, boolean keepIds) SimpleNode
(Node n, LabelMapping lm) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add new child nodefinal Object
getAttribute
(String name) final Enumeration
final double
Get the length of the branch attaching this node to its parent.final double
Get the length SE of the branch attaching this node to its parent.getChild
(int n) get child nodefinal int
Returns the number of children this node has.final Identifier
Returns the identifier for this node.final double
Get the height of this node relative to the most recent node.int
return the index of this nodefinal Node
Returns the parent node of this node.byte[]
Returns the sequence at this node, in the form of an array of bytes.Returns the sequence at this node, in the form of a String.boolean
check whether this node is an internal nodeprotected void
protected void
Initialized node instance variables based on given Node.protected void
init
(Node n, boolean keepId, LabelMapping lm) Initialized node instance variables based on given Node.void
insertChild
(Node n, int pos) add new child node (insertion at a specific position)boolean
isLeaf()
check whether this node is an external nodeboolean
isRoot()
check whether this node is a root nodevoid
determines the height of this node and its descendants from branch lengths, assuming contemporaneous tips.removeChild
(int n) remove childfinal void
removes parent.void
reset()
final void
setAttribute
(String name, Object value) Sets a named attribute to the given value.final void
setBranchLength
(double value) Set the length of the branch attaching this node to its parent.final void
setBranchLengthSE
(double value) Set the length SE of the branch attaching this node to its parent.void
set child nodefinal void
Set identifier for this node.final void
setNodeHeight
(double value) Set the height of this node relative to the most recent node.final void
setNodeHeight
(double value, boolean adjustChildBranchLengths) Set the height of this node relative to the most recent node.void
setNumber
(int n) set the index of this nodevoid
Set the parent node of this node.void
setSequence
(byte[] s) Sets the sequence at this node, in the form of an array of bytes.toString()
-
Constructor Details
-
SimpleNode
public SimpleNode()constructor default node -
SimpleNode
-
SimpleNode
Constructor- Parameters:
children
-branchLength
-- Throws:
IllegalArgumentException
- if only one child!
-
SimpleNode
-
SimpleNode
constructor used to clone a node and all children -
SimpleNode
-
SimpleNode
-
-
Method Details
-
reset
public void reset() -
init
-
init
Initialized node instance variables based on given Node. children are ignored. -
init
Initialized node instance variables based on given Node. children are ignored.- Parameters:
lm
- - may be null
-
getParent
Returns the parent node of this node. -
setParent
Set the parent node of this node. -
removeParent
public final void removeParent()removes parent. -
getSequenceString
Returns the sequence at this node, in the form of a String. -
getSequence
public byte[] getSequence()Returns the sequence at this node, in the form of an array of bytes.- Specified by:
getSequence
in interfaceNode
-
setSequence
public void setSequence(byte[] s) Sets the sequence at this node, in the form of an array of bytes.- Specified by:
setSequence
in interfaceNode
-
getBranchLength
public final double getBranchLength()Get the length of the branch attaching this node to its parent.- Specified by:
getBranchLength
in interfaceNode
-
setBranchLength
public final void setBranchLength(double value) Set the length of the branch attaching this node to its parent.- Specified by:
setBranchLength
in interfaceNode
-
getBranchLengthSE
public final double getBranchLengthSE()Get the length SE of the branch attaching this node to its parent.- Specified by:
getBranchLengthSE
in interfaceNode
-
setBranchLengthSE
public final void setBranchLengthSE(double value) Set the length SE of the branch attaching this node to its parent.- Specified by:
setBranchLengthSE
in interfaceNode
-
getNodeHeight
public final double getNodeHeight()Get the height of this node relative to the most recent node.- Specified by:
getNodeHeight
in interfaceNode
-
setNodeHeight
public final void setNodeHeight(double value) Set the height of this node relative to the most recent node.- Specified by:
setNodeHeight
in interfaceNode
-
setNodeHeight
public final void setNodeHeight(double value, boolean adjustChildBranchLengths) Set the height of this node relative to the most recent node.- Specified by:
setNodeHeight
in interfaceNode
- Parameters:
adjustChildBranchLengths
- if true
-
getIdentifier
Returns the identifier for this node.- Specified by:
getIdentifier
in interfaceNode
-
setIdentifier
Set identifier for this node.- Specified by:
setIdentifier
in interfaceNode
-
setNumber
public void setNumber(int n) Description copied from interface:Node
set the index of this node -
getNumber
public int getNumber()Description copied from interface:Node
return the index of this node -
getChild
get child node -
setChild
set child node -
hasChildren
public boolean hasChildren()check whether this node is an internal node- Returns:
- result (true or false)
-
isLeaf
public boolean isLeaf()check whether this node is an external node -
isRoot
public boolean isRoot()check whether this node is a root node -
addChild
add new child node -
insertChild
add new child node (insertion at a specific position)- Specified by:
insertChild
in interfaceNode
- Parameters:
n
- new child node + @param pos position
-
removeChild
remove child- Specified by:
removeChild
in interfaceNode
- Parameters:
n
- number of child to be removed
-
lengths2HeightsContemp
public void lengths2HeightsContemp()determines the height of this node and its descendants from branch lengths, assuming contemporaneous tips. -
setAttribute
Sets a named attribute to the given value.- Specified by:
setAttribute
in interfaceAttributeNode
- Parameters:
name
- the name of the attributevalue
- the value to set the attribute
-
getAttribute
- Specified by:
getAttribute
in interfaceAttributeNode
- Parameters:
name
- the name of the attribute.- Returns:
- the attribute with the given name or null if it doesn't exist.
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceAttributeNode
- Returns:
- an enumeration of the attributes that this node has or null if the node has no attributes.
-
getChildCount
public final int getChildCount()Returns the number of children this node has.- Specified by:
getChildCount
in interfaceNode
-
toString
-