+ @Override\r
+ public final SortedSet<String> getReMappedScientificNamesFromGeneTree() {\r
+ return _scientific_names_mapped_to_reduced_specificity;\r
+ }\r
+\r
+ @Override\r
+ public int getSpeciationsSum() {\r
+ return _speciations_sum;\r
+ }\r
+\r
+ @Override\r
+ public List<PhylogenyNode> getStrippedExternalGeneTreeNodes() {\r
+ return _stripped_gene_tree_nodes;\r
+ }\r
+\r
+ @Override\r
+ public List<PhylogenyNode> getStrippedSpeciesTreeNodes() {\r
+ return _stripped_species_tree_nodes;\r
+ }\r
+\r
+ @Override\r
+ public TaxonomyComparisonBase getTaxCompBase() {\r
+ return _tax_comp_base;\r
+ }\r
+\r
+ public final static List<Integer> getIndexesOfShortestTree( final List<Phylogeny> assigned_trees ) {\r
+ final List<Integer> shortests = new ArrayList<Integer>();\r
+ boolean depth = true;\r
+ double x = Double.MAX_VALUE;\r
+ for( int i = 0; i < assigned_trees.size(); ++i ) {\r
+ final Phylogeny phy = assigned_trees.get( i );\r
+ if ( i == 0 ) {\r
+ if ( PhylogenyMethods.calculateMaxDistanceToRoot( phy ) > 0 ) {\r
+ depth = false;\r
+ }\r
+ }\r
+ final double d;\r
+ if ( depth ) {\r
+ d = PhylogenyMethods.calculateMaxDepth( phy );\r
+ }\r
+ else {\r
+ d = PhylogenyMethods.calculateMaxDistanceToRoot( phy );\r
+ }\r
+ if ( d < x ) {\r
+ x = d;\r
+ shortests.clear();\r
+ shortests.add( i );\r
+ }\r
+ else if ( d == x ) {\r
+ shortests.add( i );\r
+ }\r
+ }\r
+ return shortests;\r
+ }\r
+\r
+ /**\r
+ * Places the root of this Phylogeny on Branch b. The new root is always\r
+ * placed on the middle of the branch b.\r
+ *\r
+ */\r
+ static final void reRoot( final PhylogenyBranch b, final Phylogeny phy ) {\r
+ final PhylogenyNode n1 = b.getFirstNode();\r
+ final PhylogenyNode n2 = b.getSecondNode();\r
+ if ( n1.isExternal() ) {\r
+ phy.reRoot( n1 );\r
+ }\r
+ else if ( n2.isExternal() ) {\r
+ phy.reRoot( n2 );\r
+ }\r
+ else if ( ( n2 == n1.getChildNode1() ) || ( n2 == n1.getChildNode2() ) ) {\r
+ phy.reRoot( n2 );\r
+ }\r
+ else if ( ( n1 == n2.getChildNode1() ) || ( n1 == n2.getChildNode2() ) ) {\r
+ phy.reRoot( n1 );\r
+ }\r
+ // else if ( ( n1.getParent() != null ) && n1.getParent().isRoot()\r
+ // && ( ( n1.getParent().getChildNode1() == n2 ) || ( n1.getParent().getChildNode2() == n2 ) ) ) {\r
+ // phy.reRoot( n1 );\r
+ //\r
+ // }\r
+ else {\r
+ throw new IllegalArgumentException( "reRoot( Branch b ): b is not a branch." );\r
+ }\r
+ }\r
+\r
+ private final static void transferTaxonomy( final Phylogeny gt ) {\r
+ for( final PhylogenyNodeIterator it = gt.iteratorPostorder(); it.hasNext(); ) {\r
+ GSDI.transferTaxonomy( it.next() );\r
+ }\r