|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjebl.evolution.trees.SimpleRootedTree
public final class SimpleRootedTree
A simple, and initially immutable rooted tree implementation. All returned collections are defensively copied. The implementation of Node is private. A number of methods are provided that can be used to construct a tree (createExternalNode & createInternalNode).
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface jebl.evolution.graphs.Graph |
---|
Graph.NoEdgeException, Graph.Utils |
Constructor Summary | |
---|---|
SimpleRootedTree()
|
|
SimpleRootedTree(RootedTree tree)
Make a copy of the given rooted tree |
|
SimpleRootedTree(RootedTree tree,
java.util.Map<Node,Node> nodeMapping)
Make a copy of the given rooted tree |
|
SimpleRootedTree(Tree tree,
Node ingroupNode,
Node outgroupNode,
double ingroupBranchLength)
Make a copy of the given unrooted tree |
Method Summary | |
---|---|
Node |
addNode(Edge edge)
Adds a new node at the midpoint of the given edge |
Node |
addNode(Node node)
Adds a new node at the midpoint of the edge connecting the given node to its parent. |
boolean |
conceptuallyUnrooted()
Due to current implementation limitations, trees store "branch" information in nodes. |
Node |
createExternalNode(Taxon taxon)
Creates a new external node with the given taxon. |
jebl.evolution.trees.SimpleRootedTree.SimpleRootedNode |
createInternalNode(java.util.List<? extends Node> children)
Once a SimpleRootedTree has been created, the node stucture can be created by calling createExternalNode and createInternalNode. |
Node |
createNodes(RootedTree tree,
Node node)
Clones the entire tree structure from the given RootedTree. |
Node |
createNodes(Tree tree,
Node parent,
Node child)
Clones the entire tree structure from the given (unrooted) Tree. |
void |
deleteInternalNode(Node node)
Removes an internal node in this tree. |
java.util.List<Node> |
getAdjacencies(Node node)
Returns a list of nodes connected to this node by an edge |
java.lang.Object |
getAttribute(java.lang.String name)
|
java.util.Map<java.lang.String,java.lang.Object> |
getAttributeMap()
Gets the entire attribute map. |
java.util.Set<java.lang.String> |
getAttributeNames()
|
java.util.List<Node> |
getChildren(Node node)
|
Edge |
getEdge(Node node1,
Node node2)
Returns the Edge that connects these two nodes |
double |
getEdgeLength(Node node1,
Node node2)
Returns the length of the edge that connects these two nodes |
java.util.Set<Edge> |
getEdges()
|
java.util.List<Edge> |
getEdges(Node node)
Returns a list of edges connected to this node |
java.util.Set<Edge> |
getExternalEdges()
The set of external edges. |
java.util.Set<Node> |
getExternalNodes()
|
double |
getHeight(Node node)
|
java.util.Set<Edge> |
getInternalEdges()
The set of internal edges. |
java.util.Set<Node> |
getInternalNodes()
|
double |
getLength(Node node)
|
Node |
getNode(Taxon taxon)
|
java.util.Set<Node> |
getNodes()
|
Node[] |
getNodes(Edge edge)
Returns an array of 2 nodes which are the nodes at either end of the edge. |
java.util.Set<Node> |
getNodes(int degree)
|
Node |
getParent(Node node)
|
Edge |
getParentEdge(Node node)
|
Node |
getRootNode()
The root of the tree has the largest node height of all nodes in the tree. |
java.util.Set<Taxon> |
getTaxa()
|
Taxon |
getTaxon(Node node)
|
boolean |
hasHeights()
|
boolean |
hasLengths()
|
boolean |
isExternal(Node node)
|
boolean |
isRoot(Node node)
|
void |
removeAttribute(java.lang.String name)
|
void |
renameTaxa(Taxon from,
Taxon to)
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets an named attribute for this object. |
void |
setConceptuallyUnrooted(boolean intent)
|
void |
setHeight(Node node,
double height)
|
void |
setLength(Node node,
double length)
|
void |
swapNodes(Node n,
int i0,
int i1)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleRootedTree()
public SimpleRootedTree(RootedTree tree)
tree
- a rooted treepublic SimpleRootedTree(RootedTree tree, java.util.Map<Node,Node> nodeMapping)
tree
- a rooted treenodeMapping
- store {source tree node -> new tree node} mapping in here if non-nullpublic SimpleRootedTree(Tree tree, Node ingroupNode, Node outgroupNode, double ingroupBranchLength) throws Graph.NoEdgeException
tree
- an unrooted treeingroupNode
- the node on one side of the rootoutgroupNode
- the node on the other side of the rootingroupBranchLength
- the branch length from the root to the ingroup node
Graph.NoEdgeException
Method Detail |
---|
public Node createNodes(RootedTree tree, Node node)
tree
- node
-
public Node createNodes(Tree tree, Node parent, Node child) throws Graph.NoEdgeException
tree
- the unrooted treeparent
- the parent nodechild
- the child node
Graph.NoEdgeException
public Node createExternalNode(Taxon taxon)
taxon
- the taxon associated with this node
public jebl.evolution.trees.SimpleRootedTree.SimpleRootedNode createInternalNode(java.util.List<? extends Node> children)
children
- the child nodes of this nodes
public void deleteInternalNode(Node node)
node
- the node to remove.public Node addNode(Node node)
node
- must be a node in the tree, which has a parent
public Node addNode(Edge edge)
edge
-
public void swapNodes(Node n, int i0, int i1)
public void setHeight(Node node, double height)
node
- the node whose height is being setheight
- the heightpublic void setLength(Node node, double length)
node
- the node whose branch length (to its parent) is being setlength
- the lengthpublic java.util.List<Node> getChildren(Node node)
getChildren
in interface RootedTree
node
- the node whose children are being requested.
public boolean hasHeights()
hasHeights
in interface RootedTree
public double getHeight(Node node)
getHeight
in interface RootedTree
node
- the node whose height is being requested.
public boolean hasLengths()
hasLengths
in interface RootedTree
public double getLength(Node node)
getLength
in interface RootedTree
node
- the node whose branch length (to its parent) is being requested.
public Node getParent(Node node)
getParent
in interface RootedTree
node
- the node whose parent is requested
public Edge getParentEdge(Node node)
public Node getRootNode()
getRootNode
in interface RootedTree
public java.util.Set<Node> getExternalNodes()
getExternalNodes
in interface Tree
public java.util.Set<Node> getInternalNodes()
getInternalNodes
in interface Tree
public java.util.Set<Taxon> getTaxa()
getTaxa
in interface Tree
public Taxon getTaxon(Node node)
getTaxon
in interface Tree
node
- the node whose associated taxon is being requested.
public boolean isExternal(Node node)
isExternal
in interface Tree
node
- the node
public Node getNode(Taxon taxon)
getNode
in interface Tree
taxon
- the taxon
public void renameTaxa(Taxon from, Taxon to)
renameTaxa
in interface Tree
public java.util.List<Edge> getEdges(Node node)
getEdges
in interface Graph
node
-
public java.util.List<Node> getAdjacencies(Node node)
Graph
getAdjacencies
in interface Graph
node
-
public Edge getEdge(Node node1, Node node2) throws Graph.NoEdgeException
getEdge
in interface Graph
node1
- node2
-
Graph.NoEdgeException
- if the nodes are not directly connected by an edge.public double getEdgeLength(Node node1, Node node2) throws Graph.NoEdgeException
Graph
getEdgeLength
in interface Graph
node1
- node2
-
Graph.NoEdgeException
- if the nodes are not directly connected by an edge.public Node[] getNodes(Edge edge)
getNodes
in interface Graph
edge
-
public java.util.Set<Node> getNodes()
getNodes
in interface Graph
public java.util.Set<Edge> getEdges()
getEdges
in interface Graph
public java.util.Set<Edge> getExternalEdges()
getExternalEdges
in interface Tree
public java.util.Set<Edge> getInternalEdges()
getInternalEdges
in interface Tree
public java.util.Set<Node> getNodes(int degree)
getNodes
in interface Graph
degree
- the number of edges connected to a node
public void setConceptuallyUnrooted(boolean intent)
public boolean conceptuallyUnrooted()
RootedTree
conceptuallyUnrooted
in interface RootedTree
public boolean isRoot(Node node)
isRoot
in interface RootedTree
node
- the node
public void setAttribute(java.lang.String name, java.lang.Object value)
Attributable
setAttribute
in interface Attributable
name
- the name of the attribute.value
- the new value of the attribute.public java.lang.Object getAttribute(java.lang.String name)
getAttribute
in interface Attributable
name
- the name of the attribute of interest, or null if the attribute doesn't exist.
public void removeAttribute(java.lang.String name)
removeAttribute
in interface Attributable
name
- name of attribute to removepublic java.util.Set<java.lang.String> getAttributeNames()
getAttributeNames
in interface Attributable
public java.util.Map<java.lang.String,java.lang.Object> getAttributeMap()
Attributable
getAttributeMap
in interface Attributable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |