2 // FORESTER -- software libraries and applications
3 // for evolutionary biology research and applications.
5 // Copyright (C) 2008-2009 Christian M. Zmasek
6 // Copyright (C) 2008-2009 Burnham Institute for Medical Research
7 // Copyright (C) 2000-2001 Washington University School of Medicine
8 // and Howard Hughes Medical Institute
9 // Copyright (C) 2003-2007 Ethalinda K.S. Cannon
10 // All rights reserved
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 // Contact: phylosoft @ gmail . com
27 // WWW: https://sites.google.com/site/cmzmasek/home/software/forester
29 package org.forester.archaeopteryx;
31 import java.awt.Color;
32 import java.io.BufferedReader;
34 import java.io.FileReader;
35 import java.io.IOException;
36 import java.io.InputStreamReader;
38 import java.util.Arrays;
39 import java.util.Hashtable;
41 import java.util.SortedMap;
42 import java.util.StringTokenizer;
43 import java.util.TreeMap;
45 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
46 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
47 import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE;
48 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
49 import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
50 import org.forester.phylogeny.data.NodeDataField;
51 import org.forester.phylogeny.data.NodeVisualData;
52 import org.forester.phylogeny.data.NodeVisualData.NodeFill;
53 import org.forester.phylogeny.data.NodeVisualData.NodeShape;
54 import org.forester.util.ForesterUtil;
56 public final class Configuration {
58 public enum EXT_NODE_DATA_RETURN_ON {
59 BUFFER_ONLY, CONSOLE, WINODW;
63 CROSSPLATFORM, NATIVE, NIMBUS, UNKNOWN
69 final static String clickto_options[][] = {
70 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
71 { "Go to Sub/Supertree", "display" }, { "Swap Descendants", "display" },
72 { "Colorize Node(s)", "display" }, { "Change Node Font(s)", "display" },
73 { "Colorize Subtree(s)", "display" }, { "Open Sequence DB", "display" }, { "Open PDB", "display" },
74 { "Open Taxonomy DB", "display" }, { "Launch BLAST", "display" }, { "Cut Subtree", "display" },
75 { "Copy Subtree", "display" }, { "Paste Subtree", "display" }, { "Delete Subtree/Node", "display" },
76 { "Add New Node", "display" }, { "Edit Node Data", "display" }, { "Sort Descendants", "display" },
77 { "List Node Data", "display" }, { "Select Node(s)", "display" } , { "Uncollapse All", "display" }, { "Order Subtree", "display" }, };
78 private final static String DEFAULT_SPECIES_COLORS[][] = {
79 { "BRAFL", "0x00FFFF" }, { "SPHGR", "0x9620F0" }, { "STRPU", "0x9620F0" }, { "CIOIN", "0xFF1CAE" },
80 { "CIOSA", "0xFF2CAE" }, { "BOVIN", "0x5C3317" }, { "CANFA", "0x8B2323" }, { "HUMAN", "0xFF2400" },
81 { "PANTR", "0xCC2400" }, { "MOUSE", "0xFF7F00" }, { "RAT", "0xFFEF00" }, { "MONDO", "0xEE9A49" },
82 { "ORNAN", "0xCD853F" }, { "XENLA", "0x6BAA23" }, { "XENTR", "0x6BAA23" }, { "CHICK", "0xFFC125" },
83 { "FUGRU", "0x0000FF" }, { "BRARE", "0x0000DD" }, { "DANRE", "0x0000BB" }, { "TETNG", "0x0000AA" },
84 { "ORYLA", "0x000088" }, { "GASAC", "0x000066" }, { "CAEEL", "0x666699" }, { "CAEBR", "0xB0B0B0" },
85 { "DROME", "0x663366" }, { "DROPS", "0x996699" }, { "APIME", "0x7A7700" }, { "AEDAE", "0x8C5900" },
86 { "TRICA", "0x918E00" }, { "NEMVE", "0x0066CC" }, { "HYDVU", "0x3399FF" }, { "LUBBA", "0xF7B5CB" },
87 { "GEOCY", "0xF5A0BD" }, { "AMPQE", "0x009966" }, { "SUBDO", "0xC790B9" }, { "MONBE", "0xFC0FC0" },
88 { "DICPU", "0xFFCC33" }, { "DICDI", "0xFFCC00" }, { "ENTHI", "0x5959AB" }, { "ARATH", "0x00FF00" },
89 { "POPTR", "0x006400" }, { "VITVI", "0x00CD00" }, { "GLYMA", "0x00FF7F" }, { "ORYSA", "0x008B00" },
90 { "ORYSJ", "0x008C00" }, { "SORBI", "0x00EE76" }, { "SELMO", "0x238E23" }, { "PHYPA", "0x09F911" },
91 { "OSTLU", "0x7FFF00" }, { "OSTTA", "0x7FFF00" }, { "OSTRC", "0x7FFF00" }, { "MICPU", "0x66CD00" },
92 { "MIC99", "0x66CD00" }, { "CHLRE", "0xB3EE3A" }, { "VOLCA", "0xC0FF3E" }, { "CHLSP", "0x6B8E23" },
93 { "CYAME", "0xD02090" }, { "YEAST", "0xAAAAAA" }, { "BACFR", "0xFF0000" }, { "BACTN", "0xFFFF00" },
94 { "MYXXD", "0x0000FF" }, { "STIAU", "0x00FFFF" }, { "BACOV", "0x8C5900" }, { "BACUN", "0x66CD00" },
95 { "PORGI", "0x918E00" } };
96 final static int display_node_data = 0;
97 final static int collapse_uncollapse = 1;
98 final static int reroot = 2;
99 final static int subtree = 3;
100 final static int swap = 4;
101 final static int color_node_font = 5;
102 final static int change_node_font = 6;
103 final static int color_subtree = 7;
104 final static int open_seq_web = 8;
105 final static int open_pdb_web = 9;
106 final static int open_tax_web = 10;
107 final static int blast = 11;
108 final static int cut_subtree = 12;
109 final static int copy_subtree = 13;
110 final static int paste_subtree = 14;
111 final static int delete_subtree_or_node = 15;
112 final static int add_new_node = 16;
113 final static int edit_node_data = 17;
114 final static int sort_descendents = 18;
115 final static int get_ext_desc_data = 19;
116 final static int select_nodes = 20;
117 final static int uncollapse_all = 21;
118 final static int order_subtree = 22;
120 // ------------------
122 // ------------------
123 final static String display_options[][] = {
124 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
125 { "Seq Annotations", "display", "no" }, { "Confidence Values", "display", "?" },
126 { "Node Events", "display", "?" }, { "Colorize by Taxonomy", "display", "no" },
127 { "Colorize by Sequence", "display", "no" }, { "Visual Styles/Branch Colors", "display", "no" },
128 { "Branch Widths", "display", "no" }, { "Domain Architectures", "display", "no" },
129 { "Binary Characters", "nodisplay", "no" }, { "Binary Char Counts", "nodisplay", "no" },
130 { "Seq Name", "display", "yes" }, { "Seq Accession", "display", "no" },
131 { "Show Internal Data", "display", "yes" }, { "Dyna Hide", "display", "yes" },
132 { "Taxonomy Scientific", "display", "yes" }, { "Taxonomy Common", "display", "no" },
133 { "Colorize by Annotation", "display", "no" }, { "Seq Symbol", "display", "yes" },
134 { "Rollover", "display", "yes" }, { "Relation Confidence", "nodisplay", "no" },
135 { "Vector Data", "nodisplay", "no" }, { "Taxonomy Images", "display", "no" },
136 { "Properties", "display", "no" }, { "Gene Name", "display", "yes" },
137 { "Multiple Seq Alignment", "display", "no" }, { "Branch Length Values", "display", "no" }
138 , { "Taxonomy Rank", "display", "no" }, { "Show External Data", "display", "yes" }};
139 final static int display_as_phylogram = 0;
140 final static int show_node_names = 1;
141 final static int show_tax_code = 2;
142 final static int show_annotation = 3;
143 final static int write_confidence_values = 4;
144 final static int write_events = 5;
145 final static int color_according_to_species = 6;
146 final static int color_according_to_sequence = 7;
147 final static int use_style = 8;
148 final static int width_branches = 9;
149 final static int show_domain_architectures = 10;
150 final static int show_binary_characters = 11;
151 final static int show_binary_character_counts = 12;
152 final static int show_seq_names = 13;
153 final static int show_sequence_acc = 14;
154 final static int display_internal_data = 15;
155 final static int dynamically_hide_data = 16;
156 final static int show_taxonomy_scientific_names = 17;
157 final static int show_taxonomy_common_names = 18;
158 final static int color_according_to_annotation = 19;
159 final static int show_seq_symbols = 20;
160 final static int node_data_popup = 21;
161 final static int show_relation_confidence = 22;
162 final static int show_vector_data = 23;
163 final static int show_taxonomy_images = 24;
164 final static int show_properties = 25;
165 final static int show_gene_names = 26;
166 final static int show_mol_seqs = 27;
167 final static int write_branch_length_values = 28;
168 final static int show_tax_rank = 29;
169 final static int display_external_data = 30;
171 static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
172 private static Hashtable<String, Color> _sequence_colors;
173 private static Hashtable<String, Color> _annotation_colors;
174 private static Hashtable<String, Color> _domain_colors;
175 private static Hashtable<String, Color> _species_colors;
176 private static String DEFAULT_FONT_FAMILY = "";
177 private static final int DEPRECATED = -2;
178 private static final String DISPLAY_COLOR_KEY = "display_color";
179 // ---------------------------
180 // Display options for trees
181 // ---------------------------
182 // ---------------------------------
183 // Pertaining to the config itself
184 // ---------------------------------
185 // Full path to config (may be URL)
186 String config_filename;
187 // This option is selected in the dropdown
188 int default_clickto = Configuration.display_node_data;
189 String default_config_filename = AptxConstants.DEFAULT_CONFIGURATION_FILE_NAME;
193 TreeColorSet tree_color_set;
197 TreeFontSet tree_font_set;
198 boolean verbose = AptxConstants.VERBOSE_DEFAULT;
199 private boolean _abbreviate_scientific_names = false;
200 private boolean _antialias_screen = true;
201 private boolean _background_color_gradient = false;
202 private String _base_font_family_name = "";
203 private int _base_font_size = -1;
204 private CLADOGRAM_TYPE _cladogram_type = AptxConstants.CLADOGRAM_TYPE_DEFAULT;
205 private boolean _color_labels_same_as_parent_branch = false;
206 private int _default_bootstrap_samples = -1;
207 private NodeFill _default_node_fill = NodeFill.SOLID;
208 private NodeShape _default_node_shape = NodeShape.RECTANGLE;
209 private short _default_node_shape_size = AptxConstants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
210 private SortedMap<String, Color> _display_colors = null;
211 private boolean _display_sequence_relations = false;
212 private boolean _editable = true;
213 private NodeDataField _ext_desc_data_to_return = NodeDataField.UNKNOWN;
214 private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
215 private int _frame_x_size;
216 private int _frame_y_size;
217 private Color _gui_background_color = AptxConstants.GUI_BACKGROUND_DEFAULT;
218 private Color _gui_button_background_color = AptxConstants.BUTTON_BACKGROUND_COLOR_DEFAULT;
219 private Color _gui_button_border_color = AptxConstants.BUTTON_BORDER_COLOR_DEFAULT;
220 private Color _gui_button_text_color = AptxConstants.BUTTON_TEXT_COLOR_DEFAULT;
221 private Color _gui_checkbox_and_button_active_color = AptxConstants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
222 private Color _gui_checkbox_text_color = AptxConstants.CHECKBOX_TEXT_COLOR_DEFAULT;
223 private Color _gui_menu_background_color = AptxConstants.MENU_BACKGROUND_COLOR_DEFAULT;
224 private Color _gui_menu_text_color = AptxConstants.MENU_TEXT_COLOR_DEFAULT;
225 private boolean _hide_controls_and_menus = false;
226 private boolean _internal_number_are_confidence_for_nh_parsing = false;
227 private String _label_for_get_ext_descendents_data = "";
228 private int _max_base_font_size = 20;
229 private boolean _midpoint_root = false;
230 private int _min_base_font_size = 2;
231 private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT;
232 private boolean _nh_parsing_replace_underscores = false;
233 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
234 private short _number_of_digits_after_comma_for_branch_length_values = AptxConstants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
235 private short _number_of_digits_after_comma_for_confidence_values = AptxConstants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
236 private short _ov_max_height = 80;
237 private short _ov_max_width = 80;
238 private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
239 private File _path_to_local_fastme = null;
240 private File _path_to_local_mafft = null;
241 private File _path_to_local_raxml = null;
242 private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
243 private float _print_line_width = AptxConstants.PDF_LINE_WIDTH_DEFAULT;
244 private boolean _show_annotation_ref_source = true;
245 private boolean _show_default_node_shapes_external = false;
246 private boolean _show_default_node_shapes_for_marked_nodes = false;
247 private boolean _show_default_node_shapes_internal = false;
248 private boolean _show_domain_labels = true;
249 private boolean _show_overview = true;
250 private boolean _show_scale = false;
251 private TAXONOMY_EXTRACTION _taxonomy_extraction = TAXONOMY_EXTRACTION.NO;
252 private UI _ui = UI.UNKNOWN;
253 private boolean _use_tabbed_display = false;
254 private boolean _validate_against_phyloxml_xsd_schema = AptxConstants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
255 private Color _vector_data_min_color = Color.BLUE;
256 private Color _vector_data_max_color = Color.YELLOW;
257 private Color _vector_data_mean_color = Color.WHITE;
258 private double _vector_data_height = 12;
259 private int _vector_data_width = 120;
260 private boolean _line_up_renderable_node_data = true;
261 private boolean _right_align_domains = false;
262 private boolean _allow_thick_strokes = false;
263 private boolean _could_read_config_file = false;
265 for( final String font_name : AptxConstants.DEFAULT_FONT_CHOICES ) {
266 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
267 DEFAULT_FONT_FAMILY = font_name;
271 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
272 DEFAULT_FONT_FAMILY = AptxConstants.DEFAULT_FONT_CHOICES[ AptxConstants.DEFAULT_FONT_CHOICES.length - 1 ];
276 public Configuration() {
277 this( null, false, false, false );
280 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
281 if ( ForesterUtil.isEmpty( cf ) ) {
282 config_filename = default_config_filename;
285 config_filename = cf;
287 _could_read_config_file = false;
288 setDisplayColors( new TreeMap<String, Color>() );
289 config_filename = config_filename.trim();
292 // If URL, open accordingly
294 u = new URL( config_filename );
296 final InputStreamReader isr = new InputStreamReader( u.openStream() );
297 final BufferedReader bf = new BufferedReader( isr );
300 ForesterUtil.programMessage( AptxConstants.PRG_NAME, "successfully read from configuration url ["
301 + config_filename + "]" );
302 _could_read_config_file = true;
304 catch ( final Exception e ) {
305 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "failed to read configuration from ["
306 + config_filename + "]: " + e.getLocalizedMessage() );
309 catch ( final Exception e ) {
310 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "cannot find or open configuration url ["
311 + config_filename + "]" );
315 // Otherwise, open as a file
316 File f = new File( config_filename );
318 f = new File( config_filename + ".txt" );
320 if ( f.exists() && f.canRead() ) {
322 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
325 _could_read_config_file = true;
327 catch ( final Exception e ) {
329 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "failed to read configuration from ["
330 + config_filename + "]: " + e );
336 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "cannot find or open configuration file ["
337 + config_filename + "]" );
343 public String getBaseFontFamilyName() {
344 return _base_font_family_name;
347 public int getDefaultBootstrapSamples() {
348 return _default_bootstrap_samples;
351 public NodeFill getDefaultNodeFill() {
352 return _default_node_fill;
355 public NodeShape getDefaultNodeShape() {
356 return _default_node_shape;
359 public short getDefaultNodeShapeSize() {
360 return _default_node_shape_size;
363 public NodeDataField getExtDescNodeDataToReturn() {
364 return _ext_desc_data_to_return;
367 public EXT_NODE_DATA_RETURN_ON getExtNodeDataReturnOn() {
368 return _ext_node_data_return_on;
371 public int getFrameXSize() {
372 return _frame_x_size;
375 public int getFrameYSize() {
376 return _frame_y_size;
379 public String getLabelForGetExtDescendentsData() {
380 return _label_for_get_ext_descendents_data;
383 public File getPathToLocalFastme() {
384 return _path_to_local_fastme;
387 public File getPathToLocalMafft() {
388 return _path_to_local_mafft;
391 public File getPathToLocalRaxml() {
392 return _path_to_local_raxml;
395 public double getVectorDataHeight() {
396 return _vector_data_height;
399 public Color getVectorDataMaxColor() {
400 return _vector_data_max_color;
403 public Color getVectorDataMeanColor() {
404 return _vector_data_mean_color;
407 public Color getVectorDataMinColor() {
408 return _vector_data_min_color;
411 public int getVectorDataWidth() {
412 return _vector_data_width;
415 public boolean isAbbreviateScientificTaxonNames() {
416 return _abbreviate_scientific_names;
419 public boolean isAllowThickStrokes() {
420 return _allow_thick_strokes;
423 public boolean isBackgroundColorGradient() {
424 return _background_color_gradient;
427 public boolean isColorByTaxonomicGroup() {
431 public boolean isColorLabelsSameAsParentBranch() {
432 return _color_labels_same_as_parent_branch;
435 final public boolean isLineUpRendarableNodeData() {
436 return _line_up_renderable_node_data;
439 public boolean isMidpointReroot() {
440 return _midpoint_root;
443 final public boolean isRightLineUpDomains() {
444 return _right_align_domains;
447 public boolean isShowAnnotationRefSource() {
448 return _show_annotation_ref_source;
451 public boolean isShowDefaultNodeShapesExternal() {
452 return _show_default_node_shapes_external;
455 public boolean isShowDefaultNodeShapesForMarkedNodes() {
456 return _show_default_node_shapes_for_marked_nodes;
459 public boolean isShowDefaultNodeShapesInternal() {
460 return _show_default_node_shapes_internal;
463 public boolean isShowDomainLabels() {
464 return _show_domain_labels;
467 public void putDisplayColors( final String key, final Color color ) {
468 getDisplayColors().put( key, color );
471 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
472 _abbreviate_scientific_names = abbreviate_scientific_names;
475 public void setAddTaxonomyImagesCB( final boolean b ) {
476 display_options[ show_taxonomy_images ][ 1 ] = b ? "yes" : "no";
479 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
480 _background_color_gradient = background_color_gradient;
483 public void setBaseFontFamilyName( final String base_font_family_name ) {
484 _base_font_family_name = base_font_family_name;
487 public void setBaseFontSize( final int base_font_size ) {
488 _base_font_size = base_font_size;
491 public void setColorizeBranches( final boolean b ) {
492 display_options[ use_style ][ 2 ] = b ? "yes" : "no";
495 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
496 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
499 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
500 _default_node_fill = default_node_fill;
503 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
504 _default_node_shape = default_node_shape;
507 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
508 _default_node_shape_size = default_node_shape_size;
511 public void setDisplayAsPhylogram( final boolean b ) {
512 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
515 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
516 _display_colors = display_colors;
519 public void setDisplayConfidenceValues( final boolean b ) {
520 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
523 public void setDisplayGeneNames( final boolean b ) {
524 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
527 public void setDisplayInternalData( final boolean b ) {
528 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
531 public void setDisplayExternalData( final boolean b ) {
532 display_options[ display_external_data ][ 2 ] = b ? "yes" : "no";
535 public void setDisplayMultipleSequenceAlignment( final boolean b ) {
536 display_options[ show_mol_seqs ][ 2 ] = b ? "yes" : "no";
539 public void setDisplayNodeNames( final boolean b ) {
540 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
543 public void setDisplaySequenceAcc( final boolean b ) {
544 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
547 public void setDisplaySequenceNames( final boolean b ) {
548 display_options[ show_seq_names ][ 2 ] = b ? "yes" : "no";
551 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
552 _display_sequence_relations = display_sequence_relations;
555 public void setDisplaySequenceSymbols( final boolean b ) {
556 display_options[ show_seq_symbols ][ 2 ] = b ? "yes" : "no";
559 public void setDisplayTaxonomyCode( final boolean b ) {
560 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
563 public void setDisplayTaxonomyRank( final boolean b ) {
564 display_options[ show_tax_rank ][ 2 ] = b ? "yes" : "no";
567 public void setDisplayTaxonomyCommonNames( final boolean b ) {
568 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
571 public void setDisplayTaxonomyImages( final boolean b ) {
572 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
575 public void setDisplayTaxonomyScientificNames( final boolean b ) {
576 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
579 public void setDynamicallyHideData( final boolean b ) {
580 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
583 public void setExtDescNodeDataToReturn( final NodeDataField ext_desc_data_to_return ) {
584 _ext_desc_data_to_return = ext_desc_data_to_return;
587 public void setFrameXSize( final int frame_x_size ) {
588 _frame_x_size = frame_x_size;
591 public void setFrameYSize( final int frame_y_size ) {
592 _frame_y_size = frame_y_size;
595 final public void setLineUpRendarableNodeData( final boolean line_up_renderable_node_data ) {
596 _line_up_renderable_node_data = line_up_renderable_node_data;
599 public void setMidpointReroot( final boolean midpoint_root ) {
600 _midpoint_root = midpoint_root;
603 public void setMinConfidenceValue( final double min_confidence_value ) {
604 _min_confidence_value = min_confidence_value;
607 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
608 _node_label_direction = node_label_direction;
611 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short number_of_digits_after_comma_for_branch_length_values ) {
612 _number_of_digits_after_comma_for_branch_length_values = number_of_digits_after_comma_for_branch_length_values;
615 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short number_of_digits_after_comma_for_confidence_values ) {
616 _number_of_digits_after_comma_for_confidence_values = number_of_digits_after_comma_for_confidence_values;
619 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
620 _phylogeny_graphics_type = phylogeny_graphics_type;
623 public void setPrintLineWidth( final float print_line_width ) {
624 _print_line_width = print_line_width;
627 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
628 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
631 final public void setRightLineUpDomains( final boolean right_align_domains ) {
632 _right_align_domains = right_align_domains;
635 public void setShowDefaultNodeShapesExternal( final boolean show_default_node_shapes_external ) {
636 _show_default_node_shapes_external = show_default_node_shapes_external;
639 public void setShowDefaultNodeShapesForMarkedNodes( final boolean show_default_node_shapes_for_marked_nodes ) {
640 _show_default_node_shapes_for_marked_nodes = show_default_node_shapes_for_marked_nodes;
643 public void setShowDefaultNodeShapesInternal( final boolean show_default_node_shapes_internal ) {
644 _show_default_node_shapes_internal = show_default_node_shapes_internal;
647 public void setShowDomainLabels( final boolean show_domain_labels ) {
648 _show_domain_labels = show_domain_labels;
651 public void setShowScale( final boolean show_scale ) {
652 _show_scale = show_scale;
655 public void setUseStyle( final boolean b ) {
656 display_options[ use_style ][ 2 ] = b ? "yes" : "no";
659 private int getClickToIndex( final String name ) {
661 if ( name.equals( "edit_info" ) ) {
662 index = Configuration.display_node_data;
664 .printWarningMessage( AptxConstants.PRG_NAME,
665 "configuration key [edit_info] is deprecated, use [display node data] instead" );
667 else if ( name.equals( "display_node_data" ) ) {
668 index = Configuration.display_node_data;
670 else if ( name.equals( "collapse_uncollapse" ) ) {
671 index = Configuration.collapse_uncollapse;
673 else if ( name.equals( "uncollapse_all" ) ) {
674 index = Configuration.uncollapse_all;
676 else if ( name.equals( "reroot" ) ) {
677 index = Configuration.reroot;
679 else if ( name.equals( "subtree" ) ) {
680 index = Configuration.subtree;
682 else if ( name.equals( "swap" ) ) {
683 index = Configuration.swap;
685 else if ( name.equals( "order_subtree" ) ) {
686 index = Configuration.order_subtree;
688 else if ( name.equals( "sort_descendants" ) ) {
689 index = Configuration.sort_descendents;
691 else if ( name.equals( "get_ext_descendents_data" ) ) {
692 index = Configuration.get_ext_desc_data;
694 else if ( name.equals( "display_sequences" ) ) {
696 .printWarningMessage( AptxConstants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
699 else if ( name.equals( "open_seq_web" ) ) {
700 index = Configuration.open_seq_web;
702 else if ( name.equals( "open_pdb_web" ) ) {
703 index = Configuration.open_pdb_web;
705 else if ( name.equals( "open_tax_web" ) ) {
706 index = Configuration.open_tax_web;
708 else if ( name.equals( "blast" ) ) {
709 index = Configuration.blast;
711 else if ( name.equals( "cut_subtree" ) ) {
712 index = Configuration.cut_subtree;
714 else if ( name.equals( "copy_subtree" ) ) {
715 index = Configuration.copy_subtree;
717 else if ( name.equals( "paste_subtree" ) ) {
718 index = Configuration.paste_subtree;
720 else if ( name.equals( "delete" ) ) {
721 index = Configuration.delete_subtree_or_node;
723 else if ( name.equals( "add_new_node" ) ) {
724 index = Configuration.add_new_node;
726 else if ( name.equals( "edit_node_data" ) ) {
727 index = Configuration.edit_node_data;
729 else if ( name.equals( "select_nodes" ) ) {
730 index = Configuration.select_nodes;
732 else if ( name.equals( "display_node_popup" ) ) {
733 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME,
734 "configuration key [display_node_popup] is deprecated" );
737 else if ( name.equals( "custom_option" ) ) {
738 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "configuration key [custom_option] is deprecated" );
741 else if ( name.equals( "color_subtree" ) ) {
742 index = Configuration.color_subtree;
744 else if ( name.equals( "change_node_font" ) ) {
745 index = Configuration.change_node_font;
747 else if ( name.equals( "color_node_font" ) ) {
748 index = Configuration.color_node_font;
750 else if ( name.equals( "color_subtree" ) ) {
751 index = Configuration.color_subtree;
756 private final void initSpeciesColors() {
757 _species_colors = new Hashtable<String, Color>();
758 for( final String[] s : DEFAULT_SPECIES_COLORS ) {
759 _species_colors.put( s[ 0 ], Color.decode( s[ 1 ] ) );
763 private boolean parseBoolean( final String str ) {
764 final String my_str = str.trim().toLowerCase();
765 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
768 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
772 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
777 private double parseDouble( final String str ) {
780 d = Double.parseDouble( str.trim() );
782 catch ( final Exception e ) {
783 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse double from [" + str + "]" );
789 private float parseFloat( final String str ) {
792 f = Float.parseFloat( str.trim() );
794 catch ( final Exception e ) {
795 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse float from [" + str + "]" );
801 private int parseInt( final String str ) {
804 i = Integer.parseInt( str.trim() );
806 catch ( final Exception e ) {
807 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse integer from [" + str + "]" );
813 private short parseShort( final String str ) {
816 i = Short.parseShort( str.trim() );
818 catch ( final Exception e ) {
819 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse short from [" + str + "]" );
825 private void processFontFamily( final StringTokenizer st ) {
826 setBaseFontFamilyName( "" );
827 final String font_str = ( ( String ) st.nextElement() ).trim();
828 final String[] fonts = font_str.split( ",+" );
829 for( String font : fonts ) {
830 font = font.replace( '_', ' ' ).trim();
831 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
832 setBaseFontFamilyName( font );
839 * read each line of config file, process non-comment lines
840 * @throws IOException
842 private void readConfig( final BufferedReader conf_in ) throws IOException {
845 line = conf_in.readLine();
846 if ( line != null ) {
848 // skip comments and blank lines
849 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
850 // convert runs of spaces to tabs
851 line = line.replaceAll( "\\s+", "\t" );
852 final StringTokenizer st = new StringTokenizer( line, "\t" );
856 } while ( line != null );
859 private void setAntialiasScreen( final boolean antialias_screen ) {
860 _antialias_screen = antialias_screen;
863 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
864 _cladogram_type = cladogram_type;
867 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
868 _default_bootstrap_samples = default_bootstrap_samples;
871 private void setEditable( final boolean editable ) {
872 _editable = editable;
875 private void setExtNodeDataReturnOn( final EXT_NODE_DATA_RETURN_ON ext_node_data_return_on ) {
876 _ext_node_data_return_on = ext_node_data_return_on;
879 //private void setGraphicsExportX( final int graphics_export_x ) {
880 // _graphics_export_x = graphics_export_x;
883 //private void setGraphicsExportY( final int graphics_export_y ) {
884 // _graphics_export_y = graphics_export_y;
887 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
888 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
892 * Set a key-value(s) tuple
894 private void setKeyValue( final StringTokenizer st ) {
895 final String key = ( ( String ) st.nextElement() ).replace( ':', ' ' ).trim().toLowerCase();
896 if ( !st.hasMoreElements() ) {
899 // Handle single value settings first:
900 if ( key.equals( "default_click_to" ) ) {
901 final String clickto_name = ( String ) st.nextElement();
902 default_clickto = getClickToIndex( clickto_name );
903 if ( default_clickto == -1 ) {
904 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "invalid value [" + clickto_name
905 + "] for [default_click_to]" );
908 else if ( default_clickto == DEPRECATED ) {
912 else if ( key.equals( "native_ui" ) ) {
913 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
914 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
917 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
918 _ui = UI.CROSSPLATFORM;
920 else if ( my_str.equals( "?" ) ) {
924 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
929 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
930 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
932 else if ( key.equals( "antialias_screen" ) ) {
933 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
935 else if ( key.equals( "phylogeny_graphics_type" ) ) {
936 final String type_str = ( ( String ) st.nextElement() ).trim();
937 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
938 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
940 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
941 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
943 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
944 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
946 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
947 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
949 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
950 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
952 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
953 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
955 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
956 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
958 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
959 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
962 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
963 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str
964 + "] for [phylogeny_graphics_type]" );
967 else if ( key.equals( "min_confidence_value" ) ) {
968 final String mcv_str = ( ( String ) st.nextElement() ).trim();
969 final double d = parseDouble( mcv_str );
970 setMinConfidenceValue( d );
972 else if ( key.equals( "font_family" ) ) {
973 processFontFamily( st );
975 else if ( key.equals( "font_size" ) ) {
976 final String size_str = ( ( String ) st.nextElement() ).trim();
977 final int i = parseInt( size_str );
979 setBaseFontSize( i );
982 else if ( key.equals( "font_size_min" ) ) {
983 final String size_str = ( ( String ) st.nextElement() ).trim();
984 final int i = parseInt( size_str );
986 setMinBaseFontSize( i );
989 else if ( key.equals( "font_size_max" ) ) {
990 final String size_str = ( ( String ) st.nextElement() ).trim();
991 final int i = parseInt( size_str );
993 setMaxBaseFontSize( i );
996 else if ( key.equals( "pdf_export_line_width" ) ) {
997 final String str = ( ( String ) st.nextElement() ).trim();
998 final float f = parseFloat( str );
1000 setPrintLineWidth( f );
1003 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME,
1004 "value for [pdf_export_line_width] cannot be zero or negative" );
1007 else if ( key.equals( "window_initial_size_x" ) ) {
1008 final String str = ( ( String ) st.nextElement() ).trim();
1009 final int i = parseInt( str );
1014 else if ( key.equals( "window_initial_size_y" ) ) {
1015 final String str = ( ( String ) st.nextElement() ).trim();
1016 final int i = parseInt( str );
1021 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1022 final String str = ( ( String ) st.nextElement() ).trim();
1023 final int i = parseInt( str );
1025 setDefaultBootstrapSamples( i );
1029 .printWarningMessage( AptxConstants.PRG_NAME,
1030 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1033 else if ( key.equals( "mafft_local" ) ) {
1034 final String str = ( ( String ) st.nextElement() ).trim();
1035 if ( !ForesterUtil.isEmpty( str ) ) {
1036 setPathToLocalMafft( new File( str ) );
1039 else if ( key.equals( "fastme_local" ) ) {
1040 final String str = ( ( String ) st.nextElement() ).trim();
1041 if ( !ForesterUtil.isEmpty( str ) ) {
1042 setPathToLocalFastme( new File( str ) );
1045 else if ( key.equals( "raxml_local" ) ) {
1046 final String str = ( ( String ) st.nextElement() ).trim();
1047 if ( !ForesterUtil.isEmpty( str ) ) {
1048 setPathToLocalRaxml( new File( str ) );
1051 else if ( key.equals( "show_scale" ) ) {
1052 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1054 else if ( key.equals( "show_overview" ) ) {
1055 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1057 else if ( key.equals( "background_gradient" ) ) {
1058 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1060 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1061 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1063 else if ( key.equals( "show_domain_labels" ) ) {
1064 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1066 else if ( key.equals( "show_seq_annotation_ref_sources" ) ) {
1067 setShowAnnotationRefSource( parseBoolean( ( String ) st.nextElement() ) );
1069 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1070 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1072 else if ( key.equals( "cladogram_type" ) ) {
1073 final String type_str = ( ( String ) st.nextElement() ).trim();
1074 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1075 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1077 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.LINED_UP.toString() ) ) {
1078 setCladogramType( Options.CLADOGRAM_TYPE.LINED_UP );
1081 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str
1082 + "] for [cladogram_type]" );
1085 else if ( key.equals( "hide_controls_and_menus" ) ) {
1086 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1088 else if ( key.equals( "use_tabbed_display" ) ) {
1089 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1091 else if ( key.equals( "overview_width" ) ) {
1092 final short i = parseShort( ( ( String ) st.nextElement() ) );
1095 else if ( key.equals( "overview_height" ) ) {
1096 final short i = parseShort( ( ( String ) st.nextElement() ) );
1097 setOvMaxHeight( i );
1099 else if ( key.equals( "overview_placement_type" ) ) {
1100 final String type_str = ( ( String ) st.nextElement() ).trim();
1101 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1102 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1104 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1105 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1107 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1108 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1110 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1111 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1114 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1115 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str
1116 + "] for [overview_placement_type]" );
1119 else if ( key.equals( "node_label_direction" ) ) {
1120 final String type_str = ( ( String ) st.nextElement() ).trim();
1121 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1122 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1124 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1125 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1128 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1129 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + type_str
1130 + "] for [node_label_direction]" );
1133 else if ( key.equals( "branch_length_value_digits" ) ) {
1134 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1136 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1139 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "illegal value [" + i
1140 + "] for [branch_length_value_digits]" );
1143 else if ( key.equals( "confidence_value_digits" ) ) {
1144 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1146 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1149 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "illegal value [" + i
1150 + "] for [confidence_value_digits]" );
1153 else if ( key.equals( "allow_editing" ) ) {
1154 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1156 else if ( key.equals( "display_sequence_relations" ) ) {
1157 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1159 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1160 final boolean r = parseBoolean( ( String ) st.nextElement() );
1161 if ( r && ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) ) {
1163 .printWarningMessage( AptxConstants.PRG_NAME,
1164 "attempt to extract taxonomies and replace underscores at the same time" );
1167 setReplaceUnderscoresInNhParsing( r );
1170 else if ( key.equals( "taxonomy_extraction_in_nh_parsing" ) ) {
1171 final String s = ( String ) st.nextElement();
1172 if ( s.equalsIgnoreCase( "no" ) ) {
1173 setTaxonomyExtraction( TAXONOMY_EXTRACTION.NO );
1175 else if ( s.equalsIgnoreCase( "pfam_relaxed" ) ) {
1176 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
1178 else if ( s.equalsIgnoreCase( "pfam_strict" ) ) {
1179 setTaxonomyExtraction( TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
1181 else if ( s.equalsIgnoreCase( "aggressive" ) ) {
1182 setTaxonomyExtraction( TAXONOMY_EXTRACTION.AGGRESSIVE );
1186 .printWarningMessage( AptxConstants.PRG_NAME,
1187 "unknown value for \"taxonomy_extraction_in_nh_parsing\": "
1189 + " (must be either: no, pfam_relaxed, pfam_strict, or aggressive)" );
1191 if ( ( getTaxonomyExtraction() != TAXONOMY_EXTRACTION.NO ) && isReplaceUnderscoresInNhParsing() ) {
1193 .printWarningMessage( AptxConstants.PRG_NAME,
1194 "attempt to extract taxonomies and replace underscores at the same time" );
1197 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1198 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1200 else if ( key.equals( "gui_background_color" ) ) {
1201 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1203 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1204 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1206 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1207 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1209 else if ( key.equals( "gui_button_text_color" ) ) {
1210 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1212 else if ( key.equals( "gui_button_background_color" ) ) {
1213 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1215 else if ( key.equals( "gui_menu_background_color" ) ) {
1216 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1218 else if ( key.equals( "gui_menu_text_color" ) ) {
1219 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1221 else if ( key.equals( "gui_button_border_color" ) ) {
1222 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1224 else if ( key.equals( "show_default_node_shapes_internal" ) ) {
1225 setShowDefaultNodeShapesInternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1227 else if ( key.equals( "show_default_node_shapes_external" ) ) {
1228 setShowDefaultNodeShapesExternal( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1230 else if ( key.equals( "show_node_shapes_for_nodes_with_vis_data" ) ) {
1231 setShowDefaultNodeShapesForMarkedNodes( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1233 else if ( key.equals( "default_node_size" ) ) {
1234 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1235 setDefaultNodeShapeSize( i );
1237 else if ( key.equals( "default_node_fill" ) ) {
1238 final String fill_str = ( ( String ) st.nextElement() ).trim();
1239 if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.NONE.toString() ) ) {
1240 setDefaultNodeFill( NodeFill.NONE );
1242 else if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.GRADIENT.toString() ) ) {
1243 setDefaultNodeFill( NodeFill.GRADIENT );
1245 else if ( fill_str.equalsIgnoreCase( NodeVisualData.NodeFill.SOLID.toString() ) ) {
1246 setDefaultNodeFill( NodeFill.SOLID );
1249 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + fill_str
1250 + "] for [default_node_fill]" );
1253 else if ( key.equals( "default_node_shape" ) ) {
1254 final String shape_str = ( ( String ) st.nextElement() ).trim();
1255 if ( shape_str.equalsIgnoreCase( NodeVisualData.NodeShape.CIRCLE.toString() ) ) {
1256 setDefaultNodeShape( NodeShape.CIRCLE );
1258 else if ( shape_str.equalsIgnoreCase( NodeVisualData.NodeShape.RECTANGLE.toString() ) ) {
1259 setDefaultNodeShape( NodeShape.RECTANGLE );
1262 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + shape_str
1263 + "] for [default_node_shape]" );
1266 else if ( key.equals( "midpoint_reroot" ) ) {
1267 setMidpointReroot( parseBoolean( ( String ) st.nextElement() ) );
1269 else if ( key.equals( "list_node_data_field" ) || key.equals( "ext_descendents_data_to_return" ) ) {
1270 final String s = ( ( String ) st.nextElement() ).trim();
1271 if ( s.equalsIgnoreCase( "node_name" ) ) {
1272 setExtDescNodeDataToReturn( NodeDataField.NODE_NAME );
1274 else if ( s.equalsIgnoreCase( "sequence_acc" ) ) {
1275 setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_ACC );
1277 else if ( s.equalsIgnoreCase( "sequence_mol_seq_fasta" ) ) {
1278 setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_MOL_SEQ_FASTA );
1280 else if ( s.equalsIgnoreCase( "sequence_name" ) ) {
1281 setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_NAME );
1283 else if ( s.equalsIgnoreCase( "gene_name" ) ) {
1284 setExtDescNodeDataToReturn( NodeDataField.GENE_NAME );
1286 else if ( s.equalsIgnoreCase( "sequence_symbol" ) ) {
1287 setExtDescNodeDataToReturn( NodeDataField.SEQUENCE_SYMBOL );
1289 else if ( s.equalsIgnoreCase( "taxonomy_scientific_name" ) ) {
1290 setExtDescNodeDataToReturn( NodeDataField.TAXONOMY_SCIENTIFIC_NAME );
1292 else if ( s.equalsIgnoreCase( "taxonomy_code" ) ) {
1293 setExtDescNodeDataToReturn( NodeDataField.TAXONOMY_CODE );
1295 else if ( s.equalsIgnoreCase( "user_selected" ) ) {
1296 setExtDescNodeDataToReturn( NodeDataField.UNKNOWN );
1298 else if ( s.equalsIgnoreCase( "domains" ) ) {
1299 setExtDescNodeDataToReturn( NodeDataField.DOMAINS_ALL );
1301 else if ( s.equalsIgnoreCase( "domains_collapsed" ) ) {
1302 setExtDescNodeDataToReturn( NodeDataField.DOMAINS_COLLAPSED_PER_PROTEIN );
1304 else if ( s.equalsIgnoreCase( "seq_annotations" ) ) {
1305 setExtDescNodeDataToReturn( NodeDataField.SEQ_ANNOTATIONS );
1307 else if ( s.equalsIgnoreCase( "go_term_ids" ) ) {
1308 setExtDescNodeDataToReturn( NodeDataField.GO_TERM_IDS );
1311 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + s
1312 + "] for [ext_descendents_data_to_return]" );
1315 else if ( key.equals( "list_node_data_custom_label" ) || key.equals( "label_for_get_ext_descendents_data" ) ) {
1316 final String s = ( ( String ) st.nextElement() ).trim();
1317 if ( !ForesterUtil.isEmpty( s ) && ( s.length() > 1 ) ) {
1318 setLabelForGetExtDescendentsData( s.replaceAll( "_", " " ) );
1321 else if ( key.equals( "list_node_data_in" ) || key.equals( "ext_descendents_data_to_return_on" ) ) {
1322 final String s = ( ( String ) st.nextElement() ).trim().toLowerCase();
1323 if ( s.equals( "console" ) ) {
1324 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.CONSOLE );
1326 else if ( s.equals( "window" ) ) {
1327 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
1329 else if ( s.equals( "buffer_only" ) ) {
1330 setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
1333 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown value [" + s
1334 + "] for [ext_descendents_data_to_return_on]" );
1337 else if ( key.equals( "vector_data_min_color" ) ) {
1338 _vector_data_min_color = Color.decode( ( String ) st.nextElement() );
1340 else if ( key.equals( "vector_data_max_color" ) ) {
1341 _vector_data_max_color = Color.decode( ( String ) st.nextElement() );
1343 else if ( key.equals( "vector_data_mean_color" ) ) {
1344 _vector_data_mean_color = Color.decode( ( String ) st.nextElement() );
1346 else if ( key.equals( "vector_data_width" ) ) {
1347 _vector_data_width = parseShort( ( String ) st.nextElement() );
1348 if ( _vector_data_width < 1 ) {
1349 _vector_data_width = 120;
1352 else if ( key.equals( "vector_data_height" ) ) {
1353 _vector_data_height = parseShort( ( String ) st.nextElement() );
1354 if ( _vector_data_height < 1 ) {
1355 _vector_data_height = 12;
1358 else if ( key.equals( "line_up_renderable_data" ) ) {
1359 setLineUpRendarableNodeData( parseBoolean( ( String ) st.nextElement() ) );
1361 else if ( key.equals( "right_align_domain_architectures" ) ) {
1362 setRightLineUpDomains( parseBoolean( ( String ) st.nextElement() ) );
1364 else if ( key.equals( "allow_thick_strokes" ) ) {
1365 _allow_thick_strokes = parseBoolean( ( String ) st.nextElement() );
1367 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1370 if ( key.equals( "phylogram" ) ) {
1371 key_index = Configuration.display_as_phylogram;
1373 else if ( key.equals( "rollover" ) ) {
1374 key_index = Configuration.node_data_popup;
1376 else if ( key.equals( "color_according_to_species" ) ) {
1377 key_index = Configuration.color_according_to_species;
1379 else if ( key.equals( "color_according_to_sequence" ) ) {
1380 key_index = Configuration.color_according_to_sequence;
1382 else if ( key.equals( "show_node_names" ) ) {
1383 key_index = Configuration.show_node_names;
1385 else if ( key.equals( "show_taxonomy_code" ) ) {
1386 key_index = Configuration.show_tax_code;
1388 else if ( key.equals( "show_taxonomy_rank" ) ) {
1389 key_index = Configuration.show_tax_rank;
1391 else if ( key.equals( "write_confidence_values" ) ) {
1392 key_index = Configuration.write_confidence_values;
1394 else if ( key.equals( "write_branch_length_values" ) ) {
1395 key_index = Configuration.write_branch_length_values;
1397 else if ( key.equals( "write_events" ) ) {
1398 key_index = Configuration.write_events;
1400 else if ( key.equals( "use_visual_styles" ) ) {
1401 key_index = Configuration.use_style;
1403 else if ( key.equals( "color_branches" ) ) {
1404 key_index = Configuration.use_style;
1406 .printWarningMessage( AptxConstants.PRG_NAME,
1407 "configuration key [color_branches] is deprecated, use [use_visual_styles] instead" );
1409 else if ( key.equals( "width_branches" ) ) {
1410 key_index = Configuration.width_branches;
1412 else if ( key.equals( "show_domain_architectures" ) ) {
1413 key_index = Configuration.show_domain_architectures;
1415 else if ( key.equals( "show_msa" ) ) {
1416 key_index = Configuration.show_mol_seqs;
1418 else if ( key.equals( "show_annotations" ) ) {
1419 key_index = Configuration.show_annotation;
1421 else if ( key.equals( "show_binary_characters" ) ) {
1422 key_index = Configuration.show_binary_characters;
1424 else if ( key.equals( "show_binary_character_counts" ) ) {
1425 key_index = Configuration.show_binary_character_counts;
1427 else if ( key.equals( "show_seq_names" ) ) {
1428 key_index = Configuration.show_seq_names;
1430 else if ( key.equals( "show_gene_names" ) ) {
1431 key_index = Configuration.show_gene_names;
1433 else if ( key.equals( "show_seq_symbols" ) ) {
1434 key_index = Configuration.show_seq_symbols;
1436 else if ( key.equals( "show_seq_acc" ) ) {
1437 key_index = Configuration.show_sequence_acc;
1439 else if ( key.equals( "display_internal_data" ) ) {
1440 key_index = Configuration.display_internal_data;
1442 else if ( key.equals( "display_external_data" ) ) {
1443 key_index = Configuration.display_external_data;
1445 else if ( key.equals( "dynamically_hide_data" ) ) {
1446 key_index = Configuration.dynamically_hide_data;
1448 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1449 key_index = Configuration.show_taxonomy_scientific_names;
1451 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1452 key_index = Configuration.show_taxonomy_common_names;
1454 else if ( key.equals( "show_taxonomy_images" ) ) {
1455 key_index = Configuration.show_taxonomy_images;
1457 else if ( key.equals( "color_according_to_annotation" ) ) {
1458 key_index = Configuration.color_according_to_annotation;
1460 else if ( key.equals( "show_vector_data" ) ) {
1461 key_index = Configuration.show_vector_data;
1463 else if ( key.equals( "show_properties" ) ) {
1464 key_index = Configuration.show_properties;
1466 else if ( key.equals( "show_relation_confidence" ) ) {
1467 key_index = Configuration.show_relation_confidence;
1469 // If we've found the key, set the values
1470 if ( key_index >= 0 ) {
1471 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1472 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1473 // otherwise, keep looking
1476 if ( key_index == DEPRECATED ) {
1479 else if ( key.equals( "click_to" ) ) {
1480 final String click_to_name = ( String ) st.nextElement();
1481 key_index = getClickToIndex( click_to_name );
1482 if ( key_index >= 0 ) {
1483 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1485 else if ( key_index == DEPRECATED ) {
1489 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown click-to option: "
1493 else if ( key.equals( "species_color" ) ) {
1494 getSpeciesColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1495 Color.decode( ( String ) st.nextElement() ) );
1497 else if ( key.equals( "sequence_color" ) ) {
1498 getSequenceColors().put( ( ( String ) st.nextElement() ).replace( '_', ' ' ),
1499 Color.decode( ( String ) st.nextElement() ) );
1501 else if ( key.equals( "domain_color" ) ) {
1502 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1504 else if ( key.equals( "annotation_color" ) ) {
1505 getAnnotationColors()
1506 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1508 else if ( key.equals( "function_color" ) ) {
1509 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME,
1510 "configuration key [function_color] is deprecated" );
1512 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1513 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1516 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown configuration key [" + key
1517 + "] in: " + config_filename );
1522 ForesterUtil.printWarningMessage( AptxConstants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1523 + config_filename );
1527 private void setLabelForGetExtDescendentsData( final String label_for_get_ext_descendents_data ) {
1528 _label_for_get_ext_descendents_data = label_for_get_ext_descendents_data;
1531 private void setMaxBaseFontSize( final int max_base_font_size ) {
1532 _max_base_font_size = max_base_font_size;
1535 private void setMinBaseFontSize( final int min_base_font_size ) {
1536 _min_base_font_size = min_base_font_size;
1539 private void setOvMaxHeight( final short ov_max_height ) {
1540 _ov_max_height = ov_max_height;
1543 private void setOvMaxWidth( final short ov_max_width ) {
1544 _ov_max_width = ov_max_width;
1547 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1548 _ov_placement = ov_placement;
1551 private void setPathToLocalFastme( final File path_to_local_fastme ) {
1552 _path_to_local_fastme = path_to_local_fastme;
1555 private void setPathToLocalMafft( final File path_to_local_mafft ) {
1556 _path_to_local_mafft = path_to_local_mafft;
1559 private void setPathToLocalRaxml( final File path_to_local_raxml ) {
1560 _path_to_local_raxml = path_to_local_raxml;
1563 private void setShowAnnotationRefSource( final boolean b ) {
1564 _show_annotation_ref_source = b;
1567 private void setShowOverview( final boolean show_overview ) {
1568 _show_overview = show_overview;
1571 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1572 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1575 boolean displaySequenceRelations() {
1576 return _display_sequence_relations;
1579 boolean doCheckOption( final int which ) {
1580 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
1581 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
1584 boolean doDisplayClickToOption( final int which ) {
1585 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
1588 boolean doDisplayOption( final int which ) {
1589 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
1593 * Will attempt to use the phylogeny to determine whether to check
1594 * this or not (e.g. phylogram)
1597 boolean doGuessCheckOption( final int which ) {
1598 return display_options[ which ][ 2 ].equals( "?" );
1601 Map<String, Color> getAnnotationColors() {
1602 if ( _annotation_colors == null ) {
1603 _annotation_colors = new Hashtable<String, Color>();
1605 return _annotation_colors;
1608 int getBaseFontSize() {
1609 return _base_font_size;
1612 CLADOGRAM_TYPE getCladogramType() {
1613 return _cladogram_type;
1616 int getClickToOptionsCount() {
1617 return clickto_options.length;
1620 String getClickToTitle( final int which ) {
1621 return clickto_options[ which ][ 0 ];
1624 int getDefaultDisplayClicktoOption() {
1625 return default_clickto;
1628 SortedMap<String, Color> getDisplayColors() {
1629 return _display_colors;
1632 String getDisplayTitle( final int which ) {
1633 return display_options[ which ][ 0 ];
1636 Map<String, Color> getDomainColors() {
1637 if ( _domain_colors == null ) {
1638 _domain_colors = new Hashtable<String, Color>();
1640 return _domain_colors;
1644 Color getGuiBackgroundColor() {
1645 return _gui_background_color;
1648 Color getGuiButtonBackgroundColor() {
1649 return _gui_button_background_color;
1652 Color getGuiButtonBorderColor() {
1653 return _gui_button_border_color;
1656 Color getGuiButtonTextColor() {
1657 return _gui_button_text_color;
1660 Color getGuiCheckboxAndButtonActiveColor() {
1661 return _gui_checkbox_and_button_active_color;
1664 Color getGuiCheckboxTextColor() {
1665 return _gui_checkbox_text_color;
1668 Color getGuiMenuBackgroundColor() {
1669 return _gui_menu_background_color;
1672 Color getGuiMenuTextColor() {
1673 return _gui_menu_text_color;
1676 static int getGuiFontSize() {
1680 int getMaxBaseFontSize() {
1681 return _max_base_font_size;
1684 int getMinBaseFontSize() {
1685 return _min_base_font_size;
1688 double getMinConfidenceValue() {
1689 return _min_confidence_value;
1692 NODE_LABEL_DIRECTION getNodeLabelDirection() {
1693 return _node_label_direction;
1696 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
1697 return _number_of_digits_after_comma_for_branch_length_values;
1700 short getNumberOfDigitsAfterCommaForConfidenceValues() {
1701 return _number_of_digits_after_comma_for_confidence_values;
1704 short getOvMaxHeight() {
1705 return _ov_max_height;
1708 short getOvMaxWidth() {
1709 return _ov_max_width;
1712 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
1713 return _ov_placement;
1716 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
1717 return _phylogeny_graphics_type;
1720 float getPrintLineWidth() {
1721 return _print_line_width;
1724 Hashtable<String, Color> getSequenceColors() {
1725 if ( _sequence_colors == null ) {
1726 _sequence_colors = new Hashtable<String, Color>();
1728 return _sequence_colors;
1731 Hashtable<String, Color> getSpeciesColors() {
1732 if ( _species_colors == null ) {
1733 initSpeciesColors();
1735 return _species_colors;
1738 public final TAXONOMY_EXTRACTION getTaxonomyExtraction() {
1739 return _taxonomy_extraction;
1742 boolean isAntialiasScreen() {
1743 return _antialias_screen;
1747 * Convenience method.
1749 * @return true if value in configuration file was 'yes'
1751 boolean isDrawAsPhylogram() {
1752 return doCheckOption( display_as_phylogram );
1755 boolean isEditable() {
1760 * Only used by ArchaeoptryxE.
1763 boolean isHideControlPanelAndMenubar() {
1764 return _hide_controls_and_menus;
1767 public boolean isInternalNumberAreConfidenceForNhParsing() {
1768 return _internal_number_are_confidence_for_nh_parsing;
1771 public boolean isReplaceUnderscoresInNhParsing() {
1772 return _nh_parsing_replace_underscores;
1775 boolean isShowOverview() {
1776 return _show_overview;
1779 boolean isShowScale() {
1783 final boolean isUseNativeUI() {
1784 if ( ( _ui == UI.UNKNOWN ) && ForesterUtil.isMac() ) {
1787 return _ui == UI.NATIVE;
1791 * Only used by ArchaeoptryxE.
1794 boolean isUseTabbedDisplay() {
1795 return _use_tabbed_display;
1798 public boolean isValidatePhyloXmlAgainstSchema() {
1799 return _validate_against_phyloxml_xsd_schema;
1802 final void setTaxonomyExtraction( final TAXONOMY_EXTRACTION taxonomy_extraction ) {
1803 _taxonomy_extraction = taxonomy_extraction;
1806 static String getDefaultFontFamilyName() {
1807 return DEFAULT_FONT_FAMILY;
1810 public boolean isCouldReadConfigFile() {
1811 return _could_read_config_file;
1815 public String getConfigFilename() {
1816 return config_filename;