|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.upenn.crimson.Tree
public class Tree
A rooted tree that is composed of Species objects. Species must be added to the tree using addSpecies() and similarly removed from the tree with removeSpecies().
Field Summary | |
---|---|
private boolean |
binary
True when all inner nodes have exactly 2 children. |
(package private) static boolean |
DEBUG_OUTPUT
If true, then whenever a tree is sampled, the list of species selected will be output to the file 'species.list'. |
private java.lang.String |
id
This is a unique name for the Tree object. |
private int |
maxLevel
The maximum number of species between the leaves and root. |
private double |
maxStemLength
The maximum distance between the species and their parents. |
private double |
maxTempDepth
The maximum distance between the leaves and root. |
private int |
minLevel
The minimum number of species between the leaves and root. |
private double |
minStemLength
The minimum distance between the species and their parents. |
private double |
minTempDepth
The minimum distance between the leaves and root. |
private java.lang.String |
modelID
Model specific to this Tree object. |
private java.lang.String |
notes
Notes specific to this Tree object. |
private int |
numLeaves
The number of leaves is stored, in case the tree has not been built from the newick string. |
private int |
numSpecies
The number of species is equivalent to speciesList.size(). |
private java.util.HashSet |
partitions
This contains the partitions loaded for this tree. |
private Species |
root
The root Species of the tree. |
private java.util.ArrayList |
speciesList
Array containing references to all species in the tree. |
private boolean |
ultrametric
True when all leaves have the same temporal depth: (minTempDepth = maxTempDepth) |
Constructor Summary | |
---|---|
Tree(java.lang.String id)
|
|
Tree(java.lang.String id,
boolean addToPool)
|
|
Tree(java.lang.String id,
Species root,
Model model,
java.lang.String notes,
int numSpecies,
int numLeaves,
boolean binary,
boolean ultrametric,
int minLevel,
int maxLevel,
double minTempDepth,
double maxTempDepth,
double minStemLength,
double maxStemLength)
Trees should not be instantiated by the user, using this routine. |
Method Summary | |
---|---|
private java.util.Queue |
addChildrenToQueue(java.util.Queue queue,
Species[] children)
This will add the children to the queue. |
void |
addPartition(Partition partition)
|
void |
addSpecies(Species species)
|
boolean |
buildTree()
This will build the tree from the nexick string. |
void |
clearStructure()
This will release the tree structure from memory. |
java.lang.Object |
clone()
This will duplicate the tree and all species. |
void |
collapse()
This will remove all internal species that have only one child, linking the child to species' parent and adjusting the child's stem lengths accordingly. |
boolean |
computeBinary()
Returns true if the tree is binary. |
void |
computeStats()
This will compute the various tree statistics. |
java.lang.String |
getID()
Get the ID. |
static Species |
getLCA(Species s1,
Species s2)
Returns the LCA for the tree, assuming this species is the root of the tree. |
java.util.ArrayList |
getLeafCounts(java.util.ArrayList subroots)
This will return a list of leaf counts for each subtree specified by the subroots. |
java.util.ArrayList |
getLeaves()
Returns the set of all leaves in the tree. |
int |
getLength()
This is the sum of the length of all partitions. |
int |
getMaxLevel()
|
double |
getMaxStemLength()
|
double |
getMaxTempDepth()
|
int |
getMinLevel()
|
double |
getMinStemLength()
|
double |
getMinTempDepth()
|
java.lang.String |
getModelID()
Returns the ID for the model underlying this tree. |
java.lang.String |
getNewick()
Returns the newick string for this tree, as stored in the database. |
java.lang.String |
getNotes()
|
int |
getNumLeaves()
This will return the number of leaves in the tree. |
int |
getNumPartitions()
The number of partitions loaded for this tree. |
int |
getNumSpecies()
This will return the number of species in the tree. |
java.util.HashSet |
getPartitions()
This will return the set of partitions. |
java.util.ArrayList |
getPartitionsByModel(java.lang.String modelID)
This will return an ArrayList containing all of the partitions in the current tree that are based on the specified model. |
Species |
getRoot()
|
Species |
getRootLCA(int num)
This will return the LCA for a random sampling of leaves from the tree. |
java.util.ArrayList |
getSpeciesByID(java.util.ArrayList speciesIn)
This will take a list of species IDs and return a list of species objects. |
Species |
getSpeciesByID(java.lang.String id)
This steps through every species in the tree and compares the species IDs until it finds the species requested. |
java.util.ArrayList |
getSpeciesList()
Returns the list of all species in the tree. |
Tree |
getSubtree(Species subroot)
Returns the subtree given the specified root. |
java.util.ArrayList |
getTreesByLevel(int level)
Returns the set of root species for any subtrees that are below a specified level. |
java.util.ArrayList |
getTreesByTempDepth(double tempDepth)
Returns the set of root species for any subtrees that are below a specified level. |
boolean |
isBinary()
|
boolean |
isBuilt()
Returns true if the tree has been built from the newick string. |
boolean |
isUltrametric()
|
Tree |
manualSampleByID(java.util.ArrayList oldLeaves)
This will return a subtree that contains the specified leaves. |
java.lang.String |
printTree()
This will print out the tree, one species per line, indenting each level. |
Tree |
randomSample(int num)
This will randomly sample the tree, returning a subtree that contains 'num' leaves. |
void |
removePartition(Partition partition)
|
void |
removeSpecies(Species species)
|
void |
setModelID(Model model)
Sets the ID for the model underlying this tree. |
void |
setNewick(java.lang.String newick)
This will update the newick string stored in the database. |
void |
setNotes(java.lang.String notes)
Updates the local notes field and the TREES table. |
void |
setRoot(Species root)
The root's label will be set to "_Root" if there is currently no label. |
java.lang.String |
toNewick()
This will print out this species and all children as a newick formatted tree. |
java.lang.String |
toNewick(boolean incSequence)
This will print out this species and all children as a newick formatted tree. |
java.lang.String |
toNewick(boolean incSequence,
boolean rooted)
This will output this species and all children as a newick formatted tree. |
java.lang.String |
toString()
This will print lots of specs about the tree. |
Tree |
uniformSampleByLevel(int level,
int num)
Returns the random, uniform sampling of species from each subtree demarkated by the level value. |
Tree |
uniformSampleByTempDepth(double tempDepth,
int num)
Returns the random, uniform sampling of species from each subtree demarkated by the temporal depth value. |
Tree |
weightedSampleByLevel(int level,
int num)
Returns the random, weighted sampling of species from each subtree demarkated by the level value. |
Tree |
weightedSampleByTempDepth(double tempDepth,
int num)
Returns the random, weighted sampling of species from each subtree demarkated by the temporal depth value. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
static final boolean DEBUG_OUTPUT
private java.lang.String id
private java.lang.String modelID
private java.lang.String notes
private Species root
private java.util.ArrayList speciesList
private int numSpecies
private int numLeaves
private boolean binary
private boolean ultrametric
private int minLevel
private int maxLevel
private double minStemLength
private double maxStemLength
private double minTempDepth
private double maxTempDepth
private java.util.HashSet partitions
Constructor Detail |
---|
public Tree(java.lang.String id) throws InvalidIDException
InvalidIDException
public Tree(java.lang.String id, boolean addToPool) throws InvalidIDException
InvalidIDException
public Tree(java.lang.String id, Species root, Model model, java.lang.String notes, int numSpecies, int numLeaves, boolean binary, boolean ultrametric, int minLevel, int maxLevel, double minTempDepth, double maxTempDepth, double minStemLength, double maxStemLength) throws InvalidIDException
InvalidIDException
Method Detail |
---|
public java.lang.String getID()
public java.lang.String getModelID()
public void setModelID(Model model)
public java.lang.String getNotes()
public void setNotes(java.lang.String notes)
public Species getRoot()
public void setRoot(Species root)
public java.util.ArrayList getSpeciesList()
public java.util.HashSet getPartitions()
public int getNumSpecies()
public int getNumLeaves()
public int getMinLevel()
public boolean isBinary()
public boolean isUltrametric()
public int getMaxLevel()
public double getMinStemLength()
public double getMaxStemLength()
public double getMinTempDepth()
public double getMaxTempDepth()
public java.lang.String getNewick()
public void setNewick(java.lang.String newick)
public boolean isBuilt()
public boolean buildTree()
private java.util.Queue addChildrenToQueue(java.util.Queue queue, Species[] children)
public void clearStructure()
public void addSpecies(Species species)
public void removeSpecies(Species species)
public java.util.ArrayList getSpeciesByID(java.util.ArrayList speciesIn)
public Species getSpeciesByID(java.lang.String id)
public void computeStats()
public boolean computeBinary()
public java.util.ArrayList getLeaves()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toNewick()
public java.lang.String toNewick(boolean incSequence)
incSequence
- when true, inner sequence IDs will be
included in the newick output
public java.lang.String toNewick(boolean incSequence, boolean rooted)
incSequence
- when true, inner sequence IDs will be
included in the newick outputrooted
- when true, the tree will rooted
public java.lang.String printTree()
public java.lang.String toString()
toString
in class java.lang.Object
public int getNumPartitions()
public int getLength()
public void addPartition(Partition partition)
public void removePartition(Partition partition)
public java.util.ArrayList getPartitionsByModel(java.lang.String modelID)
public void collapse()
public java.util.ArrayList getLeafCounts(java.util.ArrayList subroots)
public Tree getSubtree(Species subroot)
public java.util.ArrayList getTreesByLevel(int level)
public Tree uniformSampleByLevel(int level, int num)
public Tree weightedSampleByLevel(int level, int num)
public java.util.ArrayList getTreesByTempDepth(double tempDepth)
public Tree uniformSampleByTempDepth(double tempDepth, int num)
public Tree weightedSampleByTempDepth(double tempDepth, int num)
public Tree manualSampleByID(java.util.ArrayList oldLeaves)
public Tree randomSample(int num)
public Species getRootLCA(int num)
public static Species getLCA(Species s1, Species s2)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |