softparsmap
Class GeneNode

java.lang.Object
  extended bysoftparsmap.Node
      extended bysoftparsmap.GeneNode
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
GeneLeaf, MuNode

public class GeneNode
extends Node

Defines a gene node in a gene tree.


Constructor Summary
GeneNode(EdgeType edgeType, int label)
          Constructs a gene node given an edge type and a label.
GeneNode(EdgeType edgeType, int label, double edge)
          Constructs a gene node given an edge type, edge value, and label.
 
Method Summary
 GeneNode cloneNode()
          Returns a copy of this GeneNode.
 GeneNode cloneTree()
          Returns a copy of this subtree.
 java.util.Set collapsedEdges()
          Return all nodes in the subtree where their collapse flag is set to true.
 void collapseEdges()
          Collapsing all edges in this subtree where the collapsed flag is set.
 int countDuplications()
          Returns the number of duplications in this subtree.
 int countGeneLosses()
          Returns the number of losses in this subtree.
 Mutation countMutation()
          Returns the number of duplications and losses in this subtree.
 int countStrongEdges()
          Counting the number of strong edges in this subtree.
 boolean duplicatedNode()
          Returns true if this node is duplicated.
 GeneLeaf findLeaf(GeneLeaf leaf)
          Returns the leaf with the same label as given leaf.
 GeneLeaf findLeaf(int label)
          Returns the leaf with given label.
 GeneNode findNode(GeneNode node)
          Returns the gene node that exists in this subtree and has the same label.
 GeneNode findNodeForUnrootedSplit(java.util.Set splitLeavesA, java.util.Set splitLeavesB)
          Returns the gene node that harbor the split that contain the leaf set 'splitLeavesA'.
 ChildIterator getChildIterator()
          Returns the child iterator for this node.
 boolean getCollapsedEdge()
          Returns true if the node is flagged collapsed.
 java.util.Set getDuplicatedNodes()
          Returns the set of all duplicated nodes in this subtree.
 int getDuplicationsNode()
          Returns the number of duplications this node causes given a species tree.
 EdgeType getEdgeType()
          Returns the edge type of the edge that belong to this node.
 double getEdgeValue()
          Returns the edge value.
 Family getFamily()
          Returns the family that this node belongs to.
 int getGeneLossesNode()
          Returns the number of gene losses this node causes given a species tree.
 java.util.Set getInternalNodes()
          Return all internal nodes in this subtree.
 SpeciesNode getM()
          See the m-map in the article.
 java.util.Set getMM()
          See the M-map in the article.
 PropertyFile getPropertyFile()
          Returns the property file.
 java.util.Set getSL()
          See the SL function in the article.
 boolean hasFamily()
          Returns true if this node has a family.
 boolean hasM()
          Returns true if M has been set.
 boolean hasMM()
          Returns true if the M-map has been set.
 boolean hasSL()
          Returns true if SL has been set.
 void insertSpeciesTreeSplits()
          Insert splits from the species tree if it does not increase the minimum number of duplications and gene loss.
 boolean isEdgeWeak()
          Returns true if the edge for this node is weak, else false.
static GeneNode nextNode(EdgeType edgeType)
          Return the next unique node with given edge type.
static GeneNode nextNode(EdgeType edgeType, double value)
          Returns the next unique node with edge with give value and edge type.
 Node pruneOneChildNodes()
          Collapsing all internal nodes with only one child node.
 GeneNode reroot()
          Re-rooting the gene tree that this gene tree is a part of, using midpoint re-rooting.
 GeneNode rerootThis()
          Re-rooting the gene tree that this node is a part of.
 GeneNode resolveUncertainties(GeneNode originalTree)
          Try to resolve all uncertainties in this rooted gene tree using the original unrooted gene tree.
 boolean rootedEquals(GeneNode root)
          Returns true if this subtrees have the same rooted topology as the given subtree.
 GeneNode setCollapsedEdge(boolean collapsedEdge)
          Sets the collapsed flag to given value.
 GeneNode setEdge(EdgeType edgeType, double edge)
          Sets the edge type and edge value for this node.
 GeneNode setEdgeType(EdgeType edgeType)
          Sets the edge type for this node.
 GeneNode setEdgeValue(double edge)
          Sets the edge value for the edge that belongs to this node.
 void setFamily(Family family)
          Sets the family that this node belongs to.
 void setFamilyTree(Family family)
          Sets the family for this subtree.
 void setNewLabel()
          Reassigns the label of this node to a new unique number.
 
Methods inherited from class softparsmap.Node
addChild, compareTo, equals, findLCA, getChildren, getLabel, getLeaves, getMap, getNodes, getParent, getRoot, getSplits, hasChildren, hashCode, isBinaryTree, isConsistentWith, isRoot, nextUnique, numChildren, removeChild, setMap, setNextUnique, toString, toStringAll, toStringTable, toStringTree
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneNode

public GeneNode(EdgeType edgeType,
                int label)
Constructs a gene node given an edge type and a label.

Parameters:
edgeType - is the edge type that the edge of this node belong to.
label - is the label of this node
See Also:
EdgeType

GeneNode

public GeneNode(EdgeType edgeType,
                int label,
                double edge)
Constructs a gene node given an edge type, edge value, and label.

Parameters:
edgeType - is the edge type that the edge of this node belong to.
label - is the label of this node
edge - is the edge value of this node
See Also:
EdgeType
Method Detail

getFamily

public Family getFamily()
Returns the family that this node belongs to.

Returns:
the family that this node belongs to
See Also:
Family

setFamily

public void setFamily(Family family)
Sets the family that this node belongs to.

Parameters:
family - is the family that this node belong to

setFamilyTree

public void setFamilyTree(Family family)
Sets the family for this subtree.

Parameters:
family - is the family for this subtree

hasFamily

public boolean hasFamily()
Returns true if this node has a family.

Returns:
true if this node has a family

resolveUncertainties

public GeneNode resolveUncertainties(GeneNode originalTree)
Try to resolve all uncertainties in this rooted gene tree using the original unrooted gene tree. A new tree will be created. This method can only be called on the root of the tree, else a FatalException will be thrown.

Parameters:
originalTree - is the original unrooted gene tree.
Returns:
the root of the new tree

getEdgeType

public EdgeType getEdgeType()
Returns the edge type of the edge that belong to this node.

Returns:
the edge type of the edge that belong to this node

getPropertyFile

public PropertyFile getPropertyFile()
Returns the property file.

Returns:
the property file

findNodeForUnrootedSplit

public GeneNode findNodeForUnrootedSplit(java.util.Set splitLeavesA,
                                         java.util.Set splitLeavesB)
Returns the gene node that harbor the split that contain the leaf set 'splitLeavesA'.

Parameters:
splitLeavesA - is the first set that defines a split
splitLeavesB - is the second set that defines a split
Returns:
a gene node that harbor the split
See Also:
GeneLeaf

collapseEdges

public void collapseEdges()
Collapsing all edges in this subtree where the collapsed flag is set.


insertSpeciesTreeSplits

public void insertSpeciesTreeSplits()
Insert splits from the species tree if it does not increase the minimum number of duplications and gene loss.


setNewLabel

public void setNewLabel()
Reassigns the label of this node to a new unique number.

Returns:
this node for chaining

getInternalNodes

public java.util.Set getInternalNodes()
Return all internal nodes in this subtree.

Returns:
a set of gene nodes.

countStrongEdges

public int countStrongEdges()
Counting the number of strong edges in this subtree. If this node is a root will NOT be counted.

Returns:
the number of strong edges in this subtree.

collapsedEdges

public java.util.Set collapsedEdges()
Return all nodes in the subtree where their collapse flag is set to true.

Returns:
a set of nodes.

cloneNode

public GeneNode cloneNode()
Returns a copy of this GeneNode. Does not connect it to any other node.

Returns:
The copy.

cloneTree

public GeneNode cloneTree()
Returns a copy of this subtree.

Returns:
the root of the new subtree

findLeaf

public GeneLeaf findLeaf(int label)
Returns the leaf with given label. The search will only be done in this subtree.

Parameters:
label - is a label
Returns:
a leaf with given label. Null if not found
See Also:
GeneLeaf

findLeaf

public GeneLeaf findLeaf(GeneLeaf leaf)
Returns the leaf with the same label as given leaf. The search will only be done in this subtree.

Parameters:
leaf - is the leaf
Returns:
a leaf that has the same label as the given leaf. Null if not found.
See Also:
GeneLeaf

findNode

public GeneNode findNode(GeneNode node)
Returns the gene node that exists in this subtree and has the same label.

Parameters:
node - the node to look for.
Returns:
the gene node that exists in this subtree and has the same label.

reroot

public GeneNode reroot()
Re-rooting the gene tree that this gene tree is a part of, using midpoint re-rooting. It is dependent on the method rerootThis().

Returns:
the new root of the tree.

rerootThis

public GeneNode rerootThis()
Re-rooting the gene tree that this node is a part of. This gene node will be the root when finished.

Returns:
the root of the re-rooted tree.

rootedEquals

public boolean rootedEquals(GeneNode root)
Returns true if this subtrees have the same rooted topology as the given subtree.

Parameters:
root - is the root of the subtree that this subtree will be compared against
Returns:
true if their rooted topology is identical, else false

setEdgeValue

public GeneNode setEdgeValue(double edge)
Sets the edge value for the edge that belongs to this node.

Parameters:
edge - is the new edge value.
Returns:
this for chaining

setEdge

public GeneNode setEdge(EdgeType edgeType,
                        double edge)
Sets the edge type and edge value for this node.

Parameters:
edgeType - is the edge type
edge - is the new edge value
Returns:
this for chaining

setEdgeType

public GeneNode setEdgeType(EdgeType edgeType)
Sets the edge type for this node.

Parameters:
edgeType - is the edge type for this node
Returns:
this for chaining

getDuplicationsNode

public int getDuplicationsNode()
Returns the number of duplications this node causes given a species tree.

Returns:
the number of duplications

getGeneLossesNode

public int getGeneLossesNode()
Returns the number of gene losses this node causes given a species tree.

Returns:
the number of gene losses

duplicatedNode

public boolean duplicatedNode()
Returns true if this node is duplicated.

Returns:
the same as getDuplicationsNode()>0

getM

public SpeciesNode getM()
See the m-map in the article.

Returns:
the mapped species node

hasM

public boolean hasM()
Returns true if M has been set.

Returns:
true if M has been set

getMM

public java.util.Set getMM()
See the M-map in the article.

Returns:
a set of species nodes.
See Also:
SpeciesNode

hasMM

public boolean hasMM()
Returns true if the M-map has been set.

Returns:
true if the M-map has been set

getSL

public java.util.Set getSL()
See the SL function in the article.

Returns:
a set of species nodes.
See Also:
SpeciesNode

hasSL

public boolean hasSL()
Returns true if SL has been set.

Returns:
true if SL has been set

getChildIterator

public ChildIterator getChildIterator()
Returns the child iterator for this node.

Returns:
a child iterator.
See Also:
ChildIterator

countMutation

public Mutation countMutation()
Returns the number of duplications and losses in this subtree.

Returns:
the number of duplications and losses in this subtree.

countGeneLosses

public int countGeneLosses()
Returns the number of losses in this subtree.

Returns:
the number of losses in this subtree.

countDuplications

public int countDuplications()
Returns the number of duplications in this subtree.

Returns:
the number of duplications in this subtree.

getDuplicatedNodes

public java.util.Set getDuplicatedNodes()
Returns the set of all duplicated nodes in this subtree.

Returns:
the set of all duplicated nodes in this subtree

setCollapsedEdge

public GeneNode setCollapsedEdge(boolean collapsedEdge)
Sets the collapsed flag to given value.

Parameters:
collapsedEdge - is new value of the collapsed flag
Returns:
this gene node for chaining.

getCollapsedEdge

public boolean getCollapsedEdge()
Returns true if the node is flagged collapsed.

Returns:
the collapsed flag attribute.

getEdgeValue

public double getEdgeValue()
Returns the edge value.

Returns:
the edge value

pruneOneChildNodes

public Node pruneOneChildNodes()
Collapsing all internal nodes with only one child node. Replacing the same method in Node in order to join edges when removing a node with one child.

Overrides:
pruneOneChildNodes in class Node
Returns:
the new root.

isEdgeWeak

public boolean isEdgeWeak()
Returns true if the edge for this node is weak, else false.

Returns:
true if the edge for this node is weak, else false.

nextNode

public static GeneNode nextNode(EdgeType edgeType,
                                double value)
Returns the next unique node with edge with give value and edge type.

Parameters:
value - is the edge value
edgeType - is the edge type
Returns:
the new gene node.

nextNode

public static GeneNode nextNode(EdgeType edgeType)
Return the next unique node with given edge type.

Returns:
the new gene node.