inprogress
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Sat, 22 Dec 2012 05:33:40 +0000 (05:33 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Sat, 22 Dec 2012 05:33:40 +0000 (05:33 +0000)
forester/java/src/org/forester/application/rio.java
forester/java/src/org/forester/archaeopteryx/AptxUtil.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/io/parsers/nexus/NexusPhylogeniesParser.java
forester/java/src/org/forester/phylogeny/Phylogeny.java
forester/java/src/org/forester/rio/RIO.java
forester/java/src/org/forester/util/ForesterUtil.java

index 01a5d6b..98fd473 100644 (file)
@@ -283,12 +283,18 @@ public class rio {
             final BasicDescriptiveStatistics stats = rio.getDuplicationsStatistics();
             final java.text.DecimalFormat df = new java.text.DecimalFormat( "0.#" );
             System.out.println( "Mean number of duplications  : " + df.format( stats.arithmeticMean() ) + " (sd: "
-                    + df.format( stats.sampleStandardDeviation() ) + ")" );
+                    + df.format( stats.sampleStandardDeviation() ) + ") ("
+                    + df.format( 100.0 * stats.arithmeticMean() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
             if ( stats.getN() > 3 ) {
-                System.out.println( "Median number of duplications: " + df.format( stats.median() ) );
+                System.out.println( "Median number of duplications: " + df.format( stats.median() ) + " ("
+                        + df.format( 100.0 * stats.median() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
             }
-            System.out.println( "Minimum duplications         : " + ( int ) stats.getMin() );
-            System.out.println( "Maximum duplications         : " + ( int ) stats.getMax() );
+            System.out.println( "Minimum duplications         : " + ( int ) stats.getMin() + " ("
+                    + df.format( 100.0 * stats.getMin() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+            System.out.println( "Maximum duplications         : " + ( int ) stats.getMax() + " ("
+                    + df.format( 100.0 * stats.getMax() / rio.getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+            System.out.println( "Gene tree internal nodes     : " + rio.getIntNodesOfAnalyzedGeneTrees() );
+            System.out.println( "Gene tree external nodes     : " + rio.getExtNodesOfAnalyzedGeneTrees() );
         }
         catch ( final RIOException e ) {
             ForesterUtil.fatalError( e.getLocalizedMessage() );
index 1f7af11..97e8304 100644 (file)
@@ -949,7 +949,7 @@ public final class AptxUtil {
 
     final static void unexpectedError( final Error e ) {
         System.err.println();
-        e.printStackTrace(  System.err );
+        e.printStackTrace( System.err );
         System.err.println();
         final StringBuffer sb = new StringBuffer();
         for( final StackTraceElement s : e.getStackTrace() ) {
@@ -958,39 +958,41 @@ public final class AptxUtil {
         JOptionPane
                 .showMessageDialog( null,
                                     "An unexpected (possibly severe) error has occured - terminating. \nPlease contact: "
-                                            + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n" + sb,
+                                            + Constants.AUTHOR_EMAIL + " \nError: " + e.getLocalizedMessage() + "\n"
+                                            + sb,
                                     "Unexpected Severe Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
                                     JOptionPane.ERROR_MESSAGE );
         System.exit( -1 );
     }
-    
+
     final static void outOfMemoryError( final OutOfMemoryError e ) {
         System.err.println();
         System.err.println( "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option" );
         System.err.println();
         e.printStackTrace();
         System.err.println();
-        
-        JOptionPane
-                .showMessageDialog( null,
-                                    "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
-                                            + "\n\nError: " + e.getLocalizedMessage(),
-                                    "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
-                                    JOptionPane.ERROR_MESSAGE );
+        JOptionPane.showMessageDialog( null,
+                                       "Java memory allocation might be too small, try \"-Xmx2048m\" java command line option"
+                                               + "\n\nError: " + e.getLocalizedMessage(),
+                                       "Out of Memory Error [" + Constants.PRG_NAME + " " + Constants.VERSION + "]",
+                                       JOptionPane.ERROR_MESSAGE );
         System.exit( -1 );
     }
 
     final static void unexpectedException( final Exception e ) {
         System.err.println();
-        e.printStackTrace(  System.err );
+        e.printStackTrace( System.err );
         System.err.println();
         final StringBuffer sb = new StringBuffer();
         for( final StackTraceElement s : e.getStackTrace() ) {
             sb.append( s + "\n" );
         }
-        JOptionPane.showMessageDialog( null, "An unexpected exception has occured. \nPlease contact: "
-                + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage() + "\n" + sb, "Unexpected Exception ["
-                + Constants.PRG_NAME + Constants.VERSION + "]", JOptionPane.ERROR_MESSAGE );
+        JOptionPane.showMessageDialog( null,
+                                       "An unexpected exception has occured. \nPlease contact: "
+                                               + Constants.AUTHOR_EMAIL + " \nException: " + e.getLocalizedMessage()
+                                               + "\n" + sb,
+                                       "Unexpected Exception [" + Constants.PRG_NAME + Constants.VERSION + "]",
+                                       JOptionPane.ERROR_MESSAGE );
     }
 
     final static String writePhylogenyToGraphicsByteArrayOutputStream( final ByteArrayOutputStream baos,
index 2ccf1eb..fbe73f0 100644 (file)
@@ -268,7 +268,6 @@ public final class MainFrameApplication extends MainFrame {
         catch ( final IllegalAccessException e ) {
             AptxUtil.dieWithSystemError( "illegal access exception: " + e.toString() );
         }
-      
         if ( ( current_dir != null ) && current_dir.canRead() && current_dir.isDirectory() ) {
             setCurrentDir( current_dir );
         }
index ef4b4c3..f104de3 100644 (file)
@@ -43,6 +43,7 @@ import org.forester.io.parsers.util.ParserUtils;
 import org.forester.io.parsers.util.PhylogenyParserException;
 import org.forester.phylogeny.Phylogeny;
 import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Taxonomy;
 import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory;
 import org.forester.phylogeny.factories.PhylogenyFactory;
 import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
@@ -254,6 +255,16 @@ public class NexusPhylogeniesParser implements PhylogenyParser {
                         node.setName( getTaxlabels().get( i - 1 ).replaceAll( "['\"]+", "" ) );
                     }
                 }
+                if ( !isReplaceUnderscores() && ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) ) {
+                    final String tax = ParserUtils.extractTaxonomyCodeFromNodeName( node.getName(),
+                                                                                    getTaxonomyExtraction() );
+                    if ( !ForesterUtil.isEmpty( tax ) ) {
+                        if ( !node.getNodeData().isHasTaxonomy() ) {
+                            node.getNodeData().setTaxonomy( new Taxonomy() );
+                        }
+                        node.getNodeData().getTaxonomy().setTaxonomyCode( tax );
+                    }
+                }
             }
         }
         getPhylogenies().add( p );
index 038ea8b..9eb8d18 100644 (file)
@@ -556,6 +556,22 @@ public class Phylogeny {
         return c;
     }
 
+    public int getNumberOfInternalNodes() {
+        if ( isEmpty() ) {
+            return 0;
+        }
+        int c = 0;
+        for( final PhylogenyNodeIterator iter = iteratorPreorder(); iter.hasNext(); ) {
+            if ( iter.next().isInternal() ) {
+                ++c;
+            }
+        }
+        if ( !isRooted() ) {
+            --c;
+        }
+        return c;
+    }
+
     /**
      * Returns the sum of external Nodes of this Phylogeny (int).
      */
index 0ecb248..24b4c2a 100644 (file)
@@ -67,6 +67,7 @@ public final class RIO {
     private Phylogeny[]                      _analyzed_gene_trees;
     private List<PhylogenyNode>              _removed_gene_tree_nodes;
     private int                              _ext_nodes;
+    private int                              _int_nodes;
     private TaxonomyComparisonBase           _gsdir_tax_comp_base;
     private final StringBuilder              _log;
     private final BasicDescriptiveStatistics _duplications_stats;
@@ -95,6 +96,7 @@ public final class RIO {
         _verbose = verbose;
         _rerooting = rerooting;
         _ext_nodes = -1;
+        _int_nodes = -1;
         _log = new StringBuilder();
         _gsdir_tax_comp_base = null;
         _analyzed_gene_trees = null;
@@ -121,6 +123,16 @@ public final class RIO {
         return _ext_nodes;
     }
 
+    /**
+     * Returns the numbers of number of int nodes in gene trees analyzed (after
+     * stripping).
+     * 
+     * @return number of int nodes in gene trees analyzed (after stripping)
+     */
+    public final int getIntNodesOfAnalyzedGeneTrees() {
+        return _int_nodes;
+    }
+
     public final TaxonomyComparisonBase getGSDIRtaxCompBase() {
         return _gsdir_tax_comp_base;
     }
@@ -253,6 +265,7 @@ public final class RIO {
         }
         if ( i == 0 ) {
             _ext_nodes = assigned_tree.getNumberOfExternalNodes();
+            _int_nodes = assigned_tree.getNumberOfInternalNodes();
         }
         else if ( _ext_nodes != assigned_tree.getNumberOfExternalNodes() ) {
             throw new RIOException( "after stripping gene tree #" + ( i + 1 )
@@ -332,12 +345,19 @@ public final class RIO {
         final java.text.DecimalFormat df = new java.text.DecimalFormat( "0.#" );
         log( "Gene trees analyzed                             : " + _duplications_stats.getN() );
         log( "Mean number of duplications                     : " + df.format( _duplications_stats.arithmeticMean() )
-                + " (sd: " + df.format( _duplications_stats.sampleStandardDeviation() ) + ")" );
+                + " (sd: " + df.format( _duplications_stats.sampleStandardDeviation() ) + ")" + " ("
+                + df.format( 100.0 * _duplications_stats.arithmeticMean() / getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
         if ( _duplications_stats.getN() > 3 ) {
-            log( "Median number of duplications                   : " + df.format( _duplications_stats.median() ) );
-        }
-        log( "Minimum duplications                            : " + ( int ) _duplications_stats.getMin() );
-        log( "Maximum duplications                            : " + ( int ) _duplications_stats.getMax() );
+            log( "Median number of duplications                   : " + df.format( _duplications_stats.median() )
+                    + " (" + df.format( 100.0 * _duplications_stats.median() / getIntNodesOfAnalyzedGeneTrees() )
+                    + "%)" );
+        }
+        log( "Minimum duplications                            : " + ( int ) _duplications_stats.getMin() + " ("
+                + df.format( 100.0 * _duplications_stats.getMin() / getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+        log( "Maximum duplications                            : " + ( int ) _duplications_stats.getMax() + " ("
+                + df.format( 100.0 * _duplications_stats.getMax() / getIntNodesOfAnalyzedGeneTrees() ) + "%)" );
+        log( "Gene tree internal nodes                        : " + getIntNodesOfAnalyzedGeneTrees() );
+        log( "Gene tree external nodes                        : " + getExtNodesOfAnalyzedGeneTrees() );
     }
 
     private final void preLog( final Phylogeny[] gene_trees,
@@ -346,7 +366,7 @@ public final class RIO {
                                final String outgroup,
                                final int first,
                                final int last ) {
-        log( "Number of gene tree (total)                     : " + gene_trees.length );
+        log( "Number of gene trees (total)                    : " + gene_trees.length );
         log( "Algorithm                                       : " + algorithm );
         log( "Species tree external nodes (prior to stripping): " + species_tree.getNumberOfExternalNodes() );
         log( "Species tree polytomies (prior to stripping)    : "
index ba1af65..cb04e65 100644 (file)
@@ -938,7 +938,7 @@ public final class ForesterUtil {
         System.err.println();
         System.exit( -1 );
     }
-    
+
     final public static void unexpectedFatalError( final Error e ) {
         System.err.println();
         System.err.println( "unexpected error: should not have occured! Please contact program author(s)." );