X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Ftools%2FSupportCount.java;h=283668ca09cbdd254f74f6e89f0cdc0f77f0a7e3;hb=01d681ced8f186561a3dd76715d950bd0eabd82d;hp=a3c7fa8e0f362652110b1bf7787cc06b37e903d2;hpb=48f7a89be9d34f1930a1f863e608235cc27184c5;p=jalview.git diff --git a/forester/java/src/org/forester/tools/SupportCount.java b/forester/java/src/org/forester/tools/SupportCount.java index a3c7fa8..283668c 100644 --- a/forester/java/src/org/forester/tools/SupportCount.java +++ b/forester/java/src/org/forester/tools/SupportCount.java @@ -5,7 +5,7 @@ // Copyright (C) 2008-2009 Christian M. Zmasek // Copyright (C) 2008-2009 Burnham Institute for Medical Research // All rights reserved -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -15,13 +15,13 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA // // Contact: phylosoft @ gmail . com -// WWW: www.phylosoft.org/forester +// WWW: https://sites.google.com/site/cmzmasek/home/software/forester package org.forester.tools; @@ -33,6 +33,7 @@ import java.util.NoSuchElementException; import org.forester.phylogeny.Phylogeny; import org.forester.phylogeny.PhylogenyMethods; +import org.forester.phylogeny.PhylogenyMethods.DESCENDANT_SORT_PRIORITY; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.iterators.PhylogenyNodeIterator; @@ -63,7 +64,7 @@ public final class SupportCount { phylogeny.reRoot( phylogeny.getNode( child0_name ) ); evaluator_phylogeny.reRoot( evaluator_phylogeny.getNode( child0_name ) ); } - final Map> phylogeny_external_names_per_node = SupportCount + final Map> phylogeny_external_names_per_node = SupportCount .extractExternalNamesPerNode( phylogeny ); return ( SupportCount.compare( phylogeny, evaluator_phylogeny, @@ -96,7 +97,7 @@ public final class SupportCount { */ private static double compare( final Phylogeny phylogeny, final Phylogeny evaluator_phylogeny, - final Map> phylogeny_external_names_per_node, + final Map> phylogeny_external_names_per_node, final boolean update_support_in_phylogeny, final double similarity_threshold ) { int matching_branches = 0; @@ -113,7 +114,7 @@ public final class SupportCount { for( final Object element : evaluator_phylogeny_it.next().getAllExternalDescendants() ) { c1.add( ( ( PhylogenyNode ) element ).getName() ); } - for( final Integer id : phylogeny_external_names_per_node.keySet() ) { + for( final Long id : phylogeny_external_names_per_node.keySet() ) { final List c2 = phylogeny_external_names_per_node.get( id ); if ( ( c2.size() == c1.size() ) && c2.containsAll( c1 ) ) { if ( c2.size() > 1 ) { @@ -180,7 +181,7 @@ public final class SupportCount { } final String child0_name = phylogeny.getFirstExternalNode().getName(); phylogeny.reRoot( phylogeny.getNode( child0_name ) ); - final Map> phylogeny_external_names_per_node = SupportCount + final Map> phylogeny_external_names_per_node = SupportCount .extractExternalNamesPerNode( phylogeny ); if ( verbose ) { System.out.println(); @@ -195,11 +196,17 @@ public final class SupportCount { if ( strip_evaluator_phylogenies ) { unstripped_evaluator_phylogeny = evaluator_phylogeny.copy(); SupportCount.strip( seq_names_to_keep, evaluator_phylogeny ); - evaluator_phylogeny.orderAppearance( true ); // This is for + PhylogenyMethods.orderAppearance( evaluator_phylogeny.getRoot(), + true, + true, + DESCENDANT_SORT_PRIORITY.TAXONOMY ); // This is for // easer // comparison if // phylos are saved // to file. + evaluator_phylogeny.externalNodesHaveChanged(); + evaluator_phylogeny.clearHashIdToNodeMap(); + evaluator_phylogeny.recalculateNumberOfExternalDescendants( true ); } final double s = SupportCount.compare( phylogeny, evaluator_phylogenies[ i ], @@ -207,7 +214,10 @@ public final class SupportCount { true, similarity_threshold ); if ( ( similarity_threshold < 0.0 ) || ( s >= similarity_threshold ) ) { - unstripped_evaluator_phylogeny.orderAppearance( true ); + PhylogenyMethods.orderAppearance( unstripped_evaluator_phylogeny.getRoot(), + true, + true, + DESCENDANT_SORT_PRIORITY.TAXONOMY ); evaluator_phylogenies_above_threshold.add( unstripped_evaluator_phylogeny ); } if ( verbose ) { @@ -229,14 +239,14 @@ public final class SupportCount { return evaluator_phylogenies_above_threshold; } - private static Map> extractExternalNamesPerNode( final Phylogeny phylogeny ) + private static Map> extractExternalNamesPerNode( final Phylogeny phylogeny ) throws NoSuchElementException { - final HashMap> phylogeny_external_names_per_node = new HashMap>(); + final HashMap> phylogeny_external_names_per_node = new HashMap>(); for( final PhylogenyNodeIterator it = phylogeny.iteratorPostorder(); it.hasNext(); ) { final PhylogenyNode n = it.next(); final List l = n.getAllExternalDescendants(); final ArrayList c = new ArrayList(); - phylogeny_external_names_per_node.put( new Integer( n.getId() ), c ); + phylogeny_external_names_per_node.put( new Long( n.getId() ), c ); for( final PhylogenyNode phylogenyNode : l ) { c.add( phylogenyNode.getName() ); }