Class Phylogeny
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAsChild
(PhylogenyNode parent) Adds this Phylogeny to the list of child nodes of PhylogenyNode parent and sets the parent of this to parent.void
addAsSibling
(PhylogenyNode sibling) double
This calculates the height of the subtree emanating at n for rooted, tree-shaped phylogeniesvoid
copy()
Returns a deep copy of this Phylogeny.copy
(PhylogenyNode source) Returns a deep copy of this Phylogeny.Returns a shallow copy of this Phylogeny.copyShallow
(PhylogenyNode source) static final Phylogeny
void
deleteSubtree
(PhylogenyNode remove_us, boolean collapse_resulting_node_with_one_desc) Need to call clearHashIdToNodeMap() afterwards (not done automatically to allow client multiple deletions in linear time).void
String[]
Warning.Returns the first external PhylogenyNode.double
This calculates the height for rooted, tree-shaped phylogenies.getName()
Returns the name of this Phylogeny.getNode
(long id) Finds the PhylogenyNode of this Phylogeny which has a matching ID number.Returns a PhylogenyNode of this Phylogeny which has a matching name.int
This is time-inefficient since it runs a iterator each time it is called.Returns a List with references to all Nodes of this Phylogeny which have a matching name.getNodesViaGeneName
(String seq_name) getNodesViaSequenceName
(String seq_name) getNodesViaSequenceSymbol
(String seq_name) getNodesViaTaxonomyCode
(String taxonomy_code) getNodesWithMatchingSpecies
(String specname) Returns a Vector with references to all Nodes of this Phylogeny which have a matching species name.getNodeViaSequenceName
(String seq_name) getNodeViaTaxonomyCode
(String taxonomy_code) int
int
Returns the sum of external Nodes of this Phylogeny (int).int
getParalogousNodes
(PhylogenyNode n, String[] taxonomyCodeRange) Returns all paralogs of the external PhylogenyNode n of this Phylogeny.getRoot()
Returns the root PhylogenyNode of this Phylogeny.getType()
void
init()
Deletes this Phylogeny.boolean
Returns whether this is a completely binary tree (i.e.boolean
isEmpty()
Checks whether a Phylogeny object is deleted (or empty).boolean
boolean
isRooted()
Returns true is this Phylogeny is rooted.boolean
isTree()
void
Resets the ID numbers of the nodes of this Phylogeny in level order, starting with start_label (for the root).void
Prints descriptions of all external Nodes of this Phylogeny to System.out.void
recalculateNumberOfExternalDescendants
(boolean consider_collapsed_nodes) (Re)counts the number of children for each PhylogenyNode of this Phylogeny.void
reRoot
(long id) Places the root of this Phylogeny on the parent branch of the PhylogenyNode with a corresponding ID.void
Places the root of this Phylogeny on the parent branch PhylogenyNode n.void
reRoot
(PhylogenyNode n, double distance_n_to_parent) void
Sets all Nodes of this Phylogeny to not-collapsed.void
setConfidence
(Confidence confidence) void
setDescription
(String description) void
setDistanceUnit
(String _distance_unit) void
setIdentifier
(Identifier identifier) void
setIdToNodeMap
(HashMap<Long, PhylogenyNode> idhash) void
Sets the indicators of all Nodes of this Phylogeny to 0.void
Sets the name of this Phylogeny to s.void
void
setRerootable
(boolean rerootable) void
void
setRooted
(boolean b) Sets whether this Phylogeny is rooted or not.void
setSequenceRelationQueries
(Collection<Sequence> sequencesByName) void
toNewHampshire
(PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE nh_conversion_support_style) toNexus()
toPhyloXML
(int phyloxml_level) toString()
Converts this Phylogeny to a New Hampshire X (String) representation.void
unRoot()
Removes the root PhylogenyNode this Phylogeny.
-
Field Details
-
ALLOW_MULTIPLE_PARENTS_DEFAULT
public static final boolean ALLOW_MULTIPLE_PARENTS_DEFAULT- See Also:
-
-
Constructor Details
-
Phylogeny
public Phylogeny()Default Phylogeny constructor. Constructs an empty Phylogeny.
-
-
Method Details
-
addAsChild
Adds this Phylogeny to the list of child nodes of PhylogenyNode parent and sets the parent of this to parent.- Parameters:
n
- the PhylogenyNode to add
-
addAsSibling
-
calculateSubtreeHeight
This calculates the height of the subtree emanating at n for rooted, tree-shaped phylogenies- Parameters:
n
- the root-node of a subtree- Returns:
- the height of the subtree emanating at n
-
clearHashIdToNodeMap
public void clearHashIdToNodeMap() -
copy
Returns a deep copy of this Phylogeny.(The resulting Phylogeny has its references in the external nodes corrected, if they are lacking/obsolete in this.)
-
copy
Returns a deep copy of this Phylogeny.(The resulting Phylogeny has its references in the external nodes corrected, if they are lacking/obsolete in this.)
-
copyShallow
Returns a shallow copy of this Phylogeny.(The resulting Phylogeny has its references in the external nodes corrected, if they are lacking/obsolete in this.)
-
copyShallow
-
deleteSubtree
Need to call clearHashIdToNodeMap() afterwards (not done automatically to allow client multiple deletions in linear time). Need to call 'recalculateNumberOfExternalDescendants(boolean)' after this if tree is to be displayed.- Parameters:
remove_us
- the parent node of the subtree to be deleted
-
externalNodesHaveChanged
public void externalNodesHaveChanged() -
getAllExternalNodeNames
-
getConfidence
-
getDescription
-
getDistanceUnit
-
createInstanceFromNhxString
- Throws:
IOException
-
getExternalNodes
Warning. The order of the returned nodes is random -- and hence cannot be relied on.- Returns:
- Unordered set of PhylogenyNode
-
getFirstExternalNode
Returns the first external PhylogenyNode. -
getHeight
public double getHeight()This calculates the height for rooted, tree-shaped phylogenies. The height is the longest distance from the root to an external node. Please note. Child nodes of collapsed nodes are ignored -- which is useful for display purposes but might be misleading for other applications.- Returns:
- the height for rooted, tree-shaped phylogenies
-
getIdentifier
-
getName
Returns the name of this Phylogeny. -
getNode
Finds the PhylogenyNode of this Phylogeny which has a matching ID number.- Returns:
- PhylogenyNode with matching ID, null if not found
- Throws:
NoSuchElementException
-
getNode
Returns a PhylogenyNode of this Phylogeny which has a matching name. Throws an Exception if seqname is not present in this or not unique.- Parameters:
name
- name (String) of PhylogenyNode to find- Returns:
- PhylogenyNode with matchin name
-
getNodeCount
public int getNodeCount()This is time-inefficient since it runs a iterator each time it is called. -
getNodes
Returns a List with references to all Nodes of this Phylogeny which have a matching name.- Parameters:
name
- name (String) of Nodes to find- Returns:
- Vector of references to Nodes of this Phylogeny with matching names
- See Also:
-
getNodesViaSequenceName
-
getNodesViaSequenceSymbol
-
getNodesViaGeneName
-
getNodesViaTaxonomyCode
-
getNodesWithMatchingSpecies
Returns a Vector with references to all Nodes of this Phylogeny which have a matching species name.- Parameters:
specname
- species name (String) of Nodes to find- Returns:
- Vector of references to Nodes of this Phylogeny with matching species names.
- See Also:
-
getNodeViaSequenceName
-
getNodeViaTaxonomyCode
-
getNumberOfBranches
public int getNumberOfBranches() -
getNumberOfInternalNodes
public int getNumberOfInternalNodes() -
getNumberOfExternalNodes
public int getNumberOfExternalNodes()Returns the sum of external Nodes of this Phylogeny (int). -
getParalogousNodes
Returns all paralogs of the external PhylogenyNode n of this Phylogeny. paralog are returned as List of node references.PRECONDITION: This tree must be binary and rooted, and speciation - duplication need to be assigned for each of its internal Nodes.
Returns null if this Phylogeny is empty or if n is internal.
(Last modified: 11/22/00) Olivier CHABROL : olivier.chabrol@univ-provence.fr
- Parameters:
n
- external PhylogenyNode whose orthologs are to be returned- Returns:
- Vector of references to all orthologous Nodes of PhylogenyNode n of this Phylogeny, null if this Phylogeny is empty or if n is internal
-
getRelevantSequenceRelationTypes
-
getRoot
Returns the root PhylogenyNode of this Phylogeny. -
getSequenceRelationQueries
-
getType
-
init
public void init()Deletes this Phylogeny. -
isCompletelyBinary
public boolean isCompletelyBinary()Returns whether this is a completely binary tree (i.e. all internal nodes are bifurcations). -
isEmpty
public boolean isEmpty()Checks whether a Phylogeny object is deleted (or empty).- Returns:
- true if the tree is deleted (or empty), false otherwise
-
isRerootable
public boolean isRerootable() -
isRooted
public boolean isRooted()Returns true is this Phylogeny is rooted. -
isTree
public boolean isTree() -
iteratorExternalForward
-
iteratorLevelOrder
-
iteratorPostorder
-
iteratorPreorder
-
levelOrderReID
public void levelOrderReID()Resets the ID numbers of the nodes of this Phylogeny in level order, starting with start_label (for the root).
WARNING. After this method has been called, node IDs are no longer unique. -
printExtNodes
public void printExtNodes()Prints descriptions of all external Nodes of this Phylogeny to System.out. -
recalculateNumberOfExternalDescendants
public void recalculateNumberOfExternalDescendants(boolean consider_collapsed_nodes) (Re)counts the number of children for each PhylogenyNode of this Phylogeny. As an example, this method needs to be called after a Phylogeny has been reRooted and it is to be displayed.- Parameters:
consider_collapsed_nodes
- set to true to take into account collapsed nodes (collapsed nodes have 1 child).
-
reRoot
public void reRoot(long id) Places the root of this Phylogeny on the parent branch of the PhylogenyNode with a corresponding ID. The new root is always placed on the middle of the branch. If the resulting reRooted Phylogeny is to be used any further, in most cases the following methods have to be called on the resulting Phylogeny:- recalculateNumberOfExternalDescendants(boolean)
- recalculateAndReset()
- Parameters:
id
- ID (int) of PhylogenyNode of this Phylogeny
-
reRoot
Places the root of this Phylogeny on the parent branch PhylogenyNode n. The new root is always placed on the middle of the branch.If the resulting reRooted Phylogeny is to be used any further, in most cases the following three methods have to be called on the resulting Phylogeny:
- recalculateNumberOfExternalDescendants(boolean)
- recalculateAndReset()
(Last modified: 10/01/01)
- Parameters:
n
- PhylogenyNode of this Phylogeny\
-
reRoot
-
setAllNodesToNotCollapse
public void setAllNodesToNotCollapse()Sets all Nodes of this Phylogeny to not-collapsed.In most cases methods adjustNodeCount(false) and recalculateAndReset() need to be called after this method has been called.
-
setConfidence
-
setDescription
-
setDistanceUnit
-
setIdentifier
-
setIdToNodeMap
-
setIndicatorsToZero
public void setIndicatorsToZero()Sets the indicators of all Nodes of this Phylogeny to 0. -
setName
Sets the name of this Phylogeny to s. -
setRelevantSequenceRelationTypes
public void setRelevantSequenceRelationTypes(Collection<SequenceRelation.SEQUENCE_RELATION_TYPE> types) -
setRerootable
public void setRerootable(boolean rerootable) -
setRoot
-
setRooted
public void setRooted(boolean b) Sets whether this Phylogeny is rooted or not. -
setSequenceRelationQueries
-
setType
-
toNewHampshire
-
toNewHampshire
public String toNewHampshire(PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE nh_conversion_support_style) -
toNewHampshireX
-
toNexus
-
toNexus
-
toPhyloXML
-
toString
Converts this Phylogeny to a New Hampshire X (String) representation. -
unRoot
Removes the root PhylogenyNode this Phylogeny.- Throws:
RuntimeException
-