From 8f8bbd46b51ab6778da479b6fa2a444b46ac3a60 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Wed, 9 Jan 2013 06:10:00 +0000 Subject: [PATCH] kepp only one dup min gt --- .../java/src/org/forester/application/gsdi.java | 5 +-- .../java/src/org/forester/application/rio.java | 2 +- .../archaeopteryx/MainFrameApplication.java | 9 +---- forester/java/src/org/forester/rio/RIO.java | 42 +------------------- forester/java/src/org/forester/sdi/GSDIR.java | 19 +++++---- .../src/org/forester/util/ForesterConstants.java | 2 +- 6 files changed, 17 insertions(+), 62 deletions(-) diff --git a/forester/java/src/org/forester/application/gsdi.java b/forester/java/src/org/forester/application/gsdi.java index 9e3f326..17dbf7e 100644 --- a/forester/java/src/org/forester/application/gsdi.java +++ b/forester/java/src/org/forester/application/gsdi.java @@ -288,10 +288,7 @@ public final class gsdi { try { final PhylogenyWriter writer = new PhylogenyWriter(); if ( base_algorithm == ALGORITHM.GSDIR ) { - writer.toPhyloXML( out_file, - ( ( GSDIR ) gsdii ).getMinDuplicationsSumGeneTrees(), - 0, - ForesterUtil.LINE_SEPARATOR ); + writer.toPhyloXML( out_file, ( ( GSDIR ) gsdii ).getMinDuplicationsSumGeneTree(), 0 ); } else { writer.toPhyloXML( out_file, gene_tree, 0 ); diff --git a/forester/java/src/org/forester/application/rio.java b/forester/java/src/org/forester/application/rio.java index 59553e6..c371af5 100644 --- a/forester/java/src/org/forester/application/rio.java +++ b/forester/java/src/org/forester/application/rio.java @@ -53,7 +53,7 @@ import org.forester.util.ForesterUtil; public class rio { final static private String PRG_NAME = "rio"; - final static private String PRG_VERSION = "4.000 beta 6"; + final static private String PRG_VERSION = "4.000 beta 7"; final static private String PRG_DATE = "2013.01.08"; final static private String E_MAIL = "phyloxml@gmail.com"; final static private String WWW = "https://sites.google.com/site/cmzmasek/home/software/forester"; diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index b50cbf2..d0b7949 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -1270,9 +1270,7 @@ public final class MainFrameApplication extends MainFrame { AptxUtil.unexpectedException( e ); return; } - final List assigned_trees = gsdir.getMinDuplicationsSumGeneTrees(); - final List shortests = GSDIR.getIndexesOfShortestTree( assigned_trees ); - final Phylogeny result_gene_tree = assigned_trees.get( shortests.get( 0 ) ); + final Phylogeny result_gene_tree = gsdir.getMinDuplicationsSumGeneTree(); result_gene_tree.setRerootable( false ); result_gene_tree.clearHashIdToNodeMap(); result_gene_tree.recalculateNumberOfExternalDescendants( true ); @@ -1287,10 +1285,7 @@ public final class MainFrameApplication extends MainFrame { _mainpanel.getCurrentTreePanel().setEdited( true ); JOptionPane.showMessageDialog( this, "Duplications (min): " + gsdir.getMinDuplicationsSum() + "\n" + "Speciations: " - + gsdir.getSpeciationsSum() + "\n" - + "Number of root positions minimizing duplications sum: " - + gsdir.getMinDuplicationsSumGeneTrees().size() + "\n" - + "Number of shortest trees: " + shortests.size(), + + gsdir.getSpeciationsSum(), "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 771d5e7..0cbe6dd 100644 --- a/forester/java/src/org/forester/rio/RIO.java +++ b/forester/java/src/org/forester/rio/RIO.java @@ -388,7 +388,7 @@ public final class RIO { final Phylogeny assigned_tree; if ( _rerooting == REROOTING.BY_ALGORITHM ) { final GSDIR gsdir = new GSDIR( gene_tree, species_tree, true, i == 0 ); - final List assigned_trees = gsdir.getMinDuplicationsSumGeneTrees(); + assigned_tree = gsdir.getMinDuplicationsSumGeneTree(); if ( i == 0 ) { _removed_gene_tree_nodes = gsdir.getStrippedExternalGeneTreeNodes(); for( final PhylogenyNode r : _removed_gene_tree_nodes ) { @@ -398,11 +398,6 @@ public final class RIO { } } } - final List shortests = GSDIR.getIndexesOfShortestTree( assigned_trees ); - assigned_tree = assigned_trees.get( shortests.get( 0 ) ); - if ( log() ) { - writeStatsToLog( i, gsdir, shortests ); - } if ( i == 0 ) { _gsdir_tax_comp_base = gsdir.getTaxCompBase(); } @@ -501,41 +496,6 @@ public final class RIO { } } log( "Re-rooting : " + rs ); - if ( _rerooting == REROOTING.BY_ALGORITHM ) { - writeLogSubHeader(); - } - } - - private final void writeLogSubHeader() { - _log.append( ForesterUtil.LINE_SEPARATOR ); - _log.append( "Some information about duplication numbers in gene trees:" ); - _log.append( ForesterUtil.LINE_SEPARATOR ); - _log.append( "#" ); - _log.append( "\t" ); - _log.append( "re-rootings with minimal number of duplications" ); - _log.append( "/" ); - _log.append( "total root placements" ); - _log.append( "\t" ); - _log.append( "duplications range" ); - _log.append( "\t" ); - _log.append( "mininal duplication re-rootings with shortest tree heigth" ); - _log.append( ForesterUtil.LINE_SEPARATOR ); - } - - private final void writeStatsToLog( final int i, final GSDIR gsdir, final List shortests ) { - final BasicDescriptiveStatistics stats = gsdir.getDuplicationsSumStats(); - _log.append( i ); - _log.append( "\t" ); - _log.append( gsdir.getMinDuplicationsSumGeneTrees().size() ); - _log.append( "/" ); - _log.append( stats.getN() ); - _log.append( "\t" ); - _log.append( ( int ) stats.getMin() ); - _log.append( "-" ); - _log.append( ( int ) stats.getMax() ); - _log.append( "\t" ); - _log.append( shortests.size() ); - _log.append( ForesterUtil.LINE_SEPARATOR ); } public final IntMatrix getOrthologTable() { diff --git a/forester/java/src/org/forester/sdi/GSDIR.java b/forester/java/src/org/forester/sdi/GSDIR.java index 602e9e2..8ada705 100644 --- a/forester/java/src/org/forester/sdi/GSDIR.java +++ b/forester/java/src/org/forester/sdi/GSDIR.java @@ -42,7 +42,7 @@ public class GSDIR implements GSDII { private final int _min_duplications_sum; private final int _speciations_sum; private final BasicDescriptiveStatistics _duplications_sum_stats; - private final List _min_duplications_sum_gene_trees; + private Phylogeny _min_duplications_sum_gene_tree; private final List _stripped_gene_tree_nodes; private final List _stripped_species_tree_nodes; private final Set _mapped_species_tree_nodes; @@ -72,7 +72,6 @@ public class GSDIR implements GSDII { } int min_duplications_sum = Integer.MAX_VALUE; int speciations_sum = 0; - _min_duplications_sum_gene_trees = new ArrayList(); _duplications_sum_stats = new BasicDescriptiveStatistics(); for( final PhylogenyBranch branch : gene_tree_branches_post_order ) { gene_tree.reRoot( branch ); @@ -88,12 +87,16 @@ public class GSDIR implements GSDII { if ( gsdi_result.getDuplicationsSum() < min_duplications_sum ) { min_duplications_sum = gsdi_result.getDuplicationsSum(); speciations_sum = gsdi_result.getSpeciationsSum(); - _min_duplications_sum_gene_trees.clear(); - _min_duplications_sum_gene_trees.add( gene_tree.copy() ); - //_speciations_sum + _min_duplications_sum_gene_tree = gene_tree.copy(); } else if ( gsdi_result.getDuplicationsSum() == min_duplications_sum ) { - _min_duplications_sum_gene_trees.add( gene_tree.copy() ); + final List l = new ArrayList(); + l.add( _min_duplications_sum_gene_tree ); + l.add( gene_tree ); + final int index = getIndexesOfShortestTree( l ).get( 0 ); + if ( index == 1 ) { + _min_duplications_sum_gene_tree = gene_tree.copy(); + } } _duplications_sum_stats.addValue( gsdi_result.getDuplicationsSum() ); } @@ -114,8 +117,8 @@ public class GSDIR implements GSDII { return _min_duplications_sum; } - public List getMinDuplicationsSumGeneTrees() { - return _min_duplications_sum_gene_trees; + public Phylogeny getMinDuplicationsSumGeneTree() { + return _min_duplications_sum_gene_tree; } @Override diff --git a/forester/java/src/org/forester/util/ForesterConstants.java b/forester/java/src/org/forester/util/ForesterConstants.java index 1f551d6..f147188 100644 --- a/forester/java/src/org/forester/util/ForesterConstants.java +++ b/forester/java/src/org/forester/util/ForesterConstants.java @@ -27,7 +27,7 @@ package org.forester.util; public final class ForesterConstants { - public final static String FORESTER_VERSION = "1.017"; + public final static String FORESTER_VERSION = "1.018"; public final static String FORESTER_DATE = "130108"; public final static String PHYLO_XML_VERSION = "1.10"; public final static String PHYLO_XML_LOCATION = "http://www.phyloxml.org"; -- 1.7.10.2