org.forester.phylogeny
Class PhylogenyMethods

java.lang.Object
  extended by org.forester.phylogeny.PhylogenyMethods

public class PhylogenyMethods
extends java.lang.Object


Nested Class Summary
static class PhylogenyMethods.DESCENDANT_SORT_PRIORITY
           
static class PhylogenyMethods.PhylogenyNodeField
           
static class PhylogenyMethods.TAXONOMY_EXTRACTION
           
 
Method Summary
static boolean areAllChildrenDuplications(PhylogenyNode n)
           
static DescriptiveStatistics calculatBranchLengthStatistics(Phylogeny phy)
           
static java.util.List<DescriptiveStatistics> calculatConfidenceStatistics(Phylogeny phy)
           
static int calculateDepth(PhylogenyNode node)
           
 double calculateDistance(PhylogenyNode node1, PhylogenyNode node2)
          Calculates the distance between PhylogenyNodes node1 and node2.
static double calculateDistanceToRoot(PhylogenyNode node)
           
 double calculateFurthestDistance(Phylogeny phylogeny)
           
static short calculateMaxBranchesToLeaf(PhylogenyNode node)
           
static int calculateMaxDepth(Phylogeny phy)
           
static double calculateMaxDistanceToRoot(Phylogeny phy)
           
static int calculateNumberOfExternalNodesWithoutTaxonomy(PhylogenyNode node)
           
static DescriptiveStatistics calculatNumberOfDescendantsPerNodeStatistics(Phylogeny phy)
           
 java.lang.Object clone()
           
static int countNumberOfPolytomies(Phylogeny phy)
           
static void deleteExternalNodesNegativeSelection(java.util.Set<java.lang.Integer> to_delete, Phylogeny phy)
           
static void deleteExternalNodesNegativeSelection(java.lang.String[] node_names_to_delete, Phylogeny p)
           
static void deleteExternalNodesPositiveSelection(java.util.Set<Taxonomy> species_to_keep, Phylogeny phy)
           
static java.util.List<java.lang.String> deleteExternalNodesPositiveSelection(java.lang.String[] node_names_to_keep, Phylogeny p)
           
static java.util.List<PhylogenyNode> getAllDescendants(PhylogenyNode node)
           
static java.awt.Color getBranchColorValue(PhylogenyNode node)
          Convenience method
static double getBranchWidthValue(PhylogenyNode node)
          Convenience method
static double getConfidenceValue(PhylogenyNode node)
          Convenience method
static double[] getConfidenceValuesAsArray(PhylogenyNode node)
          Convenience method
static Taxonomy getExternalDescendantsTaxonomy(PhylogenyNode node)
          Returns taxonomy t if all external descendants have the same taxonomy t, null otherwise.
 PhylogenyNode getFarthestNode1()
           
 PhylogenyNode getFarthestNode2()
           
static PhylogenyNode getFurthestDescendant(PhylogenyNode node)
           
static PhylogenyMethods getInstance()
           
static double getMaximumConfidenceValue(Phylogeny phy)
          Returns the largest confidence value found on phy.
static int getMinimumDescendentsPerInternalNodes(Phylogeny phy)
           
 java.util.List<PhylogenyNode> getOrthologousNodes(Phylogeny phy, PhylogenyNode node)
          Returns all orthologs of the external PhylogenyNode n of this Phylogeny.
static java.lang.String getSpecies(PhylogenyNode node)
          Convenience method for display purposes.
static java.util.List<PhylogenyNode> getSuperOrthologousNodes(PhylogenyNode n)
          Returns all Nodes which are connected to external PhylogenyNode n of this Phylogeny by a path containing only speciation events.
static java.lang.String getTaxonomyIdentifier(PhylogenyNode node)
          Convenience method for display purposes.
static java.util.List<PhylogenyNode> getUltraParalogousNodes(PhylogenyNode n)
          Returns all Nodes which are connected to external PhylogenyNode n of this Phylogeny by a path containing, and leading to, only duplication events.
static java.lang.String inferCommonPartOfScientificNameOfDescendants(PhylogenyNode node)
           
 boolean isAreOrthologous(PhylogenyNode node1, PhylogenyNode node2)
           
static boolean isHasExternalDescendant(PhylogenyNode node)
           
static boolean isTaxonomyHasIdentifierOfGivenProvider(Taxonomy tax, java.lang.String[] providers)
           
static void midpointRoot(Phylogeny phylogeny)
           
static void normalizeBootstrapValues(Phylogeny phylogeny, double max_bootstrap_value, double max_normalized_value)
           
static java.util.List<PhylogenyNode> obtainAllNodesAsList(Phylogeny phy)
           
static java.util.Set<Taxonomy> obtainDistinctTaxonomies(PhylogenyNode node)
          Returns the set of distinct taxonomies of all external nodes of node.
static java.util.SortedMap<Taxonomy,java.lang.Integer> obtainDistinctTaxonomyCounts(PhylogenyNode node)
          Returns a map of distinct taxonomies of all external nodes of node.
 PhylogenyNode obtainLCA(PhylogenyNode node1, PhylogenyNode node2)
          Returns the LCA of PhylogenyNodes node1 and node2.
static void orderAppearance(PhylogenyNode n, boolean order, boolean order_ext_alphabetically, PhylogenyMethods.DESCENDANT_SORT_PRIORITY pri)
          Arranges the order of childern for each node of this Phylogeny in such a way that either the branch with more children is on top (right) or on bottom (left), dependent on the value of boolean order.
static void postorderBranchColorAveragingExternalNodeBased(Phylogeny p)
           
static Phylogeny[] readPhylogenies(PhylogenyParser parser, java.io.File file)
           
static Phylogeny[] readPhylogenies(PhylogenyParser parser, java.util.List<java.io.File> files)
           
static void removeNode(PhylogenyNode remove_me, Phylogeny phylogeny)
           
static java.util.List<PhylogenyNode> searchData(java.lang.String query, Phylogeny phy, boolean case_sensitive, boolean partial)
           
static java.util.List<PhylogenyNode> searchDataLogicalAnd(java.lang.String[] queries, Phylogeny phy, boolean case_sensitive, boolean partial)
           
static void setBootstrapConfidence(PhylogenyNode node, double bootstrap_confidence_value)
          Convenience method.
static void setBranchColorValue(PhylogenyNode node, java.awt.Color color)
           
static void setBranchWidthValue(PhylogenyNode node, double branch_width_value)
          Convenience method
static void setConfidence(PhylogenyNode node, double confidence_value)
          Convenience method.
static void setConfidence(PhylogenyNode node, double confidence_value, java.lang.String type)
          Convenience method.
static void setScientificName(PhylogenyNode node, java.lang.String scientific_name)
           
static void setTaxonomyCode(PhylogenyNode node, java.lang.String taxonomy_code)
          Convenience method to set the taxonomy code of a phylogeny node.
static void sortNodeDescendents(PhylogenyNode node, PhylogenyMethods.DESCENDANT_SORT_PRIORITY pri)
           
static int taxonomyBasedDeletionOfExternalNodes(Phylogeny reference, Phylogeny to_be_stripped)
          Removes from Phylogeny to_be_stripped all external Nodes which are associated with a species NOT found in Phylogeny reference.
static void transferInternalNamesToBootstrapSupport(Phylogeny phy)
           
static void transferInternalNodeNamesToConfidence(Phylogeny phy)
           
static void transferNodeNameToField(Phylogeny phy, PhylogenyMethods.PhylogenyNodeField field, boolean external_only)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

calculateDistance

public double calculateDistance(PhylogenyNode node1,
                                PhylogenyNode node2)
Calculates the distance between PhylogenyNodes node1 and node2.

Parameters:
node1 -
node2 -
Returns:
distance between node1 and node2

calculateFurthestDistance

public double calculateFurthestDistance(Phylogeny phylogeny)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

getFarthestNode1

public PhylogenyNode getFarthestNode1()

getFarthestNode2

public PhylogenyNode getFarthestNode2()

obtainLCA

public PhylogenyNode obtainLCA(PhylogenyNode node1,
                               PhylogenyNode node2)
Returns the LCA of PhylogenyNodes node1 and node2.

Parameters:
node1 -
node2 -
Returns:
LCA of node1 and node2

getOrthologousNodes

public java.util.List<PhylogenyNode> getOrthologousNodes(Phylogeny phy,
                                                         PhylogenyNode node)
Returns all orthologs of the external PhylogenyNode n of this Phylogeny. Orthologs 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.

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

isAreOrthologous

public boolean isAreOrthologous(PhylogenyNode node1,
                                PhylogenyNode node2)

readPhylogenies

public static final Phylogeny[] readPhylogenies(PhylogenyParser parser,
                                                java.io.File file)
                                         throws java.io.IOException
Throws:
java.io.IOException

readPhylogenies

public static final Phylogeny[] readPhylogenies(PhylogenyParser parser,
                                                java.util.List<java.io.File> files)
                                         throws java.io.IOException
Throws:
java.io.IOException

transferInternalNodeNamesToConfidence

public static final void transferInternalNodeNamesToConfidence(Phylogeny phy)

transferInternalNamesToBootstrapSupport

public static final void transferInternalNamesToBootstrapSupport(Phylogeny phy)

sortNodeDescendents

public static final void sortNodeDescendents(PhylogenyNode node,
                                             PhylogenyMethods.DESCENDANT_SORT_PRIORITY pri)

transferNodeNameToField

public static final void transferNodeNameToField(Phylogeny phy,
                                                 PhylogenyMethods.PhylogenyNodeField field,
                                                 boolean external_only)
                                          throws PhyloXmlDataFormatException
Throws:
PhyloXmlDataFormatException

areAllChildrenDuplications

public static boolean areAllChildrenDuplications(PhylogenyNode n)

calculateDepth

public static int calculateDepth(PhylogenyNode node)

calculateDistanceToRoot

public static double calculateDistanceToRoot(PhylogenyNode node)

calculateMaxBranchesToLeaf

public static short calculateMaxBranchesToLeaf(PhylogenyNode node)

calculateMaxDepth

public static int calculateMaxDepth(Phylogeny phy)

calculateMaxDistanceToRoot

public static double calculateMaxDistanceToRoot(Phylogeny phy)

countNumberOfPolytomies

public static int countNumberOfPolytomies(Phylogeny phy)

calculatNumberOfDescendantsPerNodeStatistics

public static DescriptiveStatistics calculatNumberOfDescendantsPerNodeStatistics(Phylogeny phy)

calculatBranchLengthStatistics

public static DescriptiveStatistics calculatBranchLengthStatistics(Phylogeny phy)

calculatConfidenceStatistics

public static java.util.List<DescriptiveStatistics> calculatConfidenceStatistics(Phylogeny phy)

obtainDistinctTaxonomies

public static java.util.Set<Taxonomy> obtainDistinctTaxonomies(PhylogenyNode node)
Returns the set of distinct taxonomies of all external nodes of node. If at least one the external nodes has no taxonomy, null is returned.


obtainDistinctTaxonomyCounts

public static java.util.SortedMap<Taxonomy,java.lang.Integer> obtainDistinctTaxonomyCounts(PhylogenyNode node)
Returns a map of distinct taxonomies of all external nodes of node. If at least one of the external nodes has no taxonomy, null is returned.


calculateNumberOfExternalNodesWithoutTaxonomy

public static int calculateNumberOfExternalNodesWithoutTaxonomy(PhylogenyNode node)

deleteExternalNodesNegativeSelection

public static void deleteExternalNodesNegativeSelection(java.util.Set<java.lang.Integer> to_delete,
                                                        Phylogeny phy)

deleteExternalNodesNegativeSelection

public static void deleteExternalNodesNegativeSelection(java.lang.String[] node_names_to_delete,
                                                        Phylogeny p)
                                                 throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

deleteExternalNodesPositiveSelection

public static void deleteExternalNodesPositiveSelection(java.util.Set<Taxonomy> species_to_keep,
                                                        Phylogeny phy)

deleteExternalNodesPositiveSelection

public static java.util.List<java.lang.String> deleteExternalNodesPositiveSelection(java.lang.String[] node_names_to_keep,
                                                                                    Phylogeny p)

getAllDescendants

public static java.util.List<PhylogenyNode> getAllDescendants(PhylogenyNode node)

getBranchColorValue

public static java.awt.Color getBranchColorValue(PhylogenyNode node)
Convenience method

Parameters:
node -
Returns:

getBranchWidthValue

public static double getBranchWidthValue(PhylogenyNode node)
Convenience method


getConfidenceValue

public static double getConfidenceValue(PhylogenyNode node)
Convenience method


getConfidenceValuesAsArray

public static double[] getConfidenceValuesAsArray(PhylogenyNode node)
Convenience method


getExternalDescendantsTaxonomy

public static Taxonomy getExternalDescendantsTaxonomy(PhylogenyNode node)
Returns taxonomy t if all external descendants have the same taxonomy t, null otherwise.


getFurthestDescendant

public static PhylogenyNode getFurthestDescendant(PhylogenyNode node)

getInstance

public static PhylogenyMethods getInstance()

getMaximumConfidenceValue

public static double getMaximumConfidenceValue(Phylogeny phy)
Returns the largest confidence value found on phy.


getMinimumDescendentsPerInternalNodes

public static int getMinimumDescendentsPerInternalNodes(Phylogeny phy)

getSpecies

public static java.lang.String getSpecies(PhylogenyNode node)
Convenience method for display purposes. Not intended for algorithms.


getSuperOrthologousNodes

public static java.util.List<PhylogenyNode> getSuperOrthologousNodes(PhylogenyNode n)
Returns all Nodes which are connected to external PhylogenyNode n of this Phylogeny by a path containing only speciation events. We call these "super orthologs". Nodes are returned as Vector of references to Nodes.

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.

Parameters:
n - external PhylogenyNode whose strictly speciation related Nodes are to be returned
Returns:
Vector of references to all strictly speciation related Nodes of PhylogenyNode n of this Phylogeny, null if this Phylogeny is empty or if n is internal

getTaxonomyIdentifier

public static java.lang.String getTaxonomyIdentifier(PhylogenyNode node)
Convenience method for display purposes. Not intended for algorithms.


getUltraParalogousNodes

public static java.util.List<PhylogenyNode> getUltraParalogousNodes(PhylogenyNode n)
Returns all Nodes which are connected to external PhylogenyNode n of this Phylogeny by a path containing, and leading to, only duplication events. We call these "ultra paralogs". Nodes are returned as Vector of references to Nodes.

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: 10/06/01)

Parameters:
n - external PhylogenyNode whose ultra paralogs are to be returned
Returns:
Vector of references to all ultra paralogs of PhylogenyNode n of this Phylogeny, null if this Phylogeny is empty or if n is internal

inferCommonPartOfScientificNameOfDescendants

public static java.lang.String inferCommonPartOfScientificNameOfDescendants(PhylogenyNode node)

isHasExternalDescendant

public static boolean isHasExternalDescendant(PhylogenyNode node)

isTaxonomyHasIdentifierOfGivenProvider

public static boolean isTaxonomyHasIdentifierOfGivenProvider(Taxonomy tax,
                                                             java.lang.String[] providers)

midpointRoot

public static void midpointRoot(Phylogeny phylogeny)

normalizeBootstrapValues

public static void normalizeBootstrapValues(Phylogeny phylogeny,
                                            double max_bootstrap_value,
                                            double max_normalized_value)

obtainAllNodesAsList

public static java.util.List<PhylogenyNode> obtainAllNodesAsList(Phylogeny phy)

postorderBranchColorAveragingExternalNodeBased

public static void postorderBranchColorAveragingExternalNodeBased(Phylogeny p)

removeNode

public static void removeNode(PhylogenyNode remove_me,
                              Phylogeny phylogeny)

searchData

public static java.util.List<PhylogenyNode> searchData(java.lang.String query,
                                                       Phylogeny phy,
                                                       boolean case_sensitive,
                                                       boolean partial)

searchDataLogicalAnd

public static java.util.List<PhylogenyNode> searchDataLogicalAnd(java.lang.String[] queries,
                                                                 Phylogeny phy,
                                                                 boolean case_sensitive,
                                                                 boolean partial)

setBootstrapConfidence

public static void setBootstrapConfidence(PhylogenyNode node,
                                          double bootstrap_confidence_value)
Convenience method. Sets value for the first confidence value (created if not present, values overwritten otherwise).


setBranchColorValue

public static void setBranchColorValue(PhylogenyNode node,
                                       java.awt.Color color)

setBranchWidthValue

public static void setBranchWidthValue(PhylogenyNode node,
                                       double branch_width_value)
Convenience method


setConfidence

public static void setConfidence(PhylogenyNode node,
                                 double confidence_value)
Convenience method. Sets value for the first confidence value (created if not present, values overwritten otherwise).


setConfidence

public static void setConfidence(PhylogenyNode node,
                                 double confidence_value,
                                 java.lang.String type)
Convenience method. Sets value for the first confidence value (created if not present, values overwritten otherwise).


setScientificName

public static void setScientificName(PhylogenyNode node,
                                     java.lang.String scientific_name)

setTaxonomyCode

public static void setTaxonomyCode(PhylogenyNode node,
                                   java.lang.String taxonomy_code)
                            throws PhyloXmlDataFormatException
Convenience method to set the taxonomy code of a phylogeny node.

Parameters:
node -
taxonomy_code -
Throws:
PhyloXmlDataFormatException

taxonomyBasedDeletionOfExternalNodes

public static int taxonomyBasedDeletionOfExternalNodes(Phylogeny reference,
                                                       Phylogeny to_be_stripped)
Removes from Phylogeny to_be_stripped all external Nodes which are associated with a species NOT found in Phylogeny reference.

Parameters:
reference - a reference Phylogeny
to_be_stripped - Phylogeny to be stripped
Returns:
number of external nodes removed from to_be_stripped

orderAppearance

public static void orderAppearance(PhylogenyNode n,
                                   boolean order,
                                   boolean order_ext_alphabetically,
                                   PhylogenyMethods.DESCENDANT_SORT_PRIORITY pri)
Arranges the order of childern for each node of this Phylogeny in such a way that either the branch with more children is on top (right) or on bottom (left), dependent on the value of boolean order.

Parameters:
order - decides in which direction to order
pri -