softparsmap
Class SpeciesNode

java.lang.Object
  extended bysoftparsmap.Node
      extended bysoftparsmap.SpeciesNode
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
SpeciesLeaf

public class SpeciesNode
extends Node

Defines a species node in a species tree.


Constructor Summary
SpeciesNode(DataSource dataSource, int label)
          Constructs a species node given a data source and the label.
 
Method Summary
static SpeciesNode computeLca(java.util.Set species)
          Returns the last common ancestor of the given set of species nodes.
static SpeciesNode computeLca(SpeciesNode na, SpeciesNode nb)
          Returns the last common ancestor of the two given species nodes.
 DataSource getDataSource()
          Returns the data source for this species node.
 PropertyFile getPropertyFile()
          Returns the property file.
 Mutation inferMutation(GeneNode geneNode, boolean collapseWeakEdges, Inparalogous inparalogous)
          Infers duplications and loss using this species subtree.
 boolean isBelow(SpeciesNode s)
          Returns true if this node is below given node.
 boolean isOnSameRootPath(SpeciesNode s)
          Returns true if this node and the given node is on the same root path.
 java.util.List minimizeMutation(GeneNode geneTree, boolean collapseEdges, Inparalogous inparalogous)
          Returns a list of rooted gene trees.
static SpeciesNode nextNodeS(DataSource ds)
          Return the next unique labeled species node.
static SpeciesNode parseNewick(DataSource ds, java.lang.String treeText)
          Parse a string in Neiwck format with gene sequences in the inner bracket.
 int setPreorder()
          Preorder this tree will give every species node two numbers.
 java.lang.String toNewick()
          Returns the subtree in Newick format.
 
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, pruneOneChildNodes, removeChild, setMap, setNextUnique, toString, toStringAll, toStringTable, toStringTree
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpeciesNode

public SpeciesNode(DataSource dataSource,
                   int label)
Constructs a species node given a data source and the label.

Parameters:
dataSource - is the data source where the species tree was created.
label - is label of the species node
Method Detail

getDataSource

public DataSource getDataSource()
Returns the data source for this species node.

Returns:
the data source for this species node

getPropertyFile

public PropertyFile getPropertyFile()
Returns the property file.

Returns:
the property file

computeLca

public static SpeciesNode computeLca(java.util.Set species)
Returns the last common ancestor of the given set of species nodes. Assumes that setPreorder() has been run.

Parameters:
species - is a set of species nodes
Returns:
the last common ancestor of the given set of species

computeLca

public static SpeciesNode computeLca(SpeciesNode na,
                                     SpeciesNode nb)
Returns the last common ancestor of the two given species nodes.

Returns:
the last common ancestor of the species na and nb.

setPreorder

public int setPreorder()
Preorder this tree will give every species node two numbers. The methods isBelow(softparsmap.SpeciesNode) and isOnSameRootPath(softparsmap.SpeciesNode) are two methods that can be run in constant time after this method has been called.

Returns:
the last used number

isBelow

public boolean isBelow(SpeciesNode s)
Returns true if this node is below given node. Run time is constant.

Parameters:
s - is the given species node
Returns:
true if this node is below given node

isOnSameRootPath

public boolean isOnSameRootPath(SpeciesNode s)
Returns true if this node and the given node is on the same root path. That is, this method returns true if this node is below the given one, or the given one is below this, or its the same node.

Returns:
true if this node and the given node is on the same root path

minimizeMutation

public java.util.List minimizeMutation(GeneNode geneTree,
                                       boolean collapseEdges,
                                       Inparalogous inparalogous)
Returns a list of rooted gene trees. These trees are simple the given unrooted gene tree, mid-point rooted on different edges such that duplications and gene loss is the lowest possible and the same for all trees in the list. It is possible to allow weak edges to be collapsed if it will give lower mutation. Duplication is prioritized before gene loss. Edges will not be collapsed, just flagged collapsed. Inparalogous may also be removed before counting mutation.

Parameters:
geneTree - is the unrooted gene tree
collapseEdges - if true weak edges will be collapsed if it gives lower mutation
inparalogous - is the inparalogous handler
Returns:
a list of gene trees with the lowest possible number of duplications and gene loss.

inferMutation

public Mutation inferMutation(GeneNode geneNode,
                              boolean collapseWeakEdges,
                              Inparalogous inparalogous)
Infers duplications and loss using this species subtree. Duplications are prioritized before gene loss and the calculation of gene loss is approximative. The method will collapse weak edges if it will give a better result and in-paralogous can be removed before counting mutation. This method can only be called using the root of the species tree and the gene tree.

Parameters:
geneNode - is the rooted gene tree
collapseWeakEdges - if true the method will collapse weak edges when it gives lower mutation
inparalogous - is the inparalogous handler and decides if inparalogous should be removed before counting mutation
Returns:
the total number of duplications and loss

toNewick

public java.lang.String toNewick()
Returns the subtree in Newick format.

Returns:
the subtree in Newick format.

parseNewick

public static SpeciesNode parseNewick(DataSource ds,
                                      java.lang.String treeText)
Parse a string in Neiwck format with gene sequences in the inner bracket. Run program InferMutation to see an example.

Parameters:
ds - is the data source
treeText - is the species tree in text format
Returns:
the root for the new species tree

nextNodeS

public static SpeciesNode nextNodeS(DataSource ds)
Return the next unique labeled species node.

Returns:
The next unique labeled species node.