+\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
+ }\r