in progress...
authorcmzmasek <chris.zma@outlook.com>
Wed, 23 Aug 2017 01:33:26 +0000 (18:33 -0700)
committercmzmasek <chris.zma@outlook.com>
Wed, 23 Aug 2017 01:33:26 +0000 (18:33 -0700)
forester/java/src/org/forester/application/cladinator.java
forester/java/src/org/forester/clade_analysis/AnalysisMulti.java [moved from forester/java/src/org/forester/clade_analysis/Analysis2.java with 51% similarity]
forester/java/src/org/forester/clade_analysis/AnalysisSingle.java [moved from forester/java/src/org/forester/clade_analysis/Analysis.java with 97% similarity]
forester/java/src/org/forester/clade_analysis/CladeAnalysisTest.java
forester/java/src/org/forester/clade_analysis/ResultMulti.java [moved from forester/java/src/org/forester/clade_analysis/Result2.java with 69% similarity]
forester/java/src/org/forester/clade_analysis/ResultSingle.java [moved from forester/java/src/org/forester/clade_analysis/Result.java with 85% similarity]

index ddc1aef..daf0224 100644 (file)
@@ -31,8 +31,8 @@ import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.forester.clade_analysis.Analysis;
-import org.forester.clade_analysis.Result;
+import org.forester.clade_analysis.AnalysisSingle;
+import org.forester.clade_analysis.ResultSingle;
 import org.forester.io.parsers.PhylogenyParser;
 import org.forester.io.parsers.util.ParserUtils;
 import org.forester.phylogeny.Phylogeny;
@@ -115,7 +115,7 @@ public final class cladinator {
                 System.out.println( "\nCould not read \"" + intreefile + "\" [" + e.getMessage() + "]\n" );
                 System.exit( -1 );
             }
-            final Result res = Analysis.execute( p, query, separator );
+            final ResultSingle res = AnalysisSingle.execute( p, query, separator );
             System.out.println();
             System.out.println( "Result:" );
             System.out.println( "Query                        : " + query );
@@ -41,11 +41,36 @@ import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Confidence;
 import org.forester.util.ForesterUtil;
 
-public final class Analysis2 {
+public final class AnalysisMulti {
 
-    public static Result2 execute( final Phylogeny p, final Pattern query, final String separator ) {
+    private final static String UNKNOWN = "?";
+    public final static double DEFAULT_CUTOFF_FOR_SPECIFICS = 0.5;
+    public final static String DEFAULT_SEPARATOR = ".";
+    public final static Pattern DEFAULT_QUERY_PATTERN_FOR_PPLACER_TYPE = Pattern.compile( ".+#\\d+_M=(.+)" );
+    
+
+    public static ResultMulti execute( final Phylogeny p ) {
+        return execute( p, DEFAULT_QUERY_PATTERN_FOR_PPLACER_TYPE, DEFAULT_SEPARATOR, DEFAULT_CUTOFF_FOR_SPECIFICS );
+    }
+    
+    public static ResultMulti execute( final Phylogeny p, final String separator ) {
+        return execute( p, DEFAULT_QUERY_PATTERN_FOR_PPLACER_TYPE, separator , DEFAULT_CUTOFF_FOR_SPECIFICS );
+    }
+    
+    public static ResultMulti execute( final Phylogeny p, final String separator,  final double cutoff_for_specifics ) {
+        return execute( p, DEFAULT_QUERY_PATTERN_FOR_PPLACER_TYPE, separator , cutoff_for_specifics );
+    }
+    
+    public static ResultMulti execute( final Phylogeny p, final double cutoff_for_specifics ) {
+        return execute( p, DEFAULT_QUERY_PATTERN_FOR_PPLACER_TYPE, DEFAULT_SEPARATOR , cutoff_for_specifics );
+    }
+
+    public static ResultMulti execute( final Phylogeny p,
+                                   final Pattern query,
+                                   final String separator,
+                                   final double cutoff_for_specifics ) {
         final List<PhylogenyNode> qnodes = p.getNodes( query );
-        final Result2 res = new Result2();
+        final ResultMulti res = new ResultMulti();
         for( int i = 0; i < qnodes.size(); ++i ) {
             final PhylogenyNode qnode = qnodes.get( i );
             System.out.println( ">>" + qnode.getName() );
@@ -64,7 +89,6 @@ public final class Analysis2 {
             while ( qnode_pp.getNumberOfDescendants() == 1 ) {
                 qnode_pp = qnode_pp.getParent();
             }
-            // final List<PhylogenyNode> qnode_ext_nodes = new ArrayList<PhylogenyNode>();
             final List<String> qnode_ext_nodes_names = new ArrayList<>();
             for( final PhylogenyNode qnode_ext_node : qnode_pp.getAllExternalDescendants() ) {
                 final String name = qnode_ext_node.getName();
@@ -76,8 +100,6 @@ public final class Analysis2 {
                     qnode_ext_nodes_names.add( name );
                 }
             }
-            //final int lec_ext_nodes = qnode_ext_nodes_names.size();
-            //final int p_ext_nodes = p.getNumberOfExternalNodes() - 1;
             final String greatest_common_prefix = ForesterUtil.greatestCommonPrefix( qnode_ext_nodes_names, separator );
             //  System.out.println( greatest_common_prefix );
             Matcher matcher = query.matcher( qnode.getName() );
@@ -93,125 +115,34 @@ public final class Analysis2 {
                 res.addGreatestCommonPrefix( greatest_common_prefix, conf );
             }
             else {
-                res.addGreatestCommonPrefix( "?", conf );
+                res.addGreatestCommonPrefix( UNKNOWN, conf );
             }
             //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);
-            if ( !ForesterUtil.isEmpty( greatest_common_prefix_up) ) {
+            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 );
             }
             else {
-                res.addGreatestCommonPrefixUp( "?", conf );
+                res.addGreatestCommonPrefixUp( UNKNOWN, conf );
             }
-           // res.addGreatestCommonPrefixUp( greatest_common_prefix_up, conf );
-            //res.addGreatestCommonPrefixUp( greatest_common_prefix_up[ 0 ], 0.1 );
-            // res.setGreatestCommonPrefixUp( greatest_common_prefix_up[ 0 ] );
-            //if ( greatest_common_prefix_up[ 1 ] != null ) {
-            //     res.setGreatestCommonCladeUpSubtreeConfidence( greatest_common_prefix_up[ 1 ] );
-            // }
-            // final String greatest_common_prefix_down[] = analyzeSiblings( qnode, qnode_p, separator,query, res );
-            final String greatest_common_prefix_down =  analyzeSiblings( qnode, qnode_p, separator, query );
-            System.out.println( "greatest_common_prefix_down=" + greatest_common_prefix_down+ " " + conf);
-            if ( !ForesterUtil.isEmpty( greatest_common_prefix_down) ) {
+            final String greatest_common_prefix_down = analyzeSiblings( qnode, qnode_p, separator, query );
+            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 );
             }
             else {
-                res.addGreatestCommonPrefixDown( "?", conf );
-            }
-            //res.addGreatestCommonPrefixDown( greatest_common_prefix_down, conf );
-            // res.setGreatestCommonPrefixDown( greatest_common_prefix_down[ 0 ] );
-            // if ( greatest_common_prefix_down[ 1 ] != null ) {
-            //     res.setGreatestCommonCladeDownSubtreeConfidence( greatest_common_prefix_down[ 1 ] );
-            // }
-        }
-        /* for( final PhylogenyNode qnode_ext_node : qnode_ext_nodes ) {
-            String name = qnode_ext_node.getName();
-            if ( ForesterUtil.isEmptyTrimmed( name ) ) {
-                throw new IllegalArgumentException( "external node(s) with empty names found" );
-            }
-            name = name.trim();
-            if ( !name.equals( query ) ) {
-                qnode_ext_nodes_names.add( name );
+                res.addGreatestCommonPrefixDown( UNKNOWN, conf );
             }
-        }*/
-        //   if ( greatest_common_prefix.length() < 1 ) {
-        //       res.addWarning( "No greatest common prefix" );
-        //res.setGreatestCommonPrefix( "" );
-        //  }
-        // else {
-        //    //  res.setGreatestCommonPrefix( greatest_common_prefix );
-        // res.addGreatestCommonPrefix( prefix, confidence, separator ); //TODO
-        //   }
-        // if ( qnode_pp.isRoot() ) {
-        //     res.addWarning( "Least Encompassing Clade is entire tree" );
-        // }
-        /*    final String conf = obtainConfidence( qnode_pp );
-        if ( conf != null ) {
-            res.setGreatestCommonCladeSubtreeConfidence(conf);
-        }*/
-        /*  final String greatest_common_prefix_up[] = analyzeSiblings( qnode_p, qnode_pp, separator );
-        res.setGreatestCommonPrefixUp( greatest_common_prefix_up[ 0 ] );
-        if ( greatest_common_prefix_up[ 1 ] != null ) {
-            res.setGreatestCommonCladeUpSubtreeConfidence( greatest_common_prefix_up[ 1 ] );
         }
-        final String greatest_common_prefix_down[] = analyzeSiblings( qnode, qnode_p, separator );
-        res.setGreatestCommonPrefixDown( greatest_common_prefix_down[ 0 ] );
-        if ( greatest_common_prefix_down[ 1 ] != null ) {
-            res.setGreatestCommonCladeDownSubtreeConfidence( greatest_common_prefix_down[ 1 ] );
-        }*/
+        res.analyze( cutoff_for_specifics );
         return res;
     }
 
-    private final static void analyzeSiblingsOLD( final PhylogenyNode child,
-                                                  final PhylogenyNode parent,
-                                                  final String separator,
-                                                  final Pattern query,
-                                                  Result2 res,
-                                                  double conf2 ) {
-        final int child_index = child.getChildNodeIndex();
-        final List<String> ext_nodes_names = new ArrayList<>();
-        final List<PhylogenyNode> descs = parent.getDescendants();
-        // String conf = null;
-        for( int i = 0; i < descs.size(); ++i ) {
-            if ( i != child_index ) {
-                final PhylogenyNode d = descs.get( i );
-                for( final PhylogenyNode n : d.getAllExternalDescendants() ) {
-                    final String name = n.getName();
-                    if ( ForesterUtil.isEmptyTrimmed( name ) ) {
-                        throw new IllegalArgumentException( "external node(s) with empty names found" );
-                    }
-                    ext_nodes_names.add( name.trim() );
-                }
-                // if ( descs.size() == 2 ) {
-                //     conf = obtainConfidence( d );
-                // }
-            }
-        }
-        ////////////////////////////////////////////////////////////
-        /*  Matcher matcher = query.matcher( child.getName() );
-          String conf_str = null;
-          if ( matcher.find() ) {
-        conf_str = matcher.group( 1 );
-          }
-          else {
-        throw new IllegalStateException(  "pattern did not match for \"" + child.getName()  + "\" -- this should have never happened!" );
-          }*/
-        ////////////////////////////////////////////////////////////
-        final String greatest_common_prefix = ForesterUtil.greatestCommonPrefix( ext_nodes_names, separator );
-        //final double conf = Double.parseDouble( conf_str );
-        if ( !ForesterUtil.isEmpty( greatest_common_prefix ) ) {
-            res.addGreatestCommonPrefix( greatest_common_prefix, conf2 );
-        }
-        else {
-            res.addGreatestCommonPrefix( "?", conf2 );
-        }
-    }
-
     private final static String analyzeSiblings( final PhylogenyNode child,
-                                               final PhylogenyNode parent,
-                                               final String separator,
-                                               final Pattern query) {
+                                                 final PhylogenyNode parent,
+                                                 final String separator,
+                                                 final Pattern query ) {
         final int child_index = child.getChildNodeIndex();
         final List<String> ext_nodes_names = new ArrayList<>();
         final List<PhylogenyNode> descs = parent.getDescendants();
@@ -224,34 +155,17 @@ public final class Analysis2 {
                     if ( ForesterUtil.isEmptyTrimmed( name ) ) {
                         throw new IllegalArgumentException( "external node(s) with empty names found" );
                     }
-                    
-                    ////
-                   
                     final Matcher m = query.matcher( name );
                     if ( !m.find() ) {
                         ext_nodes_names.add( name );
                     }
-                    
-                    ////
-                    
                 }
                 // if ( descs.size() == 2 ) {
                 //     conf = obtainConfidence( d );
                 // }
             }
         }
-        ////////////////////////////////////////////////////////////
-        /*  Matcher matcher = query.matcher( child.getName() );
-        String conf_str = null;
-        if ( matcher.find() ) {
-            conf_str = matcher.group( 1 );
-        }
-        else {
-            throw new IllegalStateException(  "pattern did not match for \"" + child.getName()  + "\" -- this should have never happened!" );
-        }*/
-        ////////////////////////////////////////////////////////////
         final String greatest_common_prefix = ForesterUtil.greatestCommonPrefix( ext_nodes_names, separator );
-        //final double conf = Double.parseDouble( conf_str );
         return greatest_common_prefix;
     }
 
@@ -39,9 +39,9 @@ import org.forester.phylogeny.PhylogenyNode;
 import org.forester.phylogeny.data.Confidence;
 import org.forester.util.ForesterUtil;
 
-public final class Analysis {
+public final class AnalysisSingle {
 
-    public static Result execute( final Phylogeny p, final String query, final String separator ) {
+    public static ResultSingle execute( final Phylogeny p, final String query, final String separator ) {
         final PhylogenyNode qnode = p.getNode( query );
         if ( qnode.isRoot() ) {
             throw new IllegalStateException( "Unexpected error: Query " + query
@@ -74,7 +74,7 @@ public final class Analysis {
             }
         }
         final String greatest_common_prefix = ForesterUtil.greatestCommonPrefix( qnode_ext_nodes_names, separator );
-        final Result res = new Result();
+        final ResultSingle res = new ResultSingle();
         if ( greatest_common_prefix.length() < 1 ) {
             res.addWarning( "No greatest common prefix" );
             res.setGreatestCommonPrefix( "" );
index f5a9d92..35c08b5 100644 (file)
@@ -2,8 +2,6 @@
 package org.forester.clade_analysis;
 
 import java.io.File;
-import java.util.List;
-import java.util.regex.Pattern;
 
 import org.forester.io.parsers.PhylogenyParser;
 import org.forester.io.parsers.util.ParserUtils;
@@ -19,7 +17,7 @@ public class CladeAnalysisTest {
 
     public static void main( final String[] args ) {
         boolean failed = false;
-       /* if ( !testCladeAnalysis1() ) {
+        if ( !testCladeAnalysis1() ) {
             System.out.println( "Clade analysis 1 failed" );
             failed = true;
         }
@@ -34,18 +32,21 @@ public class CladeAnalysisTest {
         if ( !testCladeAnalysis4() ) {
             System.out.println( "Clade analysis 4 failed" );
             failed = true;
-        */
+        }
         if ( !testCladeAnalysis5() ) {
             System.out.println( "Clade analysis 5 failed" );
             failed = true;
         }
-       /* if ( !testCladeAnalysis6() ) {
+        if ( !testCladeAnalysis6() ) {
             System.out.println( "Clade analysis 6 failed" );
             failed = true;
-        }*/
+        }
         if ( !failed ) {
             System.out.println( "OK" );
         }
+        else {
+            System.out.println( "NOT OK" );
+        }
     }
 
     public static boolean test() {
@@ -76,7 +77,7 @@ public class CladeAnalysisTest {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( intreefile1, true );
             final Phylogeny p1 = factory.create( intreefile1, pp )[ 0 ];
-            Result res = Analysis.execute( p1, "A.1.1.1", "." );
+            ResultSingle res = AnalysisSingle.execute( p1, "A.1.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.1" ) ) {
                 return false;
             }
@@ -95,7 +96,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.1.1.2", "." );
+            res = AnalysisSingle.execute( p1, "A.1.1.2", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.1" ) ) {
                 return false;
             }
@@ -114,7 +115,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.1.1.3", "." );
+            res = AnalysisSingle.execute( p1, "A.1.1.3", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.1" ) ) {
                 return false;
             }
@@ -133,7 +134,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.1.1.4", "." );
+            res = AnalysisSingle.execute( p1, "A.1.1.4", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.1.1" ) ) {
                 return false;
             }
@@ -152,7 +153,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.1.2.1", "." );
+            res = AnalysisSingle.execute( p1, "A.1.2.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -171,7 +172,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.2.1.1", "." );
+            res = AnalysisSingle.execute( p1, "A.2.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -190,7 +191,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.2.1.2", "." );
+            res = AnalysisSingle.execute( p1, "A.2.1.2", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -209,7 +210,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.3.1.1", "." );
+            res = AnalysisSingle.execute( p1, "A.3.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.3" ) ) {
                 return false;
             }
@@ -228,7 +229,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.3.1.2", "." );
+            res = AnalysisSingle.execute( p1, "A.3.1.2", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.3" ) ) {
                 return false;
             }
@@ -247,7 +248,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.3.2.1", "." );
+            res = AnalysisSingle.execute( p1, "A.3.2.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.3" ) ) {
                 return false;
             }
@@ -266,7 +267,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.3.3.1", "." );
+            res = AnalysisSingle.execute( p1, "A.3.3.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -285,7 +286,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.4.1.1", "." );
+            res = AnalysisSingle.execute( p1, "A.4.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.4.1" ) ) {
                 return false;
             }
@@ -304,7 +305,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.4.1.1.a", "." );
+            res = AnalysisSingle.execute( p1, "A.4.1.1.a", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A.4.1" ) ) {
                 return false;
             }
@@ -323,9 +324,9 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.4.1.2", "." );
-            res = Analysis.execute( p1, "A.4.1.2.a", "." );
-            res = Analysis.execute( p1, "A.5.1.1", "." );
+            res = AnalysisSingle.execute( p1, "A.4.1.2", "." );
+            res = AnalysisSingle.execute( p1, "A.4.1.2.a", "." );
+            res = AnalysisSingle.execute( p1, "A.5.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -344,7 +345,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.5.1.2", "." );
+            res = AnalysisSingle.execute( p1, "A.5.1.2", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -363,7 +364,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "A.6.3.12", "." );
+            res = AnalysisSingle.execute( p1, "A.6.3.12", "." );
             if ( !res.getGreatestCommonPrefix().equals( "A" ) ) {
                 return false;
             }
@@ -382,7 +383,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "B.1.1.1", "." );
+            res = AnalysisSingle.execute( p1, "B.1.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "" ) ) {
                 return false;
             }
@@ -401,7 +402,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 2 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "B.1.234.3", "." );
+            res = AnalysisSingle.execute( p1, "B.1.234.3", "." );
             if ( !res.getGreatestCommonPrefix().equals( "" ) ) {
                 return false;
             }
@@ -420,7 +421,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 2 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "C.1.1.1", "." );
+            res = AnalysisSingle.execute( p1, "C.1.1.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "C.1" ) ) {
                 return false;
             }
@@ -439,7 +440,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "C.1.1.2", "." );
+            res = AnalysisSingle.execute( p1, "C.1.1.2", "." );
             if ( !res.getGreatestCommonPrefix().equals( "C.1" ) ) {
                 return false;
             }
@@ -458,7 +459,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "C.1.2.1", "." );
+            res = AnalysisSingle.execute( p1, "C.1.2.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "C" ) ) {
                 return false;
             }
@@ -477,7 +478,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "C.2.1", "." );
+            res = AnalysisSingle.execute( p1, "C.2.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "C" ) ) {
                 return false;
             }
@@ -496,7 +497,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "C.3", "." );
+            res = AnalysisSingle.execute( p1, "C.3", "." );
             if ( !res.getGreatestCommonPrefix().equals( "" ) ) {
                 return false;
             }
@@ -515,7 +516,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 1 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "QE.1.1.1.2.1", "." );
+            res = AnalysisSingle.execute( p1, "QE.1.1.1.2.1", "." );
             if ( !res.getGreatestCommonPrefix().equals( "" ) ) {
                 return false;
             }
@@ -548,7 +549,7 @@ public class CladeAnalysisTest {
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( intreefile1, true );
             final Phylogeny p1 = factory.create( intreefile1, pp )[ 0 ];
-            Result res = Analysis.execute( p1, "6_DQ278891", null );
+            ResultSingle res = AnalysisSingle.execute( p1, "6_DQ278891", null );
             if ( !res.getGreatestCommonPrefix().equals( "6_" ) ) {
                 return false;
             }
@@ -567,7 +568,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "6xa_EU408330", null );
+            res = AnalysisSingle.execute( p1, "6xa_EU408330", null );
             if ( !res.getGreatestCommonPrefix().equals( "6xa_EU40833" ) ) {
                 return false;
             }
@@ -586,7 +587,7 @@ public class CladeAnalysisTest {
             if ( res.getWarnings().size() != 0 ) {
                 return false;
             }
-            res = Analysis.execute( p1, "7a_EF108306", null );
+            res = AnalysisSingle.execute( p1, "7a_EF108306", null );
             if ( !res.getGreatestCommonPrefix().equals( "" ) ) {
                 return false;
             }
@@ -615,63 +616,56 @@ public class CladeAnalysisTest {
 
     private static boolean testCladeAnalysis3() {
         try {
-            final Result2 res1 = new Result2();
+            final ResultMulti res1 = new ResultMulti();
             res1.addGreatestCommonPrefix( "A.1.1", 0.3 );
             res1.addGreatestCommonPrefix( "A.1.2", 0.3 );
             res1.addGreatestCommonPrefix( "A.1.3", 0.3 );
             res1.addGreatestCommonPrefix( "B.1", 0.1 );
-            res1.analyzeGreatestCommonPrefixes( 0.5 );
-            //res1.analyzeGreatestCommonPrefixesDown(0.5);
-            //res1.analyzeGreatestCommonPrefixesUp(0.5);
-            System.out.print( res1.toString());
-            System.out.println( "------------------------- ");
+            res1.analyze( 0.5 );
+            System.out.print( res1.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-            final Result2 res2 = new Result2( "." );
+            final ResultMulti res2 = new ResultMulti( "." );
             res2.addGreatestCommonPrefix( "A.1.1.1", 0.1 );
             res2.addGreatestCommonPrefix( "A.1", 0.7 );
             res2.addGreatestCommonPrefix( "A.1.2", 0.1 );
             res2.addGreatestCommonPrefix( "B.1", 0.1 );
-            res2.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res2.toString());
-            System.out.println( "------------------------- ");
+            res2.analyze( 0.3 );
+            System.out.print( res2.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-           
-            final Result2 res3 = new Result2( "." );
+            final ResultMulti res3 = new ResultMulti( "." );
             res3.addGreatestCommonPrefix( "A.1.1.1", 0.1 );
             res3.addGreatestCommonPrefix( "A.1.1.1.1", 0.6 );
             res3.addGreatestCommonPrefix( "A.1", 0.1 );
             res3.addGreatestCommonPrefix( "A.1.2", 0.1 );
             res3.addGreatestCommonPrefix( "B.1", 0.1 );
-            res3.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res3.toString());
-            System.out.println( "------------------------- ");
+            res3.analyze( 0.3 );
+            System.out.print( res3.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-            final Result2 res33 = new Result2( "." );
+            final ResultMulti res33 = new ResultMulti( "." );
             res33.addGreatestCommonPrefix( "A.1.1.1", 0.1 );
             res33.addGreatestCommonPrefix( "A.1.1.1.1", 0.3 );
             res33.addGreatestCommonPrefix( "A.1", 0.1 );
             res33.addGreatestCommonPrefix( "A.1.2", 0.1 );
             res33.addGreatestCommonPrefix( "B.1", 0.1 );
             res33.addGreatestCommonPrefix( "B.1.1.1", 0.3 );
-            res33.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res33.toString());
-            System.out.println( "------------------------- ");
+            res33.analyze( 0.3 );
+            System.out.print( res33.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-            final Result2 res4 = new Result2();
+            final ResultMulti res4 = new ResultMulti();
             res4.addGreatestCommonPrefix( "A.1.1.1.1", 0.35 );
             res4.addGreatestCommonPrefix( "A.1.1.1.2", 0.35 );
             res4.addGreatestCommonPrefix( "A.1", 0.1 );
             res4.addGreatestCommonPrefix( "A.1.2", 0.1 );
             res4.addGreatestCommonPrefix( "B.1", 0.1 );
-            res4.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res4.toString());
-            System.out.println( "------------------------- ");
+            res4.analyze( 0.3 );
+            System.out.print( res4.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-            final Result2 res5 = new Result2();
+            final ResultMulti res5 = new ResultMulti();
             res5.addGreatestCommonPrefix( "A.1.1.1.1", 0.2 );
             res5.addGreatestCommonPrefix( "C.2.3", 0.2 );
             res5.addGreatestCommonPrefix( "A.1.5", 0.1 );
@@ -679,54 +673,50 @@ public class CladeAnalysisTest {
             res5.addGreatestCommonPrefix( "B.1.1", 0.2 );
             res5.addGreatestCommonPrefix( "B.1.2", 0.09 );
             res5.addGreatestCommonPrefix( "D.1.1.1.1", 0.01 );
-            res5.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res5.toString());
-            System.out.println( "------------------------- ");
+            res5.analyze( 0.3 );
+            System.out.print( res5.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-           
-            final Result2 res6 = new Result2();
+            final ResultMulti res6 = new ResultMulti();
             res6.addGreatestCommonPrefix( "A.1.1.1", 0.05 );
             res6.addGreatestCommonPrefix( "A.1.1.1.1", 0.65 );
             res6.addGreatestCommonPrefix( "A.1", 0.1 );
             res6.addGreatestCommonPrefix( "A.1.2", 0.1 );
             res6.addGreatestCommonPrefix( "B.1", 0.1 );
-            res6.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res6.toString());
-            System.out.println( "------------------------- ");
+            res6.analyze( 0.3 );
+            System.out.print( res6.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-           
-            final Result2 res7 = new Result2();
+            final ResultMulti res7 = new ResultMulti();
             res7.addGreatestCommonPrefix( "A.1.1.1", 0.07 );
             res7.addGreatestCommonPrefix( "A.1.1.1.1", 0.9 );
             res7.addGreatestCommonPrefix( "A.1", 0.01 );
             res7.addGreatestCommonPrefix( "A.1.2", 0.01 );
             res7.addGreatestCommonPrefix( "B.1", 0.01 );
-            res7.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res7.toString());
-            System.out.println( "------------------------- ");
+            res7.analyze( 0.3 );
+            System.out.print( res7.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-            final Result2 res8 = new Result2( "_/_" );
+            final ResultMulti res8 = new ResultMulti( "_/_" );
             res8.addGreatestCommonPrefix( "AA_/_abc_/_def", 0.07 );
             res8.addGreatestCommonPrefix( "AA_/_abc_/_sfc", 0.9 );
             res8.addGreatestCommonPrefix( "AA_/_abc_/_xcd", 0.01 );
             res8.addGreatestCommonPrefix( "AA_/_abc_/_memr", 0.01 );
             res8.addGreatestCommonPrefix( "AA_/_abc_/_fkem_/_odem", 0.01 );
-            res8.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res8.toString());
-            System.out.println( "------------------------- ");
+            res8.analyze( 0.3 );
+            System.out.print( res8.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-           
-            final Result2 res9 = new Result2( "_/_" );
+            final ResultMulti res9 = new ResultMulti( "_/_" );
             res9.addGreatestCommonPrefix( "AA_/_abc_/_def", 0.07 );
             res9.addGreatestCommonPrefix( "AA_/_abc_/_sfc", 0.6 );
             res9.addGreatestCommonPrefix( "AA_/_abc_/_xcd", 0.01 );
             res9.addGreatestCommonPrefix( "AA_/_abc_/_memr", 0.01 );
             res9.addGreatestCommonPrefix( "AA_/_abc_/_fkem_/_odem", 0.01 );
             res9.addGreatestCommonPrefix( "BB_/_fke_/_dme_/_nx2", 0.3 );
-            res9.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res9.toString());
-            System.out.println( "------------------------- ");
+            res9.analyze( 0.3 );
+            System.out.print( res9.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
         }
         catch ( final Exception e ) {
@@ -735,41 +725,18 @@ public class CladeAnalysisTest {
         }
         return true;
     }
-    
+
     private static boolean testCladeAnalysis4() {
         try {
             final File intreefile1 = new File( PATH_TO_TEST_DATA + "pplacer_2.tre" );
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( intreefile1, true );
             final Phylogeny p1 = factory.create( intreefile1, pp )[ 0 ];
-            Pattern query = Pattern.compile(".+#\\d+_M=(.+)");
-            Result2 res = Analysis2.execute( p1, query, "." );
-            
-            res.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res.toString());
-            System.out.println( "------------------------- ");
+            ResultMulti res2 = AnalysisMulti.execute( p1 );
+            res2.analyze( 0.3 );
+            System.out.print( res2.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-           // Result res = Analysis.execute( p1, "A.1.1.1", "." );
-           /* if ( !res.getGreatestCommonPrefix().equals( "A.1" ) ) {
-                return false;
-            }
-            if ( !res.getGreatestCommonPrefixDown().equals( "A.1.1" ) ) {
-                return false;
-            }
-            if ( !res.getGreatestCommonPrefixUp().equals( "A.1.2.1" ) ) {
-                return false;
-            }
-            if ( res.getLeastEncompassingCladeSize() != 4 ) {
-                return false;
-            }
-            if ( res.getTreeSize() != 25 ) {
-                return false;
-            }
-            if ( res.getWarnings().size() != 0 ) {
-                return false;
-            }*/
-          
         }
         catch ( final Exception e ) {
             e.printStackTrace( System.out );
@@ -777,41 +744,18 @@ public class CladeAnalysisTest {
         }
         return true;
     }
-    
+
     private static boolean testCladeAnalysis5() {
         try {
             final File intreefile1 = new File( PATH_TO_TEST_DATA + "clade_analysis_test_3.xml" );
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( intreefile1, true );
             final Phylogeny p1 = factory.create( intreefile1, pp )[ 0 ];
-            Pattern query = Pattern.compile(".+#\\d+_M=(.+)");
-            Result2 res = Analysis2.execute( p1, query, "." );
-            
-            res.analyzeGreatestCommonPrefixes( 0.3 );
-            System.out.print( res.toString());
-            System.out.println( "------------------------- ");
+            ResultMulti res = AnalysisMulti.execute( p1 );
+            res.analyze( 0.3 );
+            System.out.print( res.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-           // Result res = Analysis.execute( p1, "A.1.1.1", "." );
-           /* if ( !res.getGreatestCommonPrefix().equals( "A.1" ) ) {
-                return false;
-            }
-            if ( !res.getGreatestCommonPrefixDown().equals( "A.1.1" ) ) {
-                return false;
-            }
-            if ( !res.getGreatestCommonPrefixUp().equals( "A.1.2.1" ) ) {
-                return false;
-            }
-            if ( res.getLeastEncompassingCladeSize() != 4 ) {
-                return false;
-            }
-            if ( res.getTreeSize() != 25 ) {
-                return false;
-            }
-            if ( res.getWarnings().size() != 0 ) {
-                return false;
-            }*/
-          
         }
         catch ( final Exception e ) {
             e.printStackTrace( System.out );
@@ -819,41 +763,17 @@ public class CladeAnalysisTest {
         }
         return true;
     }
-    
+
     private static boolean testCladeAnalysis6() {
         try {
             final File intreefile1 = new File( PATH_TO_TEST_DATA + "clade_analysis_test_4.xml" );
             final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
             final PhylogenyParser pp = ParserUtils.createParserDependingOnFileType( intreefile1, true );
             final Phylogeny p1 = factory.create( intreefile1, pp )[ 0 ];
-            Pattern query = Pattern.compile(".+#\\d+_M=(.+)");
-            Result2 res = Analysis2.execute( p1, query, "." );
-            
-            res.analyzeGreatestCommonPrefixes( 0.45 );
-            System.out.print( res.toString());
-            System.out.println( "------------------------- ");
+            ResultMulti res = AnalysisMulti.execute( p1, 0.45 );
+            System.out.print( res.toString() );
+            System.out.println( "------------------------- " );
             System.out.println();
-            
-           // Result res = Analysis.execute( p1, "A.1.1.1", "." );
-           /* if ( !res.getGreatestCommonPrefix().equals( "A.1" ) ) {
-                return false;
-            }
-            if ( !res.getGreatestCommonPrefixDown().equals( "A.1.1" ) ) {
-                return false;
-            }
-            if ( !res.getGreatestCommonPrefixUp().equals( "A.1.2.1" ) ) {
-                return false;
-            }
-            if ( res.getLeastEncompassingCladeSize() != 4 ) {
-                return false;
-            }
-            if ( res.getTreeSize() != 25 ) {
-                return false;
-            }
-            if ( res.getWarnings().size() != 0 ) {
-                return false;
-            }*/
-          
         }
         catch ( final Exception e ) {
             e.printStackTrace( System.out );
@@ -37,35 +37,33 @@ import java.util.TreeMap;
 
 import org.forester.util.ForesterUtil;
 
-public final class Result2 {
+public final class ResultMulti {
 
     private final String       _separator;
-    private final List<Prefix> _greatest_common_prefixes                      = new ArrayList<Prefix>();
-    private List<Prefix>       _greatest_common_prefixes_up                   = new ArrayList<Prefix>();
-    private List<Prefix>       _greatest_common_prefixes_down                 = new ArrayList<Prefix>();
-    private final List<String> _warnings                                      = new ArrayList<>();
-    private String             _greatest_common_clade_subtree_confidence      = "";
-    private String             _greatest_common_clade_subtree_confidence_up   = "";
-    private String             _greatest_common_clade_subtree_confidence_down = "";
-    private List<Prefix>       _all                                           = null;
-    private List<Prefix>       _collapsed                                     = null;
-    private List<Prefix>       _cleaned_spec                                  = null;
-    private boolean            _has_specifics                                 = false;
-    private List<Prefix>       _all_up                                        = null;
-    private List<Prefix>       _collapsed_up                                  = null;
-    private List<Prefix>       _cleaned_spec_up                               = null;
-    private boolean            _has_specifics_up                              = false;
-    private List<Prefix>       _all_down                                      = null;
-    private List<Prefix>       _collapsed_down                                = null;
-    private List<Prefix>       _cleaned_spec_down                             = null;
-    private boolean            _has_specifics_down                            = false;
-
-    public Result2( final String separator ) {
+    private final List<Prefix> _greatest_common_prefixes      = new ArrayList<Prefix>();
+    private final List<Prefix> _greatest_common_prefixes_up   = new ArrayList<Prefix>();
+    private final List<Prefix> _greatest_common_prefixes_down = new ArrayList<Prefix>();
+    private List<Prefix>       _all                           = null;
+    private List<Prefix>       _collapsed                     = null;
+    private List<Prefix>       _cleaned_spec                  = null;
+    private boolean            _has_specifics                 = false;
+    private List<Prefix>       _all_up                        = null;
+    private List<Prefix>       _collapsed_up                  = null;
+    private List<Prefix>       _cleaned_spec_up               = null;
+    private boolean            _has_specifics_up              = false;
+    private List<Prefix>       _all_down                      = null;
+    private List<Prefix>       _collapsed_down                = null;
+    private List<Prefix>       _cleaned_spec_down             = null;
+    private boolean            _has_specifics_down            = false;
+
+    ResultMulti( final String separator ) {
         _separator = separator;
+        reset();
     }
 
-    public Result2() {
-        _separator = ".";//TODO make const somewhere
+    ResultMulti() {
+        _separator = AnalysisMulti.DEFAULT_SEPARATOR;
+        reset();
     }
 
     public List<Prefix> getAllMultiHitPrefixesUp() {
@@ -116,8 +114,121 @@ public final class Result2 {
         return _has_specifics;
     }
 
-    void addWarning( final String warning ) {
-        _warnings.add( warning );
+    @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( "Collapsed:" );
+        sb.append( ForesterUtil.LINE_SEPARATOR );
+        for( final Prefix prefix : _collapsed ) {
+            sb.append( prefix );
+            sb.append( ForesterUtil.LINE_SEPARATOR );
+        }
+        if ( _has_specifics ) {
+            sb.append( ForesterUtil.LINE_SEPARATOR );
+            sb.append( "Specifics:" );
+            sb.append( ForesterUtil.LINE_SEPARATOR );
+            for( final Prefix prefix : _cleaned_spec ) {
+                sb.append( prefix );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+            }
+            sb.append( ForesterUtil.LINE_SEPARATOR );
+            sb.append( "Collapsed With Specifics:" );
+            sb.append( ForesterUtil.LINE_SEPARATOR );
+            for( final Prefix prefix : _collapsed ) {
+                sb.append( prefix );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                for( final Prefix spec : _cleaned_spec ) {
+                    if ( spec.getPrefix().startsWith( prefix.getPrefix() ) ) {
+                        sb.append( "    " + spec );
+                        sb.append( ForesterUtil.LINE_SEPARATOR );
+                    }
+                }
+            }
+        }
+        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( "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 ) {
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                sb.append( "Specifics Down:" );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                for( final Prefix prefix : _cleaned_spec_down ) {
+                    sb.append( prefix );
+                    sb.append( ForesterUtil.LINE_SEPARATOR );
+                }
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                sb.append( "Collapsed With Specifics Down:" );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                for( final Prefix prefix : _collapsed_down ) {
+                    sb.append( prefix );
+                    sb.append( ForesterUtil.LINE_SEPARATOR );
+                    for( final Prefix spec : _cleaned_spec_down ) {
+                        if ( spec.getPrefix().startsWith( prefix.getPrefix() ) ) {
+                            sb.append( "    " + spec );
+                            sb.append( ForesterUtil.LINE_SEPARATOR );
+                        }
+                    }
+                }
+            }
+        }
+        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( "Collapsed Up:" );
+            sb.append( ForesterUtil.LINE_SEPARATOR );
+            for( final Prefix prefix : _collapsed_up ) {
+                sb.append( prefix );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+            }
+            if ( _has_specifics ) {
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                sb.append( "Specifics Up:" );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                for( final Prefix prefix : _cleaned_spec_up ) {
+                    sb.append( prefix );
+                    sb.append( ForesterUtil.LINE_SEPARATOR );
+                }
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                sb.append( "Collapsed With Specifics Up:" );
+                sb.append( ForesterUtil.LINE_SEPARATOR );
+                for( final Prefix prefix : _collapsed_up ) {
+                    sb.append( prefix );
+                    sb.append( ForesterUtil.LINE_SEPARATOR );
+                    for( final Prefix spec : _cleaned_spec_up ) {
+                        if ( spec.getPrefix().startsWith( prefix.getPrefix() ) ) {
+                            sb.append( "    " + spec );
+                            sb.append( ForesterUtil.LINE_SEPARATOR );
+                        }
+                    }
+                }
+            }
+        }
+        return sb.toString();
     }
 
     void addGreatestCommonPrefix( final String prefix, final double confidence ) {
@@ -132,120 +243,85 @@ public final class Result2 {
         _greatest_common_prefixes_down.add( new Prefix( prefix_down, confidence, _separator ) );
     }
 
-    void setGreatestCommonCladeSubtreeConfidence( final String greatest_common_clade_confidence ) {
-        _greatest_common_clade_subtree_confidence = greatest_common_clade_confidence;
-    }
-
-    void setGreatestCommonCladeUpSubtreeConfidence( final String greatest_common_clade_confidence_up ) {
-        _greatest_common_clade_subtree_confidence_up = greatest_common_clade_confidence_up;
-    }
-
-    void setGreatestCommonCladeDownSubtreeConfidence( final String greatest_common_clade_confidence_down ) {
-        _greatest_common_clade_subtree_confidence_down = greatest_common_clade_confidence_down;
-    }
-
-    public String getGreatestCommonCladeSubtreeConfidence() {
-        return _greatest_common_clade_subtree_confidence;
-    }
-
-    public String getGreatestCommonCladeUpSubtreeConfidence() {
-        return _greatest_common_clade_subtree_confidence_up;
-    }
-
-    public String getGreatestCommonCladeDownSubtreeConfidence() {
-        return _greatest_common_clade_subtree_confidence_down;
-    }
-
-    public List<String> getWarnings() {
-        return _warnings;
-    }
-
-    public void analyzeGreatestCommonPrefixes( final double cutoff_for_specifics ) {
+    final void analyze( final double cutoff_for_specifics ) {
+        reset();
         analyzeGreatestCommonPrefixes( _greatest_common_prefixes, _separator, cutoff_for_specifics );
         analyzeGreatestCommonPrefixesUp( _greatest_common_prefixes_up, _separator, cutoff_for_specifics );
         analyzeGreatestCommonPrefixesDown( _greatest_common_prefixes_down, _separator, cutoff_for_specifics );
     }
 
-    public void analyzeGreatestCommonPrefixes() {
-        analyzeGreatestCommonPrefixes( _greatest_common_prefixes, _separator, -1 );
-    }
-
-    private void analyzeGreatestCommonPrefixesUp( final double cutoff_for_specifics ) {
-        analyzeGreatestCommonPrefixesUp( _greatest_common_prefixes_up, _separator, cutoff_for_specifics );
-    }
-
-    private void analyzeGreatestCommonPrefixesUp() {
-        analyzeGreatestCommonPrefixesUp( _greatest_common_prefixes_up, _separator, -1 );
-    }
-
-    private void analyzeGreatestCommonPrefixesDown( final double cutoff_for_specifics ) {
-        analyzeGreatestCommonPrefixesDown( _greatest_common_prefixes_down, _separator, cutoff_for_specifics );
-    }
-
-    private void analyzeGreatestCommonPrefixesDown() {
-        analyzeGreatestCommonPrefixesDown( _greatest_common_prefixes_down, _separator, -1 );
+    private final void reset() {
+        _all = new ArrayList<Prefix>();
+        _collapsed = new ArrayList<Prefix>();
+        _cleaned_spec = new ArrayList<Prefix>();
+        _has_specifics = false;
+        _all_up = new ArrayList<Prefix>();
+        _collapsed_up = new ArrayList<Prefix>();
+        _cleaned_spec_up = new ArrayList<Prefix>();
+        _has_specifics_up = false;
+        _all_down = new ArrayList<Prefix>();
+        _collapsed_down = new ArrayList<Prefix>();
+        _cleaned_spec_down = new ArrayList<Prefix>();
+        _has_specifics_down = false;
     }
 
     private final void analyzeGreatestCommonPrefixes( final List<Prefix> greatest_common_prefixes,
                                                       final String separator,
                                                       final double cutoff ) {
         final List<Prefix> l = obtainAllPrefixes( greatest_common_prefixes, separator );
-        sortPrefixesAccordingToConfidence( l );
-        _all = removeLessSpecificPrefixes( l );
-        _collapsed = collapse( _all );
-        _has_specifics = false;
-        if ( cutoff >= 0 ) {
-            _cleaned_spec = obtainSpecifics( cutoff, _all, _collapsed );
-            if ( _cleaned_spec != null && _cleaned_spec.size() > 0 ) {
-                _has_specifics = true;
+        if ( !ForesterUtil.isEmpty( l ) ) {
+            sortPrefixesAccordingToConfidence( l );
+            _all = removeLessSpecificPrefixes( l );
+            _collapsed = collapse( _all );
+            _has_specifics = false;
+            if ( cutoff >= 0 ) {
+                _cleaned_spec = obtainSpecifics( cutoff, _all, _collapsed );
+                if ( !ForesterUtil.isEmpty( _cleaned_spec ) ) {
+                    _has_specifics = true;
+                }
             }
         }
-        else {
-            _cleaned_spec = null;
-        }
     }
 
     private final void analyzeGreatestCommonPrefixesUp( final List<Prefix> greatest_common_prefixes_up,
                                                         final String separator,
                                                         final double cutoff ) {
         final List<Prefix> l = obtainAllPrefixes( greatest_common_prefixes_up, separator );
-        sortPrefixesAccordingToConfidence( l );
-        _all_up = removeLessSpecificPrefixes( l );
-        _collapsed_up = collapse( _all_up );
-        _has_specifics_up = false;
-        if ( cutoff >= 0 ) {
-            _cleaned_spec_up = obtainSpecifics( cutoff, _all_up, _collapsed_up );
-            if ( _cleaned_spec_up != null && _cleaned_spec_up.size() > 0 ) {
-                _has_specifics_up = true;
+        if ( !ForesterUtil.isEmpty( l ) ) {
+            sortPrefixesAccordingToConfidence( l );
+            _all_up = removeLessSpecificPrefixes( l );
+            _collapsed_up = collapse( _all_up );
+            _has_specifics_up = false;
+            if ( cutoff >= 0 ) {
+                _cleaned_spec_up = obtainSpecifics( cutoff, _all_up, _collapsed_up );
+                if ( !ForesterUtil.isEmpty( _cleaned_spec_up ) ) {
+                    _has_specifics_up = true;
+                }
             }
         }
-        else {
-            _cleaned_spec_up = null;
-        }
     }
 
-    private final void analyzeGreatestCommonPrefixesDown( final List<Prefix> greatest_common_prefixes_down,
-                                                          final String separator,
-                                                          final double cutoff ) {
+    final void analyzeGreatestCommonPrefixesDown( final List<Prefix> greatest_common_prefixes_down,
+                                                  final String separator,
+                                                  final double cutoff ) {
         final List<Prefix> l = obtainAllPrefixes( greatest_common_prefixes_down, separator );
-        sortPrefixesAccordingToConfidence( l );
-        _all_down = removeLessSpecificPrefixes( l );
-        _collapsed_down = collapse( _all_down );
-        _has_specifics_down = false;
-        if ( cutoff >= 0 ) {
-            _cleaned_spec_down = obtainSpecifics( cutoff, _all_down, _collapsed_down );
-            if ( _cleaned_spec_down != null && _cleaned_spec_down.size() > 0 ) {
-                _has_specifics_down = true;
+        if ( !ForesterUtil.isEmpty( l ) ) {
+            sortPrefixesAccordingToConfidence( l );
+            _all_down = removeLessSpecificPrefixes( l );
+            _collapsed_down = collapse( _all_down );
+            _has_specifics_down = false;
+            if ( cutoff >= 0 ) {
+                _cleaned_spec_down = obtainSpecifics( cutoff, _all_down, _collapsed_down );
+                if ( !ForesterUtil.isEmpty( _cleaned_spec_down ) ) {
+                    _has_specifics_down = true;
+                }
             }
         }
-        else {
-            _cleaned_spec_down = null;
-        }
     }
 
-    private final static List<Prefix> obtainSpecifics( final double cutoff,
-                                                       final List<Prefix> cleaned,
-                                                       final List<Prefix> collapsed ) {
+    final static List<Prefix> obtainSpecifics( final double cutoff,
+                                               final List<Prefix> cleaned,
+                                               final List<Prefix> collapsed ) {
         final List<Prefix> cleaned_spec = new ArrayList<>();
         final Set<String> collapsed_set = new HashSet<>();
         for( final Prefix prefix : collapsed ) {
@@ -285,7 +361,7 @@ public final class Result2 {
             }
         }
         if ( !ForesterUtil.isEqual( confidence_sum, 1.0, 1E-5 ) ) {
-           // throw new IllegalArgumentException( "Confidences add up to " + confidence_sum + " instead of 1.0" );
+            throw new IllegalArgumentException( "Confidences add up to " + confidence_sum + " instead of 1.0" );
         }
         return collapsed;
     }
@@ -355,124 +431,4 @@ public final class Result2 {
         }
         return l;
     }
-
-    public final String toString() {
-        final StringBuilder sb = new StringBuilder();
-        //TODO add all other stuff
-        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 ) {
-            sb.append( prefix );
-            sb.append( ForesterUtil.LINE_SEPARATOR );
-        }
-        if ( _has_specifics ) {
-            sb.append( ForesterUtil.LINE_SEPARATOR );
-            sb.append( "Specifics:" );
-            sb.append( ForesterUtil.LINE_SEPARATOR );
-            for( final Prefix prefix : _cleaned_spec ) {
-                sb.append( prefix );
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-            }
-            sb.append( ForesterUtil.LINE_SEPARATOR );
-            sb.append( "Collapsed With Specifics:" );
-            sb.append( ForesterUtil.LINE_SEPARATOR );
-            for( final Prefix prefix : _collapsed ) {
-                sb.append( prefix );
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                for( final Prefix spec : _cleaned_spec ) {
-                    if ( spec.getPrefix().startsWith( prefix.getPrefix() ) ) {
-                        sb.append( "    " + spec );
-                        sb.append( ForesterUtil.LINE_SEPARATOR );
-                    }
-                }
-            }
-        }
-        //////
-        if ( _all_down != null ) {
-            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 ) {
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                sb.append( "Specifics Down:" );
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                for( final Prefix prefix : _cleaned_spec_down ) {
-                    sb.append( prefix );
-                    sb.append( ForesterUtil.LINE_SEPARATOR );
-                }
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                sb.append( "Collapsed With Specifics Down:" );
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                for( final Prefix prefix : _collapsed_down ) {
-                    sb.append( prefix );
-                    sb.append( ForesterUtil.LINE_SEPARATOR );
-                    for( final Prefix spec : _cleaned_spec_down ) {
-                        if ( spec.getPrefix().startsWith( prefix.getPrefix() ) ) {
-                            sb.append( "    " + spec );
-                            sb.append( ForesterUtil.LINE_SEPARATOR );
-                        }
-                    }
-                }
-            }
-        }
-        //////
-        if ( _all_up != null ) {
-            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 ) {
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                sb.append( "Specifics Up:" );
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                for( final Prefix prefix : _cleaned_spec_up ) {
-                    sb.append( prefix );
-                    sb.append( ForesterUtil.LINE_SEPARATOR );
-                }
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                sb.append( "Collapsed With Specifics Up:" );
-                sb.append( ForesterUtil.LINE_SEPARATOR );
-                for( final Prefix prefix : _collapsed_up ) {
-                    sb.append( prefix );
-                    sb.append( ForesterUtil.LINE_SEPARATOR );
-                    for( final Prefix spec : _cleaned_spec_up ) {
-                        if ( spec.getPrefix().startsWith( prefix.getPrefix() ) ) {
-                            sb.append( "    " + spec );
-                            sb.append( ForesterUtil.LINE_SEPARATOR );
-                        }
-                    }
-                }
-            }
-        }
-        /////
-        return sb.toString();
-    }
 }
@@ -28,46 +28,20 @@ package org.forester.clade_analysis;
 import java.util.ArrayList;
 import java.util.List;
 
-public final class Result {
-
-    private String             _greatest_common_prefix                = "";
-    private String             _greatest_common_prefix_up             = "";
-    private String             _greatest_common_prefix_down           = "";
-    private final List<String> _warnings                              = new ArrayList<>();
-    private int                _lec_ext_nodes                         = 0;
-    private int                _p_ext_nodes                           = 0;
+import org.forester.util.ForesterUtil;
+
+public final class ResultSingle {
+
+    private String             _greatest_common_prefix                        = "";
+    private String             _greatest_common_prefix_up                     = "";
+    private String             _greatest_common_prefix_down                   = "";
+    private final List<String> _warnings                                      = new ArrayList<>();
+    private int                _lec_ext_nodes                                 = 0;
+    private int                _p_ext_nodes                                   = 0;
     private String             _greatest_common_clade_subtree_confidence      = "";
     private String             _greatest_common_clade_subtree_confidence_up   = "";
     private String             _greatest_common_clade_subtree_confidence_down = "";
 
-    void addWarning( final String warning ) {
-        _warnings.add( warning );
-    }
-
-    void setGreatestCommonPrefix( final String greatest_common_prefix ) {
-        _greatest_common_prefix = greatest_common_prefix;
-    }
-
-    void setGreatestCommonPrefixUp( final String greatest_common_prefix_up ) {
-        _greatest_common_prefix_up = greatest_common_prefix_up;
-    }
-
-    void setGreatestCommonPrefixDown( final String greatest_common_prefix_down ) {
-        _greatest_common_prefix_down = greatest_common_prefix_down;
-    }
-
-    void setGreatestCommonCladeSubtreeConfidence( final String greatest_common_clade_confidence ) {
-        _greatest_common_clade_subtree_confidence = greatest_common_clade_confidence;
-    }
-
-    void setGreatestCommonCladeUpSubtreeConfidence( final String greatest_common_clade_confidence_up ) {
-        _greatest_common_clade_subtree_confidence_up = greatest_common_clade_confidence_up;
-    }
-
-    void setGreatestCommonCladeDownSubtreeConfidence( final String greatest_common_clade_confidence_down ) {
-        _greatest_common_clade_subtree_confidence_down = greatest_common_clade_confidence_down;
-    }
-
     public String getGreatestCommonPrefix() {
         return _greatest_common_prefix;
     }
@@ -96,14 +70,6 @@ public final class Result {
         return _warnings;
     }
 
-    void setLeastEncompassingCladeSize( final int lec_ext_nodes ) {
-        _lec_ext_nodes = lec_ext_nodes;
-    }
-
-    void setTreeSize( final int p_ext_nodes ) {
-        _p_ext_nodes = p_ext_nodes;
-    }
-
     public int getLeastEncompassingCladeSize() {
         return _lec_ext_nodes;
     }
@@ -111,4 +77,50 @@ public final class Result {
     public int getTreeSize() {
         return _p_ext_nodes;
     }
+
+    public final String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "Greatest common prefix     : " + _greatest_common_prefix );
+        sb.append( ForesterUtil.LINE_SEPARATOR );
+        sb.append( "Greatest common prefix down: " + _greatest_common_prefix_down );
+        sb.append( ForesterUtil.LINE_SEPARATOR );
+        sb.append( "Greatest common prefix up  : " + _greatest_common_prefix_up );
+        return sb.toString();
+    }
+
+    void addWarning( final String warning ) {
+        _warnings.add( warning );
+    }
+
+    void setGreatestCommonPrefix( final String greatest_common_prefix ) {
+        _greatest_common_prefix = greatest_common_prefix;
+    }
+
+    void setGreatestCommonPrefixUp( final String greatest_common_prefix_up ) {
+        _greatest_common_prefix_up = greatest_common_prefix_up;
+    }
+
+    void setGreatestCommonPrefixDown( final String greatest_common_prefix_down ) {
+        _greatest_common_prefix_down = greatest_common_prefix_down;
+    }
+
+    void setGreatestCommonCladeSubtreeConfidence( final String greatest_common_clade_confidence ) {
+        _greatest_common_clade_subtree_confidence = greatest_common_clade_confidence;
+    }
+
+    void setGreatestCommonCladeUpSubtreeConfidence( final String greatest_common_clade_confidence_up ) {
+        _greatest_common_clade_subtree_confidence_up = greatest_common_clade_confidence_up;
+    }
+
+    void setGreatestCommonCladeDownSubtreeConfidence( final String greatest_common_clade_confidence_down ) {
+        _greatest_common_clade_subtree_confidence_down = greatest_common_clade_confidence_down;
+    }
+
+    void setLeastEncompassingCladeSize( final int lec_ext_nodes ) {
+        _lec_ext_nodes = lec_ext_nodes;
+    }
+
+    void setTreeSize( final int p_ext_nodes ) {
+        _p_ext_nodes = p_ext_nodes;
+    }
 }