Package org.forester.phylogeny
Class PhylogenyMethods
- java.lang.Object
-
- org.forester.phylogeny.PhylogenyMethods
-
public class PhylogenyMethods extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPhylogenyMethods.DESCENDANT_SORT_PRIORITYstatic classPhylogenyMethods.PhylogenyNodeField
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddMolecularSeqsToTree(Phylogeny phy, Msa msa)static DescriptiveStatisticscalculateBranchLengthStatistics(Phylogeny phy)static java.util.List<DescriptiveStatistics>calculateConfidenceStatistics(Phylogeny phy)static doublecalculateDistance(PhylogenyNode node1, PhylogenyNode node2)Calculates the distance between PhylogenyNodes node1 and node2.static PhylogenyNodecalculateLCA(PhylogenyNode node1, PhylogenyNode node2)Returns the LCA of PhylogenyNodes node1 and node2.static PhylogenyNodecalculateLCAonTreeWithIdsInPreOrder(PhylogenyNode node1, PhylogenyNode node2)Returns the LCA of PhylogenyNodes node1 and node2.static shortcalculateMaxBranchesToLeaf(PhylogenyNode node)static intcalculateMaxDepth(Phylogeny phy)static doublecalculateMaxDistanceToRoot(Phylogeny phy)static PhylogenyNodecalculateNodeWithMaxDistanceToRoot(Phylogeny phy)static DescriptiveStatisticscalculateNumberOfDescendantsPerNodeStatistics(Phylogeny phy)static intcalculateNumberOfExternalNodesWithoutTaxonomy(PhylogenyNode node)java.lang.Objectclone()static voidcollapseSubtreeStructure(PhylogenyNode n)static intcountNumberOfOneDescendantNodes(Phylogeny phy)static intcountNumberOfPolytomies(Phylogeny phy)static java.util.HashMap<java.lang.String,PhylogenyNode>createNameToExtNodeMap(Phylogeny phy)static voiddeleteExternalNodesNegativeSelection(java.lang.String[] node_names_to_delete, Phylogeny p)static voiddeleteExternalNodesNegativeSelection(java.util.Set<java.lang.Long> to_delete, Phylogeny phy)static java.util.List<java.lang.String>deleteExternalNodesPositiveSelection(java.lang.String[] node_names_to_keep, Phylogeny p)static voiddeleteExternalNodesPositiveSelectionT(java.util.List<Taxonomy> species_to_keep, Phylogeny phy)static voiddeleteInternalNodesWithOnlyOneDescendent(Phylogeny phy)static voiddeleteNonOrthologousExternalNodes(Phylogeny phy, PhylogenyNode n)static java.util.List<java.util.List<PhylogenyNode>>divideIntoSubTrees(Phylogeny phy, double min_distance_to_root)static booleanextractFastaInformation(Phylogeny phy)static java.util.List<PhylogenyNode>getAllDescendants(PhylogenyNode node)static java.awt.ColorgetBranchColorValue(PhylogenyNode node)Convenience methodstatic doublegetBranchWidthValue(PhylogenyNode node)Convenience methodstatic doublegetConfidenceValue(PhylogenyNode node)Convenience methodstatic double[]getConfidenceValuesAsArray(PhylogenyNode node)Convenience methodstatic EventgetEventAtLCA(PhylogenyNode n1, PhylogenyNode n2)static TaxonomygetExternalDescendantsTaxonomy(PhylogenyNode node)Returns taxonomy t if all external descendants have the same taxonomy t, null otherwise.static PhylogenyNodegetFurthestDescendant(PhylogenyNode node)static doublegetMaximumConfidenceValue(Phylogeny phy)Returns the largest confidence value found on phy.static intgetMinimumDescendentsPerInternalNodes(Phylogeny phy)static java.lang.StringgetSpecies(PhylogenyNode node)Convenience method for display purposes.static java.lang.StringgetTaxonomyIdentifier(PhylogenyNode node)Convenience method for display purposes.static booleanisAllDecendentsAreDuplications(PhylogenyNode n)static booleanisHasExternalDescendant(PhylogenyNode node)static booleanisInternalNamesLookLikeConfidences(Phylogeny phy)static booleanisTaxonomyHasIdentifierOfGivenProvider(Taxonomy tax, java.lang.String[] providers)static voidmidpointRoot(Phylogeny phylogeny)static voidnormalizeBootstrapValues(Phylogeny phylogeny, double max_bootstrap_value, double max_normalized_value)static java.util.List<PhylogenyNode>obtainAllNodesAsList(Phylogeny phy)static java.util.Map<Taxonomy,java.lang.Integer>obtainDistinctTaxonomyCounts(PhylogenyNode node)Returns a map of distinct taxonomies of all external nodes of node.static voidorderAppearance(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 voidpostorderBranchColorAveragingExternalNodeBased(Phylogeny p)static voidpreOrderReId(Phylogeny phy)static Phylogeny[]readPhylogenies(PhylogenyParser parser, java.io.File file)static Phylogeny[]readPhylogenies(PhylogenyParser parser, java.util.List<java.io.File> files)static voidremoveNode(PhylogenyNode remove_me, Phylogeny phylogeny)static java.util.List<PhylogenyNode>searchData(java.lang.String query, Phylogeny phy, boolean case_sensitive, boolean partial, boolean regex, boolean search_domains, double domains_confidence_threshold)static java.util.List<PhylogenyNode>searchDataLogicalAnd(java.lang.String[] queries, Phylogeny phy, boolean case_sensitive, boolean partial, boolean search_domains, double domains_confidence_threshold)static voidsetAllIndicatorsToZero(Phylogeny phy)static voidsetBootstrapConfidence(PhylogenyNode node, double bootstrap_confidence_value)Convenience method.static voidsetBranchColorValue(PhylogenyNode node, java.awt.Color color)static voidsetBranchWidthValue(PhylogenyNode node, double branch_width_value)Convenience methodstatic voidsetConfidence(PhylogenyNode node, double confidence_value)Convenience method.static voidsetConfidence(PhylogenyNode node, double confidence_value, java.lang.String type)Convenience method.static voidsetScientificName(PhylogenyNode node, java.lang.String scientific_name)static voidsetTaxonomyCode(PhylogenyNode node, java.lang.String taxonomy_code)Convenience method to set the taxonomy code of a phylogeny node.static voidsortNodeDescendents(PhylogenyNode node, PhylogenyMethods.DESCENDANT_SORT_PRIORITY pri)static java.util.List<PhylogenyNode>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 voidtransferInternalNamesToBootstrapSupport(Phylogeny phy)static voidtransferInternalNodeNamesToConfidence(Phylogeny phy, java.lang.String confidence_type)static voidtransferNodeNameToField(Phylogeny phy, PhylogenyMethods.PhylogenyNodeField field, boolean external_only)
-
-
-
Method Detail
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
extractFastaInformation
public static boolean extractFastaInformation(Phylogeny phy)
-
calculateBranchLengthStatistics
public static DescriptiveStatistics calculateBranchLengthStatistics(Phylogeny phy)
-
calculateConfidenceStatistics
public static java.util.List<DescriptiveStatistics> calculateConfidenceStatistics(Phylogeny phy)
-
calculateDistance
public static double calculateDistance(PhylogenyNode node1, PhylogenyNode node2)
Calculates the distance between PhylogenyNodes node1 and node2.- Parameters:
node1-node2-- Returns:
- distance between node1 and node2
-
calculateLCA
public static final PhylogenyNode calculateLCA(PhylogenyNode node1, PhylogenyNode node2)
Returns the LCA of PhylogenyNodes node1 and node2.- Parameters:
node1-node2-- Returns:
- LCA of node1 and node2
-
calculateLCAonTreeWithIdsInPreOrder
public static final PhylogenyNode calculateLCAonTreeWithIdsInPreOrder(PhylogenyNode node1, PhylogenyNode node2)
Returns the LCA of PhylogenyNodes node1 and node2. Precondition: ids are in pre-order (or level-order).- Parameters:
node1-node2-- Returns:
- LCA of node1 and node2
-
calculateMaxBranchesToLeaf
public static short calculateMaxBranchesToLeaf(PhylogenyNode node)
-
calculateMaxDepth
public static int calculateMaxDepth(Phylogeny phy)
-
calculateMaxDistanceToRoot
public static double calculateMaxDistanceToRoot(Phylogeny phy)
-
calculateNodeWithMaxDistanceToRoot
public static PhylogenyNode calculateNodeWithMaxDistanceToRoot(Phylogeny phy)
-
calculateNumberOfExternalNodesWithoutTaxonomy
public static int calculateNumberOfExternalNodesWithoutTaxonomy(PhylogenyNode node)
-
calculateNumberOfDescendantsPerNodeStatistics
public static DescriptiveStatistics calculateNumberOfDescendantsPerNodeStatistics(Phylogeny phy)
-
collapseSubtreeStructure
public static final void collapseSubtreeStructure(PhylogenyNode n)
-
countNumberOfOneDescendantNodes
public static int countNumberOfOneDescendantNodes(Phylogeny phy)
-
countNumberOfPolytomies
public static int countNumberOfPolytomies(Phylogeny phy)
-
createNameToExtNodeMap
public static final java.util.HashMap<java.lang.String,PhylogenyNode> createNameToExtNodeMap(Phylogeny phy)
-
deleteExternalNodesNegativeSelection
public static void deleteExternalNodesNegativeSelection(java.util.Set<java.lang.Long> 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 java.util.List<java.lang.String> deleteExternalNodesPositiveSelection(java.lang.String[] node_names_to_keep, Phylogeny p)
-
deleteExternalNodesPositiveSelectionT
public static void deleteExternalNodesPositiveSelectionT(java.util.List<Taxonomy> species_to_keep, Phylogeny phy)
-
deleteInternalNodesWithOnlyOneDescendent
public static final void deleteInternalNodesWithOnlyOneDescendent(Phylogeny phy)
-
deleteNonOrthologousExternalNodes
public static final void deleteNonOrthologousExternalNodes(Phylogeny phy, PhylogenyNode n)
-
divideIntoSubTrees
public static final java.util.List<java.util.List<PhylogenyNode>> divideIntoSubTrees(Phylogeny phy, double min_distance_to_root)
-
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
-
getEventAtLCA
public static final Event getEventAtLCA(PhylogenyNode n1, PhylogenyNode n2)
-
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)
-
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.
-
getTaxonomyIdentifier
public static java.lang.String getTaxonomyIdentifier(PhylogenyNode node)
Convenience method for display purposes. Not intended for algorithms.
-
isAllDecendentsAreDuplications
public static final boolean isAllDecendentsAreDuplications(PhylogenyNode n)
-
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)
-
obtainDistinctTaxonomyCounts
public static java.util.Map<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.
-
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 orderpri-
-
postorderBranchColorAveragingExternalNodeBased
public static void postorderBranchColorAveragingExternalNodeBased(Phylogeny p)
-
preOrderReId
public static final void preOrderReId(Phylogeny phy)
-
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
-
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, boolean regex, boolean search_domains, double domains_confidence_threshold)
-
searchDataLogicalAnd
public static java.util.List<PhylogenyNode> searchDataLogicalAnd(java.lang.String[] queries, Phylogeny phy, boolean case_sensitive, boolean partial, boolean search_domains, double domains_confidence_threshold)
-
setAllIndicatorsToZero
public static void setAllIndicatorsToZero(Phylogeny phy)
-
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
-
sortNodeDescendents
public static final void sortNodeDescendents(PhylogenyNode node, PhylogenyMethods.DESCENDANT_SORT_PRIORITY pri)
-
taxonomyBasedDeletionOfExternalNodes
public static java.util.List<PhylogenyNode> 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 Phylogenyto_be_stripped- Phylogeny to be stripped- Returns:
- nodes removed from to_be_stripped
-
transferInternalNamesToBootstrapSupport
public static final void transferInternalNamesToBootstrapSupport(Phylogeny phy)
-
isInternalNamesLookLikeConfidences
public static final boolean isInternalNamesLookLikeConfidences(Phylogeny phy)
-
transferInternalNodeNamesToConfidence
public static final void transferInternalNodeNamesToConfidence(Phylogeny phy, java.lang.String confidence_type)
-
transferNodeNameToField
public static final void transferNodeNameToField(Phylogeny phy, PhylogenyMethods.PhylogenyNodeField field, boolean external_only) throws PhyloXmlDataFormatException
- Throws:
PhyloXmlDataFormatException
-
-