2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2017 Christian M. Zmasek
6 // Copyright (C) 2017 J. Craig Venter Institute
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 // Contact: phyloxml @ gmail . com
24 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
26 package org.forester.clade_analysis;
28 import java.util.ArrayList;
29 import java.util.List;
30 import java.util.Map.Entry;
31 import java.util.SortedMap;
32 import java.util.TreeMap;
34 import org.forester.util.ForesterUtil;
36 public final class Result2 {
38 private List<Prefix> _greatest_common_prefix = new ArrayList<Prefix>();
39 private String _greatest_common_prefix_up = "";
40 private String _greatest_common_prefix_down = "";
41 private final List<String> _warnings = new ArrayList<>();
42 private int _lec_ext_nodes = 0;
43 private int _p_ext_nodes = 0;
44 private String _greatest_common_clade_subtree_confidence = "";
45 private String _greatest_common_clade_subtree_confidence_up = "";
46 private String _greatest_common_clade_subtree_confidence_down = "";
48 void addWarning( final String warning ) {
49 _warnings.add( warning );
52 void addGreatestCommonPrefix( final String prefix, final double confidence ) {
53 _greatest_common_prefix.add( new Prefix(prefix, confidence) );
56 void setGreatestCommonPrefixUp( final String greatest_common_prefix_up ) {
57 _greatest_common_prefix_up = greatest_common_prefix_up;
60 void setGreatestCommonPrefixDown( final String greatest_common_prefix_down ) {
61 _greatest_common_prefix_down = greatest_common_prefix_down;
64 void setGreatestCommonCladeSubtreeConfidence( final String greatest_common_clade_confidence ) {
65 _greatest_common_clade_subtree_confidence = greatest_common_clade_confidence;
68 void setGreatestCommonCladeUpSubtreeConfidence( final String greatest_common_clade_confidence_up ) {
69 _greatest_common_clade_subtree_confidence_up = greatest_common_clade_confidence_up;
72 void setGreatestCommonCladeDownSubtreeConfidence( final String greatest_common_clade_confidence_down ) {
73 _greatest_common_clade_subtree_confidence_down = greatest_common_clade_confidence_down;
76 // public String getGreatestCommonPrefix() {
77 // return _greatest_common_prefix;
80 public String getGreatestCommonPrefixUp() {
81 return _greatest_common_prefix_up;
84 public String getGreatestCommonPrefixDown() {
85 return _greatest_common_prefix_down;
88 public String getGreatestCommonCladeSubtreeConfidence() {
89 return _greatest_common_clade_subtree_confidence;
92 public String getGreatestCommonCladeUpSubtreeConfidence() {
93 return _greatest_common_clade_subtree_confidence_up;
96 public String getGreatestCommonCladeDownSubtreeConfidence() {
97 return _greatest_common_clade_subtree_confidence_down;
100 public List<String> getWarnings() {
104 void setLeastEncompassingCladeSize( final int lec_ext_nodes ) {
105 _lec_ext_nodes = lec_ext_nodes;
108 void setTreeSize( final int p_ext_nodes ) {
109 _p_ext_nodes = p_ext_nodes;
112 public int getLeastEncompassingCladeSize() {
113 return _lec_ext_nodes;
116 public int getTreeSize() {
120 public void analyzeGreatestCommonPrefixes(final String separator ) {
121 final SortedMap<String,Double> map = new TreeMap<String,Double>();
122 for( final Prefix prefix : _greatest_common_prefix ) {
123 List<String> prefixes = ForesterUtil.spliIntoPrefixes( prefix.getPrefix(), separator );
124 for( final String p : prefixes ) {
128 // System.out.println( map );
129 for (final String key : map.keySet()) {
130 //System.out.println(key);
131 for( final Prefix prefix : _greatest_common_prefix ) {
132 if ( prefix.getPrefix().startsWith( key ) ) {
133 map.put( key, map.get( key ) + prefix.getConfidence() );
137 System.out.println( map );