From 5153a2068e56d7be22cc844ce9682633eb31b178 Mon Sep 17 00:00:00 2001 From: cmzmasek Date: Wed, 23 Aug 2017 11:52:34 -0700 Subject: [PATCH] in progress... --- .../org/forester/clade_analysis/AnalysisMulti.java | 6 +-- .../src/org/forester/clade_analysis/Prefix.java | 39 ++++++++------- .../org/forester/clade_analysis/ResultMulti.java | 50 ++++++++++---------- 3 files changed, 49 insertions(+), 46 deletions(-) diff --git a/forester/java/src/org/forester/clade_analysis/AnalysisMulti.java b/forester/java/src/org/forester/clade_analysis/AnalysisMulti.java index 219588c..d920d77 100644 --- a/forester/java/src/org/forester/clade_analysis/AnalysisMulti.java +++ b/forester/java/src/org/forester/clade_analysis/AnalysisMulti.java @@ -73,7 +73,7 @@ public final class AnalysisMulti { final ResultMulti res = new ResultMulti(); for( int i = 0; i < qnodes.size(); ++i ) { final PhylogenyNode qnode = qnodes.get( i ); - System.out.println( ">>" + qnode.getName() ); + //System.out.println( ">>" + qnode.getName() ); if ( qnode.isRoot() ) { throw new IllegalArgumentException( "Query " + query + " is root." ); } @@ -119,7 +119,7 @@ public final class AnalysisMulti { } //final String greatest_common_prefix_up[] = analyzeSiblings( qnode_p, qnode_pp, separator, query, res ); final String greatest_common_prefix_up = analyzeSiblings( qnode_p, qnode_pp, separator, query ); - System.out.println( "greatest_common_prefix_up=" + greatest_common_prefix_up + " " + conf ); + //System.out.println( "greatest_common_prefix_up=" + greatest_common_prefix_up + " " + conf ); if ( !ForesterUtil.isEmpty( greatest_common_prefix_up ) ) { res.addGreatestCommonPrefixUp( greatest_common_prefix_up, conf ); } @@ -127,7 +127,7 @@ public final class AnalysisMulti { res.addGreatestCommonPrefixUp( UNKNOWN, conf ); } final String greatest_common_prefix_down = analyzeSiblings( qnode, qnode_p, separator, query ); - System.out.println( "greatest_common_prefix_down=" + greatest_common_prefix_down + " " + conf ); + // System.out.println( "greatest_common_prefix_down=" + greatest_common_prefix_down + " " + conf ); if ( !ForesterUtil.isEmpty( greatest_common_prefix_down ) ) { res.addGreatestCommonPrefixDown( greatest_common_prefix_down, conf ); } diff --git a/forester/java/src/org/forester/clade_analysis/Prefix.java b/forester/java/src/org/forester/clade_analysis/Prefix.java index 6362a3e..85fcbf7 100644 --- a/forester/java/src/org/forester/clade_analysis/Prefix.java +++ b/forester/java/src/org/forester/clade_analysis/Prefix.java @@ -2,51 +2,54 @@ package org.forester.clade_analysis; import java.math.BigDecimal; +import java.text.DecimalFormat; final class Prefix { - private final String _prefix; - private final BigDecimal _confidence; - private final String _separator; - private final String _first; + private final static DecimalFormat df = new DecimalFormat( "0.0#####" ); + private final String _prefix; + private final BigDecimal _confidence; + private final String _separator; + private final String _first; Prefix( final String prefix, final String confidence, final String separator ) { _prefix = prefix; - _confidence = new BigDecimal( confidence); - _separator = separator ; - if ( _prefix.indexOf( _separator ) < 0) { + _confidence = new BigDecimal( confidence ); + _separator = separator; + if ( _prefix.indexOf( _separator ) < 0 ) { _first = _prefix; } else { - _first = _prefix.substring( 0, _prefix.indexOf(_separator ) ); + _first = _prefix.substring( 0, _prefix.indexOf( _separator ) ); } } - - Prefix( final String prefix, final double confidence , final String separator) { + + Prefix( final String prefix, final double confidence, final String separator ) { _prefix = prefix; - _confidence = new BigDecimal( confidence); - _separator = separator ; - if ( _prefix.indexOf( _separator ) < 0) { + _confidence = new BigDecimal( confidence ); + _separator = separator; + if ( _prefix.indexOf( _separator ) < 0 ) { _first = _prefix; } else { - _first = _prefix.substring( 0, _prefix.indexOf(_separator ) ); - } + _first = _prefix.substring( 0, _prefix.indexOf( _separator ) ); + } } String getPrefix() { return _prefix; } - + String getPrefixFirstElement() { - return _first; + return _first; } + double getConfidence() { return _confidence.doubleValue(); } @Override public String toString() { - return getPrefix() + ": " + getConfidence(); + return getPrefix() + ": " + df.format( getConfidence() ); } } diff --git a/forester/java/src/org/forester/clade_analysis/ResultMulti.java b/forester/java/src/org/forester/clade_analysis/ResultMulti.java index d3bfba3..f9822ec 100644 --- a/forester/java/src/org/forester/clade_analysis/ResultMulti.java +++ b/forester/java/src/org/forester/clade_analysis/ResultMulti.java @@ -117,13 +117,13 @@ public final class ResultMulti { @Override public final String toString() { final StringBuilder sb = new StringBuilder(); - sb.append( "Cleaned:" ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - for( final Prefix prefix : _all ) { - sb.append( prefix ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - } - sb.append( ForesterUtil.LINE_SEPARATOR ); + // sb.append( "Cleaned:" ); + // sb.append( ForesterUtil.LINE_SEPARATOR ); + // for( final Prefix prefix : _all ) { + // sb.append( prefix ); + // sb.append( ForesterUtil.LINE_SEPARATOR ); + // } + // sb.append( ForesterUtil.LINE_SEPARATOR ); sb.append( "Collapsed:" ); sb.append( ForesterUtil.LINE_SEPARATOR ); for( final Prefix prefix : _collapsed ) { @@ -154,20 +154,20 @@ public final class ResultMulti { } if ( !ForesterUtil.isEmpty( _all_down ) ) { sb.append( ForesterUtil.LINE_SEPARATOR ); - sb.append( "Cleaned Down:" ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - for( final Prefix prefix : _all_down ) { - sb.append( prefix ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - } - sb.append( ForesterUtil.LINE_SEPARATOR ); + // sb.append( "Cleaned Down:" ); + // sb.append( ForesterUtil.LINE_SEPARATOR ); + // for( final Prefix prefix : _all_down ) { + // sb.append( prefix ); + // sb.append( ForesterUtil.LINE_SEPARATOR ); + // } + // sb.append( ForesterUtil.LINE_SEPARATOR ); sb.append( "Collapsed Down:" ); sb.append( ForesterUtil.LINE_SEPARATOR ); for( final Prefix prefix : _collapsed_down ) { sb.append( prefix ); sb.append( ForesterUtil.LINE_SEPARATOR ); } - if ( _has_specifics_down ) { + /* if ( _has_specifics_down ) { sb.append( ForesterUtil.LINE_SEPARATOR ); sb.append( "Specifics Down:" ); sb.append( ForesterUtil.LINE_SEPARATOR ); @@ -188,24 +188,24 @@ public final class ResultMulti { } } } - } + }*/ } if ( !ForesterUtil.isEmpty( _all_up ) ) { sb.append( ForesterUtil.LINE_SEPARATOR ); - sb.append( "Cleaned Up:" ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - for( final Prefix prefix : _all_up ) { - sb.append( prefix ); - sb.append( ForesterUtil.LINE_SEPARATOR ); - } - sb.append( ForesterUtil.LINE_SEPARATOR ); + // sb.append( "Cleaned Up:" ); + // sb.append( ForesterUtil.LINE_SEPARATOR ); + // for( final Prefix prefix : _all_up ) { + // sb.append( prefix ); + // sb.append( ForesterUtil.LINE_SEPARATOR ); + // } + // sb.append( ForesterUtil.LINE_SEPARATOR ); sb.append( "Collapsed Up:" ); sb.append( ForesterUtil.LINE_SEPARATOR ); for( final Prefix prefix : _collapsed_up ) { sb.append( prefix ); sb.append( ForesterUtil.LINE_SEPARATOR ); } - if ( _has_specifics ) { + /* if ( _has_specifics ) { sb.append( ForesterUtil.LINE_SEPARATOR ); sb.append( "Specifics Up:" ); sb.append( ForesterUtil.LINE_SEPARATOR ); @@ -226,7 +226,7 @@ public final class ResultMulti { } } } - } + }*/ } return sb.toString(); } -- 1.7.10.2