pal.tree
Class SimpleNode

java.lang.Object
  extended by pal.tree.SimpleNode
All Implemented Interfaces:
java.io.Serializable, AttributeNode, Node
Direct Known Subclasses:
PositionedNode

public class SimpleNode
extends java.lang.Object
implements AttributeNode

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:
Serialized Form

Field Summary
 
Fields inherited from interface pal.tree.AttributeNode
CLADE_PROBABILITY, MEAN_CLADE_HEIGHT, NODE_HEIGHT_SE, SUBTREE_PROBABILITY
 
Constructor Summary
  SimpleNode()
          constructor default node
  SimpleNode(Node n)
          constructor used to clone a node and all children
protected SimpleNode(Node[] children)
           
protected SimpleNode(Node[] children, double branchLength)
          Constructor
  SimpleNode(Node n, boolean keepIds)
           
  SimpleNode(Node n, LabelMapping lm)
           
  SimpleNode(java.lang.String name, double branchLength)
           
 
Method Summary
 void addChild(Node n)
          add new child node
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 double getBranchLength()
          Get the length of the branch attaching this node to its parent.
 double getBranchLengthSE()
          Get the length SE of the branch attaching this node to its parent.
 Node getChild(int n)
          get child node
 int getChildCount()
          Returns the number of children this node has.
 Identifier getIdentifier()
          Returns the identifier for this node.
 double getNodeHeight()
          Get the height of this node relative to the most recent node.
 int getNumber()
          return the index of this node
 Node getParent()
          Returns the parent node of this node.
 byte[] getSequence()
          Returns the sequence at this node, in the form of an array of bytes.
 java.lang.String getSequenceString()
          Returns the sequence at this node, in the form of a String.
 boolean hasChildren()
          check whether this node is an internal node
protected  void init(Node n)
           
protected  void init(Node n, boolean keepId)
          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 node
 boolean isRoot()
          check whether this node is a root node
 void lengths2HeightsContemp()
          determines the height of this node and its descendants from branch lengths, assuming contemporaneous tips.
 Node removeChild(int n)
          remove child
 void removeParent()
          removes parent.
 void reset()
           
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets a named attribute to the given value.
 void setBranchLength(double value)
          Set the length of the branch attaching this node to its parent.
 void setBranchLengthSE(double value)
          Set the length SE of the branch attaching this node to its parent.
 void setChild(int n, Node node)
          set child node
 void setIdentifier(Identifier id)
          Set identifier for this node.
 void setNodeHeight(double value)
          Set the height of this node relative to the most recent node.
 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 node
 void setParent(Node node)
          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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleNode

public SimpleNode()
constructor default node


SimpleNode

public SimpleNode(java.lang.String name,
                  double branchLength)

SimpleNode

protected SimpleNode(Node[] children,
                     double branchLength)
Constructor

Parameters:
children -
branchLength -
Throws:
java.lang.IllegalArgumentException - if only one child!

SimpleNode

protected SimpleNode(Node[] children)

SimpleNode

public SimpleNode(Node n)
constructor used to clone a node and all children


SimpleNode

public SimpleNode(Node n,
                  boolean keepIds)

SimpleNode

public SimpleNode(Node n,
                  LabelMapping lm)
Method Detail

reset

public void reset()

init

protected void init(Node n)

init

protected void init(Node n,
                    boolean keepId)
Initialized node instance variables based on given Node. children are ignored.


init

protected void init(Node n,
                    boolean keepId,
                    LabelMapping lm)
Initialized node instance variables based on given Node. children are ignored.

Parameters:
lm - - may be null

getParent

public final Node getParent()
Returns the parent node of this node.

Specified by:
getParent in interface Node

setParent

public void setParent(Node node)
Set the parent node of this node.

Specified by:
setParent in interface Node

removeParent

public final void removeParent()
removes parent.


getSequenceString

public java.lang.String 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 interface Node

setSequence

public void setSequence(byte[] s)
Sets the sequence at this node, in the form of an array of bytes.

Specified by:
setSequence in interface Node

getBranchLength

public final double getBranchLength()
Get the length of the branch attaching this node to its parent.

Specified by:
getBranchLength in interface Node

setBranchLength

public final void setBranchLength(double value)
Set the length of the branch attaching this node to its parent.

Specified by:
setBranchLength in interface Node

getBranchLengthSE

public final double getBranchLengthSE()
Get the length SE of the branch attaching this node to its parent.

Specified by:
getBranchLengthSE in interface Node

setBranchLengthSE

public final void setBranchLengthSE(double value)
Set the length SE of the branch attaching this node to its parent.

Specified by:
setBranchLengthSE in interface Node

getNodeHeight

public final double getNodeHeight()
Get the height of this node relative to the most recent node.

Specified by:
getNodeHeight in interface Node

setNodeHeight

public final void setNodeHeight(double value)
Set the height of this node relative to the most recent node.

Specified by:
setNodeHeight in interface Node

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 interface Node
Parameters:
adjustChildBranchLengths - if true

getIdentifier

public final Identifier getIdentifier()
Returns the identifier for this node.

Specified by:
getIdentifier in interface Node

setIdentifier

public final void setIdentifier(Identifier id)
Set identifier for this node.

Specified by:
setIdentifier in interface Node

setNumber

public void setNumber(int n)
Description copied from interface: Node
set the index of this node

Specified by:
setNumber in interface Node

getNumber

public int getNumber()
Description copied from interface: Node
return the index of this node

Specified by:
getNumber in interface Node

getChild

public Node getChild(int n)
get child node

Specified by:
getChild in interface Node
Parameters:
n - number of child
Returns:
child node

setChild

public void setChild(int n,
                     Node node)
set child node

Specified by:
setChild in interface Node
Parameters:
n - number

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

Specified by:
isLeaf in interface Node
Returns:
result (true or false)

isRoot

public boolean isRoot()
check whether this node is a root node

Specified by:
isRoot in interface Node
Returns:
result (true or false)

addChild

public void addChild(Node n)
add new child node

Specified by:
addChild in interface Node
Parameters:
n - new child node

insertChild

public void insertChild(Node n,
                        int pos)
add new child node (insertion at a specific position)

Specified by:
insertChild in interface Node
Parameters:
n - new child node + @param pos position

removeChild

public Node removeChild(int n)
remove child

Specified by:
removeChild in interface Node
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

public final void setAttribute(java.lang.String name,
                               java.lang.Object value)
Sets a named attribute to the given value.

Specified by:
setAttribute in interface AttributeNode
Parameters:
name - the name of the attribute
value - the value to set the attribute

getAttribute

public final java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface AttributeNode
Parameters:
name - the name of the attribute.
Returns:
the attribute with the given name or null if it doesn't exist.

getAttributeNames

public final java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface AttributeNode
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 interface Node

toString

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