"rio" work
authorcmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 14 Dec 2012 23:12:08 +0000 (23:12 +0000)
committercmzmasek@gmail.com <cmzmasek@gmail.com@ca865154-3058-d1c3-3e42-d8f55a55bdbd>
Fri, 14 Dec 2012 23:12:08 +0000 (23:12 +0000)
forester/java/src/org/forester/application/rio.java
forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java
forester/java/src/org/forester/rio/RIO.java
forester/java/src/org/forester/sdi/GSDIR.java
forester/java/src/org/forester/util/ForesterConstants.java

index 8ff6def..b95c032 100644 (file)
@@ -52,8 +52,8 @@ import org.forester.util.ForesterUtil;
 public class rio {
 
     final static private String PRG_NAME      = "rio";
-    final static private String PRG_VERSION   = "4.000 beta 1";
-    final static private String PRG_DATE      = "2012.12.11";
+    final static private String PRG_VERSION   = "4.000 beta 2";
+    final static private String PRG_DATE      = "2012.12.14";
     final static private String E_MAIL        = "czmasek@burnham.org";
     final static private String WWW           = "www.phylosoft.org/forester/";
     final static private String HELP_OPTION_1 = "help";
index 7c09e44..14b480f 100644 (file)
@@ -1294,13 +1294,13 @@ public final class MainFrameApplication extends MainFrame {
             AptxUtil.unexpectedException( e );
             return;
         }
-        final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTrees().get( 0 );
+        final List<Phylogeny> assigned_trees = gsdir.getMinDuplicationsSumGeneTrees();
+        final List<Integer> shortests = GSDIR.getIndexesOfShortestTree( assigned_trees );
+        final Phylogeny result_gene_tree = assigned_trees.get( shortests.get( 0 ) );
         result_gene_tree.setRerootable( false );
         result_gene_tree.clearHashIdToNodeMap();
         result_gene_tree.recalculateNumberOfExternalDescendants( true );
         _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
-        //_mainpanel.getCurrentTreePanel().setTree( gene_tree );
-        // _mainpanel.getCurrentTreePanel().setEdited( true );
         getControlPanel().setShowEvents( true );
         showWhole();
         final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
@@ -1310,10 +1310,11 @@ public final class MainFrameApplication extends MainFrame {
         showWhole();
         _mainpanel.getCurrentTreePanel().setEdited( true );
         JOptionPane.showMessageDialog( this,
-                                       "Duplications: " + gsdir.getMinDuplicationsSum() + "\n" + "Speciations: "
+                                       "Duplications (min): " + gsdir.getMinDuplicationsSum() + "\n" + "Speciations: "
                                                + gsdir.getSpeciationsSum() + "\n"
                                                + "Number of root positions minimizing duplications sum: "
-                                               + gsdir.getMinDuplicationsSumGeneTrees().size(),
+                                               + gsdir.getMinDuplicationsSumGeneTrees().size() + "\n"
+                                               + "Number of shortest trees: " + shortests.size(),
                                        "GSDIR successfully completed",
                                        JOptionPane.INFORMATION_MESSAGE );
     }
index a42d1f5..053927d 100644 (file)
@@ -202,12 +202,8 @@ public final class RIO {
                 break;
             }
             case GSDIR: {
-                //  System.out.println( "gene/species tree size before: " + gene_tree.getNumberOfExternalNodes() + "/"
-                //         + species_tree.getNumberOfExternalNodes() );
                 final GSDIR gsdir = new GSDIR( gene_tree, species_tree, true, i == 0 );
-                // System.out.println( "gene/species tree size before: " + gene_tree.getNumberOfExternalNodes() + "/"
-                //         + species_tree.getNumberOfExternalNodes() );
-                assigned_tree = gsdir.getMinDuplicationsSumGeneTrees().get( 0 );
+                final List<Phylogeny> assigned_trees = gsdir.getMinDuplicationsSumGeneTrees();
                 if ( i == 0 ) {
                     _removed_gene_tree_nodes = gsdir.getStrippedExternalGeneTreeNodes();
                     for( final PhylogenyNode r : _removed_gene_tree_nodes ) {
@@ -217,8 +213,10 @@ public final class RIO {
                         }
                     }
                 }
+                final List<Integer> shortests = GSDIR.getIndexesOfShortestTree( assigned_trees );
+                assigned_tree = assigned_trees.get( shortests.get( 0 ) );
                 if ( _produce_log ) {
-                    writeStatsToLog( i, gsdir );
+                    writeStatsToLog( i, gsdir, shortests );
                 }
                 _gsdir_tax_comp_base = gsdir.getTaxCompBase();
                 break;
@@ -248,11 +246,13 @@ public final class RIO {
         _log.append( "min" );
         _log.append( "-" );
         _log.append( "max" );
-        _log.append( "]" );
+        _log.append( "]\t<" );
+        _log.append( "shortest" );
+        _log.append( ">" );
         _log.append( ForesterUtil.LINE_SEPARATOR );
     }
 
-    private final void writeStatsToLog( final int i, final GSDIR gsdir ) {
+    private final void writeStatsToLog( final int i, final GSDIR gsdir, final List<Integer> shortests ) {
         final BasicDescriptiveStatistics stats = gsdir.getDuplicationsSumStats();
         _log.append( i );
         _log.append( "\t" );
@@ -263,7 +263,9 @@ public final class RIO {
         _log.append( ( int ) stats.getMin() );
         _log.append( "-" );
         _log.append( ( int ) stats.getMax() );
-        _log.append( "]" );
+        _log.append( "]\t<" );
+        _log.append( shortests.size() );
+        _log.append( ">" );
         _log.append( ForesterUtil.LINE_SEPARATOR );
     }
 
index 611ef4a..c211c42 100644 (file)
@@ -143,4 +143,34 @@ public class GSDIR implements GSDII {
     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
index 6de8057..bff716b 100644 (file)
@@ -27,8 +27,8 @@ package org.forester.util;
 
 public final class ForesterConstants {
 
-    public final static String  FORESTER_VERSION            = "1.010";
-    public final static String  FORESTER_DATE               = "121211";
+    public final static String  FORESTER_VERSION            = "1.011";
+    public final static String  FORESTER_DATE               = "121214";
     public final static String  PHYLO_XML_VERSION           = "1.10";
     public final static String  PHYLO_XML_LOCATION          = "http://www.phyloxml.org";
     public final static String  PHYLO_XML_XSD               = "phyloxml.xsd";