From: cmzmasek@gmail.com Date: Fri, 14 Dec 2012 23:12:08 +0000 (+0000) Subject: "rio" work X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=eb56c16825aa7d894fe610cabb1b1613c90d5fc8;p=jalview.git "rio" work --- diff --git a/forester/java/src/org/forester/application/rio.java b/forester/java/src/org/forester/application/rio.java index 8ff6def..b95c032 100644 --- a/forester/java/src/org/forester/application/rio.java +++ b/forester/java/src/org/forester/application/rio.java @@ -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"; diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 7c09e44..14b480f 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -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 assigned_trees = gsdir.getMinDuplicationsSumGeneTrees(); + final List 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 ); } diff --git a/forester/java/src/org/forester/rio/RIO.java b/forester/java/src/org/forester/rio/RIO.java index a42d1f5..053927d 100644 --- a/forester/java/src/org/forester/rio/RIO.java +++ b/forester/java/src/org/forester/rio/RIO.java @@ -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 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 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 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 ); } diff --git a/forester/java/src/org/forester/sdi/GSDIR.java b/forester/java/src/org/forester/sdi/GSDIR.java index 611ef4a..c211c42 100644 --- a/forester/java/src/org/forester/sdi/GSDIR.java +++ b/forester/java/src/org/forester/sdi/GSDIR.java @@ -143,4 +143,34 @@ public class GSDIR implements GSDII { public TaxonomyComparisonBase getTaxCompBase() { return _tax_comp_base; } + + public final static List getIndexesOfShortestTree( final List assigned_trees ) { + final List shortests = new ArrayList(); + boolean depth = true; + double x = Double.MAX_VALUE; + for( int i = 0; i < assigned_trees.size(); ++i ) { + final Phylogeny phy = assigned_trees.get( i ); + if ( i == 0 ) { + if ( PhylogenyMethods.calculateMaxDistanceToRoot( phy ) > 0 ) { + depth = false; + } + } + final double d; + if ( depth ) { + d = PhylogenyMethods.calculateMaxDepth( phy ); + } + else { + d = PhylogenyMethods.calculateMaxDistanceToRoot( phy ); + } + if ( d < x ) { + x = d; + shortests.clear(); + shortests.add( i ); + } + else if ( d == x ) { + shortests.add( i ); + } + } + return shortests; + } } diff --git a/forester/java/src/org/forester/util/ForesterConstants.java b/forester/java/src/org/forester/util/ForesterConstants.java index 6de8057..bff716b 100644 --- a/forester/java/src/org/forester/util/ForesterConstants.java +++ b/forester/java/src/org/forester/util/ForesterConstants.java @@ -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";