Class Phylogeny


  • public class Phylogeny
    extends java.lang.Object
    • Field Detail

      • ALLOW_MULTIPLE_PARENTS_DEFAULT

        public static final boolean ALLOW_MULTIPLE_PARENTS_DEFAULT
        See Also:
        Constant Field Values
    • Constructor Detail

      • Phylogeny

        public Phylogeny()
        Default Phylogeny constructor. Constructs an empty Phylogeny.
    • Method Detail

      • addAsChild

        public void addAsChild​(PhylogenyNode parent)
        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

        public void addAsSibling​(PhylogenyNode sibling)
      • calculateSubtreeHeight

        public double calculateSubtreeHeight​(PhylogenyNode n)
        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

        public Phylogeny 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

        public Phylogeny copy​(PhylogenyNode source)
        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

        public Phylogeny 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.)

      • deleteSubtree

        public 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). 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

        public java.lang.String[] getAllExternalNodeNames()
      • getConfidence

        public Confidence getConfidence()
      • getDescription

        public java.lang.String getDescription()
      • getDistanceUnit

        public java.lang.String getDistanceUnit()
      • createInstanceFromNhxString

        public static final Phylogeny createInstanceFromNhxString​(java.lang.String nhx)
                                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • getExternalNodes

        public java.util.List<PhylogenyNode> getExternalNodes()
        Warning. The order of the returned nodes is random -- and hence cannot be relied on.
        Returns:
        Unordered set of PhylogenyNode
      • getFirstExternalNode

        public 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

        public Identifier getIdentifier()
      • getName

        public java.lang.String getName()
        Returns the name of this Phylogeny.
      • getNode

        public PhylogenyNode getNode​(long id)
                              throws java.util.NoSuchElementException
        Finds the PhylogenyNode of this Phylogeny which has a matching ID number.
        Returns:
        PhylogenyNode with matching ID, null if not found
        Throws:
        java.util.NoSuchElementException
      • getNode

        public PhylogenyNode getNode​(java.lang.String name)
        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

        public java.util.List<PhylogenyNode> getNodes​(java.lang.String name)
        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:
        getNodesWithMatchingSpecies(String)
      • getNodesViaSequenceName

        public java.util.List<PhylogenyNode> getNodesViaSequenceName​(java.lang.String seq_name)
      • getNodesViaSequenceSymbol

        public java.util.List<PhylogenyNode> getNodesViaSequenceSymbol​(java.lang.String seq_name)
      • getNodesViaGeneName

        public java.util.List<PhylogenyNode> getNodesViaGeneName​(java.lang.String seq_name)
      • getNodesViaTaxonomyCode

        public java.util.List<PhylogenyNode> getNodesViaTaxonomyCode​(java.lang.String taxonomy_code)
      • getNodesWithMatchingSpecies

        public java.util.List<PhylogenyNode> getNodesWithMatchingSpecies​(java.lang.String specname)
        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:
        getNodes(String)
      • getNodeViaSequenceName

        public PhylogenyNode getNodeViaSequenceName​(java.lang.String seq_name)
      • getNodeViaTaxonomyCode

        public PhylogenyNode getNodeViaTaxonomyCode​(java.lang.String taxonomy_code)
      • getNumberOfBranches

        public int getNumberOfBranches()
      • getNumberOfInternalNodes

        public int getNumberOfInternalNodes()
      • getNumberOfExternalNodes

        public int getNumberOfExternalNodes()
        Returns the sum of external Nodes of this Phylogeny (int).
      • getParalogousNodes

        public java.util.List<PhylogenyNode> getParalogousNodes​(PhylogenyNode n,
                                                                java.lang.String[] taxonomyCodeRange)
        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
      • getRoot

        public PhylogenyNode getRoot()
        Returns the root PhylogenyNode of this Phylogeny.
      • getSequenceRelationQueries

        public java.util.Collection<Sequence> getSequenceRelationQueries()
      • getType

        public java.lang.String 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()
      • 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