moved from itext 2.1.7 to itextpdf 5.1.0
[jalview.git] / forester / java / src / org / forester / archaeopteryx / Util.java
index d347ab1..408a3d7 100644 (file)
@@ -67,9 +67,10 @@ import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
 import org.forester.phylogeny.factories.PhylogenyFactory;
 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
 import org.forester.phylogeny.iterators.PreorderTreeIterator;
+import org.forester.util.DescriptiveStatistics;
 import org.forester.util.ForesterUtil;
 
-final class Util {
+public final class Util {
 
     private final static String[] AVAILABLE_FONT_FAMILIES_SORTED = GraphicsEnvironment.getLocalGraphicsEnvironment()
                                                                          .getAvailableFontFamilyNames();
@@ -308,37 +309,79 @@ final class Util {
         }
     }
 
-    final static String createDescriptionForTab( final Phylogeny phy, final String full_path ) {
+    final static String crateBasicInformation( final Phylogeny phy ) {
         final StringBuilder desc = new StringBuilder();
         if ( ( phy != null ) && !phy.isEmpty() ) {
             if ( !ForesterUtil.isEmpty( phy.getName() ) ) {
-                desc.append( "name: " );
+                desc.append( "Name: " );
                 desc.append( phy.getName() );
-                desc.append( "; " );
+                desc.append( "\n" );
             }
             if ( phy.getIdentifier() != null ) {
-                desc.append( "id: " );
+                desc.append( "Id: " );
                 desc.append( phy.getIdentifier() );
-                desc.append( "; " );
+                desc.append( "\n" );
             }
-            desc.append( "rooted: " );
+            desc.append( "Rooted: " );
             desc.append( phy.isRooted() );
-            desc.append( "; " );
-            desc.append( "rerootable: " );
+            desc.append( "\n" );
+            desc.append( "Rerootable: " );
             desc.append( phy.isRerootable() );
-            desc.append( "; " );
-            desc.append( "external nodes: " );
+            desc.append( "\n" );
+            desc.append( "Node sum: " );
+            desc.append( phy.getNodeCount() );
+            desc.append( "\n" );
+            desc.append( "External node sum: " );
             desc.append( phy.getNumberOfExternalNodes() );
-            desc.append( "; " );
-            desc.append( "branches: " );
+            desc.append( "\n" );
+            desc.append( "Internal node sum: " );
+            desc.append( phy.getNodeCount() - phy.getNumberOfExternalNodes() );
+            desc.append( "\n" );
+            desc.append( "Branche sum: " );
             desc.append( phy.getNumberOfBranches() );
-            desc.append( "; " );
-            desc.append( "maximum descendants: " );
-            desc.append( PhylogenyMethods.calculateMaximumNumberOfDescendantsPerNode( phy ) );
-            if ( !ForesterUtil.isEmpty( full_path ) && ( full_path.length() <= 50 ) ) {
-                desc.append( "; " );
-                desc.append( "path: " );
-                desc.append( full_path );
+            desc.append( "\n" );
+            desc.append( "Depth: " );
+            desc.append( PhylogenyMethods.calculateMaxDepth( phy ) );
+            desc.append( "\n" );
+            desc.append( "Maximum distance to root: " );
+            desc.append( ForesterUtil.round( PhylogenyMethods.calculateMaxDistanceToRoot( phy ), 6 ) );
+            desc.append( "\n" );
+            desc.append( "Descendants per node statistics: " );
+            final DescriptiveStatistics ds = PhylogenyMethods.calculatNumberOfDescendantsPerNodeStatistics( phy );
+            desc.append( "\n" );
+            desc.append( "    Median: " + ForesterUtil.round( ds.median(), 2 ) );
+            desc.append( "\n" );
+            desc.append( "    Mean: " + ForesterUtil.round( ds.arithmeticMean(), 2 ) );
+            desc.append( "\n" );
+            desc.append( "    SD: " + ForesterUtil.round( ds.sampleStandardDeviation(), 2 ) );
+            desc.append( "\n" );
+            desc.append( "    Minimum: " + ForesterUtil.roundToInt( ds.getMin() ) );
+            desc.append( "\n" );
+            desc.append( "    Maximum: " + ForesterUtil.roundToInt( ds.getMax() ) );
+            desc.append( "\n" );
+            final DescriptiveStatistics cs = PhylogenyMethods.calculatConfidenceStatistics( phy );
+            if ( cs.getN() > 1 ) {
+                desc.append( "Support statistics: " );
+                desc.append( "\n" );
+                desc.append( "    Branches with support: " + cs.getN() );
+                desc.append( "\n" );
+                desc.append( "    Median: " + ForesterUtil.round( cs.median(), 6 ) );
+                desc.append( "\n" );
+                desc.append( "    Mean: " + ForesterUtil.round( cs.arithmeticMean(), 6 ) );
+                desc.append( "\n" );
+                if ( cs.getN() > 2 ) {
+                    desc.append( "    SD: " + ForesterUtil.round( cs.sampleStandardDeviation(), 6 ) );
+                    desc.append( "\n" );
+                }
+                desc.append( "    Minimum: " + ForesterUtil.roundToInt( cs.getMin() ) );
+                desc.append( "\n" );
+                desc.append( "    Maximum: " + ForesterUtil.roundToInt( cs.getMax() ) );
+                desc.append( "\n" );
+            }
+            final Set<Taxonomy> taxs = PhylogenyMethods.obtainDistinctTaxonomies( phy.getRoot() );
+            if ( taxs != null ) {
+                desc.append( "Distinct external taxonomies: " );
+                desc.append( taxs.size() );
             }
         }
         return desc.toString();
@@ -571,7 +614,7 @@ final class Util {
         System.out.println( "[" + applet_name + "] > " + message );
     }
 
-    final static void printWarningMessage( final String name, final String message ) {
+    public final static void printWarningMessage( final String name, final String message ) {
         System.out.println( "[" + name + "] > " + message );
     }