public class Tree
extends java.lang.Object
This class contains every general method appliable to every type of trees, including pretreatment methods and fields to make quick comparisons.
A tree is defined recursively by a node. A node can be summered by a label, a length and a list of sons. So, the concept of node and tree are the same in this package.
The only supported format is the newick format. To construct trees from others format, please use the TreeReader class.
Modifier and Type | Field and Description |
---|---|
java.util.Hashtable |
allowedLeft
Allowed left constraints for tree pattern definition
|
java.util.Hashtable |
allowedRight
Allowed right constraints for tree pattern definition
|
Tree |
father
The father of this node.
|
java.util.Hashtable |
forbiddenLeft
v left constraints for tree pattern definition
|
java.util.Hashtable |
forbiddenRight
Forbidden right constraints for tree pattern definition
|
boolean |
hasLeftConstraint
Existence of right and left constraints
|
boolean |
hasRightConstraint |
java.lang.String |
label
The label of a node.
|
java.util.Hashtable |
leafHashtable
Hashtable containing leaf labels as keys, and leaves as information.
|
java.util.Vector |
leafVector
Vector containing leaves, in order to quickly be able to access them without step into the tree.
|
double |
length
The length of the branch upper this node.
|
double |
maxDepth
Precomputed max depth
|
java.lang.String |
nhx
The NHX String.
|
java.util.Vector |
patternSpecies
Allowed species for this pattern node / leaf
|
int |
rightCardinalityMax
Minimum cardinality for tree patter definition
|
int |
rightCardinalityMin
Minimum cardinality for tree patter definition
|
java.util.Vector |
sons
List of sons of this node.
|
java.lang.String |
stringLength |
boolean |
ultra
True if this node is an ultraparalogy node.
|
Constructor and Description |
---|
Tree(java.lang.String newick)
Generic constructor of a tree, from a newick string
|
Tree(Tree source)
Cloning contructor, clone only basic fields, not the pretreatment fields
|
Tree(java.util.Vector sons,
java.lang.String label,
double length,
java.lang.String nhx)
Generic constructor of a node, directly from fields
|
Tree(java.util.Vector sons,
java.lang.String label,
double length,
java.lang.String stringLength,
java.lang.String nhx)
Generic constructor of a node, directly from fields
|
Modifier and Type | Method and Description |
---|---|
void |
addSpeciations()
Add speciation events into every node
|
void |
addUniquePrefix()
Add prefixes to nodes in order to obtain unique ids as labels
|
void |
clusteringNodes(java.util.Vector trees,
double threshold)
Fill a vector with nodes under a depth threshold
|
boolean |
colorPattern(Tree pattern,
Tree rootPattern,
java.util.Hashtable ind,
SpeciesDictionary dic,
java.util.Vector colored,
java.util.Hashtable stickers)
Tree pattern coloration
|
java.util.Hashtable |
computeExpansion(java.util.Hashtable d,
java.util.Hashtable unrepresented)
Return a table of the expansion for each node of this species tree
|
boolean |
containsPattern(Tree pattern,
java.util.Hashtable ind,
SpeciesDictionary dic)
Tree pattern detection
|
java.util.Hashtable |
countCopies(java.util.Hashtable d,
java.util.Hashtable l)
Return a table of the number of ancestral copies for each node of this species tree
|
boolean |
exclude(java.util.Vector list,
java.util.Hashtable table,
java.util.Hashtable excluded)
Cut from the tree excluded taxa
|
void |
fillAndCleanID(java.util.Hashtable table)
Fill an ID table, deduced from labels, and clean leaf labels from Ids.
|
void |
fillOrthologs(java.util.Vector allRes,
java.util.Vector allDepth,
java.util.Vector localRes)
The subtree of a species tree, from this tree and a species list.
|
void |
fillUltraParalogs(java.util.Hashtable table,
java.util.Vector table2,
int limit,
java.util.Vector subspecies,
java.util.Vector subspeciesTags,
java.util.Hashtable globalTable)
Fill a table with the largest ultraparalog group for each taxon
|
void |
formatLabelsWithTrace()
Clean labels, in order to fit the format P/S(trace)support
|
double |
getDepth(Tree leaf)
Return the depth of the leaf in this tree, 1.0 per level if no branch length, sum of branch lengths otherwise.
|
void |
getDepths(java.util.Vector res,
double save)
Fill a vector with every depths of each leaf of the tree, from this node, adding save
|
void |
getDuplications(java.util.Vector vect)
Fill a vector with every duplication node of this tree.
|
void |
getLosses(java.util.Vector vect)
Fill a vector with every losses node of this tree.
|
int |
getNbRedundancy()
Return the number of redundant nodes.
|
void |
getNbUltraparalogGroups(java.util.Hashtable table)
Fill a table with the number of ultraparalogous groups for each taxon
|
java.lang.String |
getNewick()
Return the newick representation of this node
|
java.lang.String |
getNHXNewick(Tree speciesTree,
java.util.Hashtable duplications,
java.lang.String refgroupe)
Return the newick representation of this node
|
Tree |
getNode(double targetLength,
java.lang.String targetLabel)
Return the node corresponding to length and label
|
java.util.Vector |
getNodes()
Return a vector containing all tree nodes under this node, this node included
|
java.util.Vector |
getRootedTrees()
Return every possible rooted trees, from this tree, cloning the structures
|
java.lang.String |
getSimpleNewick()
Return the simple (no length, no support) newick representation of this node
|
void |
getSpeciations(java.util.Vector vect)
Fill a vector with every speciations of leaves node of this tree.
|
void |
globalPretreatment()
Fill the Vector, Hashtable and pointer fields, for species trees
|
void |
heavyPretreatment()
Fill the Vector, Hashtable and pointer fields, in order to compare and reconcile this tree with others.
|
void |
initializeDuplicationNatures()
Check for each duplication if it is topological or intersection caused
|
boolean |
isLeaf()
Return true if this node is a leaf
|
Tree |
lastCommonAncestor(Tree leafI,
Tree leafJ)
Return the last common ancestor of two leaves.
|
void |
lightPretreatment()
Fill the father field, in order to enrich steppings.
|
double |
maxDepth()
Return the max depth of the tree, 1.0 per level if no branch length, sum of branch lengths otherwise.
|
double |
midpoint()
Set root branch lengths as close as midpoint, and return a midpoint score.
|
int |
nbIntersectionDuplications(Tree leaf) |
int |
nbLeaves()
Return the number of leaves.
|
int |
nbLosses()
Return the number of losses of tree (LOSS label), reducing the number with internal losses
|
int |
nbSpeciations(Tree leaf) |
java.util.Vector |
nbSpecies()
Return an array of species
|
int |
nbTopologicalDuplications(Tree leaf) |
int |
nbUltra(Tree leaf) |
void |
patternPretreatment(Tree speciesTree,
SpeciesDictionary dico)
Fill the Vector, Hashtable and pointer fields, in order to compare and reconcile this tree with others.
|
void |
pretreatment()
Fill the Vector, Hashtable and pointer fields, in order to compare and reconcile this tree with others.
|
boolean |
reroot()
Reroot the whole tree, father parents included, to the branch upper this node.
|
Tree |
speciesMapping(Tree s) |
java.util.Vector |
speciesVector()
Compute the species vector of this node
|
Tree |
subtree(java.util.Hashtable species)
The subtree of a species tree, from this tree and a species list.
|
int |
subtreeNeighbor(int level)
The subtree neighbor measure.
|
void |
taxonomicPretreatment()
Fill the Vector, Hashtable and pointer fields, in order to compare and a gene tree with a pattern tree.
|
java.lang.String |
toPhyloXMLString(SpeciesDictionary dico)
Specialized phyloXML string conversion method, used with a dictionary in order to generate a global species tree from NCBI files
|
java.lang.String |
toPhyloXMLString(java.lang.StringBuffer buffer)
Specialized phyloXML string conversion method
|
java.lang.String |
toString()
Standard string conversion method
|
double |
trace()
Compute the trace of a duplication node (intersection / union of species under the two sons)
|
java.util.Vector |
traceVector()
Compute the species intersection of this node
|
boolean |
ultraParalogy()
Return true if this subtree contains only paralogy, and false otherwise, and initialise the ultra attributes for the whole tree
|
public java.util.Vector sons
public java.lang.String label
public double length
public java.lang.String stringLength
public java.lang.String nhx
public java.util.Hashtable leafHashtable
public java.util.Vector leafVector
public double maxDepth
public Tree father
public boolean ultra
public java.util.Hashtable allowedLeft
public java.util.Hashtable allowedRight
public java.util.Hashtable forbiddenLeft
public java.util.Hashtable forbiddenRight
public int rightCardinalityMin
public int rightCardinalityMax
public java.util.Vector patternSpecies
public boolean hasLeftConstraint
public boolean hasRightConstraint
public Tree(java.lang.String newick)
newick
- The newick string, encoding the informationpublic Tree(java.util.Vector sons, java.lang.String label, double length, java.lang.String nhx)
sons
- The sons of this nodelabel
- The label of this nodelength
- The length of the branch upper this nodepublic Tree(java.util.Vector sons, java.lang.String label, double length, java.lang.String stringLength, java.lang.String nhx)
sons
- The sons of this nodelabel
- The label of this nodelength
- The length of the branch upper this nodepublic Tree(Tree source)
source
- The node to clonepublic void initializeDuplicationNatures()
public void formatLabelsWithTrace()
public java.util.Vector speciesVector()
public java.util.Vector traceVector()
public double trace()
public int nbIntersectionDuplications(Tree leaf)
leaf
- The leaf to starts frompublic int nbTopologicalDuplications(Tree leaf)
leaf
- The leaf to starts frompublic int nbUltra(Tree leaf)
leaf
- The leaf to starts frompublic java.util.Vector nbSpecies()
public int nbSpeciations(Tree leaf)
leaf
- The leaf to starts frompublic int subtreeNeighbor(int level)
level
- The k-levelpublic void getDepths(java.util.Vector res, double save)
res
- the vector to fillsave
- the value to add, 0.0 if executed from the rootpublic Tree speciesMapping(Tree s)
s
- The full species treepublic Tree subtree(java.util.Hashtable species)
species
- the species tablepublic void fillOrthologs(java.util.Vector allRes, java.util.Vector allDepth, java.util.Vector localRes)
allRes
- vector to filllocalRes
- must be initialised to new Vectorpublic void getLosses(java.util.Vector vect)
vect
- the vector to fill-public void getSpeciations(java.util.Vector vect)
vect
- the vector to fill-public void getDuplications(java.util.Vector vect)
vect
- the vector to fill-public Tree getNode(double targetLength, java.lang.String targetLabel)
public int nbLosses()
public java.lang.String toString()
toString
in class java.lang.Object
public void addSpeciations()
public boolean containsPattern(Tree pattern, java.util.Hashtable ind, SpeciesDictionary dic)
pattern
- The pattern to detectind
- The species indexdic
- The species dictionarypublic boolean colorPattern(Tree pattern, Tree rootPattern, java.util.Hashtable ind, SpeciesDictionary dic, java.util.Vector colored, java.util.Hashtable stickers)
pattern
- The pattern to detectind
- The species indexdic
- The species dictionarypublic boolean exclude(java.util.Vector list, java.util.Hashtable table, java.util.Hashtable excluded)
list
- the vector of excluded taxatable
- the hashtable of excluded taxaexcluded
- the hashtable hashtable of excluded sequences, filled during the processpublic java.lang.String toPhyloXMLString(java.lang.StringBuffer buffer)
buffer
- sequence relationspublic java.lang.String toPhyloXMLString(SpeciesDictionary dico)
dico
- The species dictionarypublic double midpoint()
public void lightPretreatment()
public void clusteringNodes(java.util.Vector trees, double threshold)
trees
- The vector to fillthreshold
- The cutting thresholdpublic void heavyPretreatment()
public void taxonomicPretreatment()
public void patternPretreatment(Tree speciesTree, SpeciesDictionary dico)
public void globalPretreatment()
public void pretreatment()
public void fillAndCleanID(java.util.Hashtable table)
table
- The id table to fillpublic boolean ultraParalogy()
public void fillUltraParalogs(java.util.Hashtable table, java.util.Vector table2, int limit, java.util.Vector subspecies, java.util.Vector subspeciesTags, java.util.Hashtable globalTable)
table
- The table to filltable2
- The id table to filllimit
- the minimum number of ultraparalog in a group to fill the ids tablepublic void getNbUltraparalogGroups(java.util.Hashtable table)
table
- The table to fillpublic java.lang.String getNHXNewick(Tree speciesTree, java.util.Hashtable duplications, java.lang.String refgroupe)
public java.lang.String getNewick()
public java.lang.String getSimpleNewick()
public double maxDepth()
public double getDepth(Tree leaf)
leaf
- The target leafpublic Tree lastCommonAncestor(Tree leafI, Tree leafJ)
leafI
- The first leafleafJ
- The second leafpublic int getNbRedundancy()
public boolean isLeaf()
public java.util.Hashtable computeExpansion(java.util.Hashtable d, java.util.Hashtable unrepresented)
public void addUniquePrefix()
public java.util.Hashtable countCopies(java.util.Hashtable d, java.util.Hashtable l)
public java.util.Vector getNodes()
public java.util.Vector getRootedTrees()
public int nbLeaves()
public boolean reroot()