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: www.phylosoft.org/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;
37 import java.net.MalformedURLException;
39 import java.util.Arrays;
40 import java.util.Hashtable;
42 import java.util.SortedMap;
43 import java.util.StringTokenizer;
44 import java.util.TreeMap;
46 import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
47 import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
48 import org.forester.archaeopteryx.Options.OVERVIEW_PLACEMENT_TYPE;
49 import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
50 import org.forester.phylogeny.data.NodeVisualization;
51 import org.forester.phylogeny.data.NodeVisualization.NodeFill;
52 import org.forester.phylogeny.data.NodeVisualization.NodeShape;
53 import org.forester.util.ForesterUtil;
55 public final class Configuration {
57 static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
58 private static final String WEB_LINK_KEY = "web_link";
59 private static final String DISPLAY_COLOR_KEY = "display_color";
60 private static final int DEPRECATED = -2;
61 private UI _ui = UI.UNKNOWN;
62 private boolean _use_tabbed_display = false;
63 private boolean _hide_controls_and_menus = false;
64 private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
65 private File _mafft = null;
66 private File _clustalo = null;
67 private File _fastme = null;
69 private SortedMap<String, WebLink> _weblinks = null;
70 private SortedMap<String, Color> _display_colors = null;
71 private boolean _antialias_screen = true;
72 private PHYLOGENY_GRAPHICS_TYPE _phylogeny_graphics_type = PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR;
73 private String _base_font_family_name = "";
74 private int _base_font_size = -1;
75 private int _graphics_export_x = -1;
76 private int _graphics_export_y = -1;
77 private short _ov_max_width = 80;
78 private short _ov_max_height = 80;
79 private OVERVIEW_PLACEMENT_TYPE _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT;
80 private double _min_confidence_value = Options.MIN_CONFIDENCE_DEFAULT;
81 private float _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT;
82 private boolean _show_scale = false;
83 private boolean _show_branch_length_values = false;
84 private boolean _show_overview = true;
85 private short _number_of_digits_after_comma_for_confidence_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_CONFIDENCE_VALUES_DEFAULT;
86 private short _number_of_digits_after_comma_for_branch_length_values = Constants.NUMBER_OF_DIGITS_AFTER_COMMA_FOR_BRANCH_LENGTH_VALUES_DEFAULT;
87 private boolean _editable = true;
88 private boolean _nh_parsing_replace_underscores = false;
89 private boolean _nh_parsing_extract_pfam_taxonomy_codes = false;
90 private boolean _internal_number_are_confidence_for_nh_parsing = false;
91 private boolean _display_sequence_relations = false;
92 private boolean _validate_against_phyloxml_xsd_schema = Constants.VALIDATE_AGAINST_PHYLOXML_XSD_SCJEMA_DEFAULT;
93 private boolean _background_color_gradient = false;
94 private boolean _show_domain_labels = true;
95 private boolean _abbreviate_scientific_names = false;
96 private boolean _color_labels_same_as_parent_branch = false;
97 private int _default_bootstrap_samples = -1;
98 private boolean _show_default_node_shapes = false;
99 private NodeShape _default_node_shape = NodeShape.CIRCLE;
100 private NodeFill _default_node_fill = NodeFill.GRADIENT;
101 private short _default_node_shape_size = Constants.DEFAULT_NODE_SHAPE_SIZE_DEFAULT;
102 private boolean _taxonomy_colorize_node_shapes = false;
103 final static int display_as_phylogram = 0;
104 final static int show_node_names = 1;
105 final static int show_tax_code = 2;
106 final static int show_annotation = 3;
107 final static int write_confidence_values = 4;
108 final static int write_events = 5;
109 final static int color_according_to_species = 6;
110 final static int color_branches = 7;
111 final static int width_branches = 8;
112 final static int show_custom_node_shapes = 9;
113 final static int show_domain_architectures = 10;
114 final static int show_binary_characters = 11;
115 final static int show_binary_character_counts = 12;
116 final static int show_gene_names = 13;
117 final static int show_sequence_acc = 14;
118 final static int display_internal_data = 15;
119 final static int dynamically_hide_data = 16;
120 final static int show_taxonomy_scientific_names = 17;
121 final static int show_taxonomy_common_names = 18;
122 final static int color_according_to_annotation = 19;
123 final static int show_gene_symbols = 20;
124 final static int node_data_popup = 21;
125 final static int show_relation_confidence = 22;
126 final static int show_vector_data = 23;
127 final static int show_taxonomy_images = 24;
128 final static int show_properties = 25;
129 // ------------------
131 // ------------------
132 final static int display_node_data = 0;
133 final static int collapse_uncollapse = 1;
134 final static int reroot = 2;
135 final static int subtree = 3;
136 final static int swap = 4;
137 final static int color_subtree = 5;
138 final static int open_seq_web = 6;
139 final static int open_tax_web = 7;
140 final static int blast = 8;
141 final static int cut_subtree = 9;
142 final static int copy_subtree = 10;
143 final static int paste_subtree = 11;
144 final static int delete_subtree_or_node = 12;
145 final static int add_new_node = 13;
146 final static int edit_node_data = 14;
147 final static int sort_descendents = 15;
148 // ---------------------------
149 // Display options for trees
150 // ---------------------------
151 // ---------------------------------
152 // Pertaining to the config itself
153 // ---------------------------------
154 // Full path to config (may be URL)
155 String config_filename;
156 String default_config_filename = Constants.DEFAULT_CONFIGURATION_FILE_NAME;
157 final static String display_options[][] = {
158 { "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
159 { "Annotation", "nodisplay", "no" }, { "Confidence Values", "display", "?" }, { "Event", "display", "?" },
160 { "Taxonomy Colorize", "display", "no" }, { "Colorize Branches", "display", "no" },
161 { "Use Branch-Widths", "display", "no" }, { "Show Custom Nodes", "display", "yes" },
162 { "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" },
163 { "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "yes" },
164 { "Prot/Gene Acc", "display", "no" }, { "Show Internal Data", "display", "yes" },
165 { "Dyna Hide", "display", "yes" }, { "Taxonomy Scientific", "display", "yes" },
166 { "Taxonomy Common", "display", "no" }, { "Annotation Colorize", "nodisplay", "no" },
167 { "Prot/Gene Symbol", "display", "yes" }, { "Rollover", "display", "yes" },
168 { "Relation Confidence", "display", "no" }, { "Vector Data", "display", "no" },
169 { "Taxonomy Images", "display", "no" }, { "Properties", "display", "no" } };
170 final static String clickto_options[][] = {
171 { "Display Node Data", "display" }, { "Collapse/Uncollapse", "display" }, { "Root/Reroot", "display" },
172 { "Sub/Super Tree", "display" }, { "Swap Descendants", "display" }, { "Colorize Subtree", "display" },
173 { "Open Sequence Web", "display" }, { "Open Taxonomy Web", "display" }, { "Blast", "display" },
174 { "Cut Subtree", "display" }, { "Copy Subtree", "display" }, { "Paste Subtree", "display" },
175 { "Delete Subtree/Node", "display" }, { "Add New Node", "display" }, { "Edit Node Data", "display" },
176 { "Sort Descendants", "display" } };
177 // This option is selected in the dropdown
178 int default_clickto = Configuration.display_node_data;
182 TreeColorSet tree_color_set;
186 TreeFontSet tree_font_set;
190 private static Hashtable<String, Color> _species_colors;
194 private static Hashtable<String, Color> _domain_colors;
198 private static Hashtable<String, Color> _annotation_colors;
199 boolean verbose = Constants.VERBOSE_DEFAULT;
200 private NODE_LABEL_DIRECTION _node_label_direction = NODE_LABEL_DIRECTION.HORIZONTAL;
201 private Color _gui_background_color = Constants.GUI_BACKGROUND_DEFAULT;
202 private Color _gui_checkbox_text_color = Constants.CHECKBOX_TEXT_COLOR_DEFAULT;
203 private Color _gui_checkbox_and_button_active_color = Constants.CHECKBOX_AND_BUTTON_ACTIVE_COLOR_DEFAULT;
204 private Color _gui_button_text_color = Constants.BUTTON_TEXT_COLOR_DEFAULT;
205 private Color _gui_button_background_color = Constants.BUTTON_BACKGROUND_COLOR_DEFAULT;
206 private Color _gui_menu_background_color = Constants.MENU_BACKGROUND_COLOR_DEFAULT;
207 private Color _gui_menu_text_color = Constants.MENU_TEXT_COLOR_DEFAULT;
208 private Color _gui_button_border_color = Constants.BUTTON_BORDER_COLOR_DEFAULT;
209 private Color _domain_structure_font_color = Constants.DOMAIN_STRUCTURE_FONT_COLOR_DEFAULT;
210 private Color _domain_structure_base_color = Constants.DOMAIN_STRUCTURE_BASE_COLOR_DEFAULT;
211 private static String DEFAULT_FONT_FAMILY = "";
213 for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
214 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
215 DEFAULT_FONT_FAMILY = font_name;
219 if ( ForesterUtil.isEmpty( DEFAULT_FONT_FAMILY ) ) {
220 DEFAULT_FONT_FAMILY = Constants.DEFAULT_FONT_CHOICES[ Constants.DEFAULT_FONT_CHOICES.length - 1 ];
224 public Configuration() {
225 this( null, false, false, false );
228 public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
229 if ( ForesterUtil.isEmpty( cf ) ) {
230 config_filename = default_config_filename;
233 config_filename = cf;
235 setWebLinks( new TreeMap<String, WebLink>() );
236 setDisplayColors( new TreeMap<String, Color>() );
237 config_filename = config_filename.trim();
240 // If URL, open accordingly
242 u = new URL( config_filename );
244 final InputStreamReader isr = new InputStreamReader( u.openStream() );
245 final BufferedReader bf = new BufferedReader( isr );
248 ForesterUtil.programMessage( Constants.PRG_NAME, "successfully read from configuration url ["
249 + config_filename + "]" );
251 catch ( final Exception e ) {
252 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
253 + config_filename + "]: " + e.getLocalizedMessage() );
256 catch ( final Exception e ) {
257 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration url ["
258 + config_filename + "]" );
262 // Otherwise, open as a file
263 File f = new File( config_filename );
265 f = new File( config_filename + ".txt" );
267 if ( f.exists() && f.canRead() ) {
269 final BufferedReader bf = new BufferedReader( new FileReader( f ) );
273 catch ( final Exception e ) {
275 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
276 + config_filename + "]: " + e );
282 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
283 + config_filename + "]" );
289 private void createWebLink( final String url_str, final String desc, final String source_identifier ) {
290 WebLink weblink = null;
293 weblink = new WebLink( new URL( url_str.trim() ), desc.trim(), source_identifier.trim() );
295 catch ( final MalformedURLException e ) {
296 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not create URL from [" + url_str + "]" );
299 if ( !ex && ( weblink != null ) ) {
300 getWebLinks().put( weblink.getSourceIdentifier().toLowerCase(), weblink );
304 boolean displaySequenceRelations() {
305 return _display_sequence_relations;
308 boolean doCheckOption( final int which ) {
309 return ( display_options[ which ][ 2 ].equalsIgnoreCase( "yes" ) )
310 || ( display_options[ which ][ 2 ].equalsIgnoreCase( "true" ) );
313 boolean doDisplayClickToOption( final int which ) {
314 return clickto_options[ which ][ 1 ].equalsIgnoreCase( "display" );
317 boolean doDisplayOption( final int which ) {
318 return display_options[ which ][ 1 ].equalsIgnoreCase( "display" );
322 * Will attempt to use the phylogeny to determine whether to check
323 * this or not (e.g. phylogram)
326 boolean doGuessCheckOption( final int which ) {
327 return display_options[ which ][ 2 ].equals( "?" );
330 Map<String, Color> getAnnotationColors() {
331 if ( _annotation_colors == null ) {
332 _annotation_colors = new Hashtable<String, Color>();
334 return _annotation_colors;
337 public String getBaseFontFamilyName() {
338 return _base_font_family_name;
341 int getBaseFontSize() {
342 return _base_font_size;
345 CLADOGRAM_TYPE getCladogramType() {
346 return _cladogram_type;
349 private int getClickToIndex( final String name ) {
351 if ( name.equals( "edit_info" ) ) {
352 index = Configuration.display_node_data;
354 .printWarningMessage( Constants.PRG_NAME,
355 "configuration key [edit_info] is deprecated, use [display node data] instead" );
357 else if ( name.equals( "display_node_data" ) ) {
358 index = Configuration.display_node_data;
360 else if ( name.equals( "collapse_uncollapse" ) ) {
361 index = Configuration.collapse_uncollapse;
363 else if ( name.equals( "reroot" ) ) {
364 index = Configuration.reroot;
366 else if ( name.equals( "subtree" ) ) {
367 index = Configuration.subtree;
369 else if ( name.equals( "swap" ) ) {
370 index = Configuration.swap;
372 else if ( name.equals( "sort_descendants" ) ) {
373 index = Configuration.sort_descendents;
375 else if ( name.equals( "display_sequences" ) ) {
377 .printWarningMessage( Constants.PRG_NAME, "configuration key [display_sequences] is deprecated" );
380 else if ( name.equals( "open_seq_web" ) ) {
381 index = Configuration.open_seq_web;
383 else if ( name.equals( "open_tax_web" ) ) {
384 index = Configuration.open_tax_web;
386 else if ( name.equals( "blast" ) ) {
387 index = Configuration.blast;
389 else if ( name.equals( "cut_subtree" ) ) {
390 index = Configuration.cut_subtree;
392 else if ( name.equals( "copy_subtree" ) ) {
393 index = Configuration.copy_subtree;
395 else if ( name.equals( "paste_subtree" ) ) {
396 index = Configuration.paste_subtree;
398 else if ( name.equals( "delete" ) ) {
399 index = Configuration.delete_subtree_or_node;
401 else if ( name.equals( "add_new_node" ) ) {
402 index = Configuration.add_new_node;
404 else if ( name.equals( "edit_node_data" ) ) {
405 index = Configuration.edit_node_data;
407 else if ( name.equals( "display_node_popup" ) ) {
408 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
409 "configuration key [display_node_popup] is deprecated" );
412 else if ( name.equals( "custom_option" ) ) {
413 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [custom_option] is deprecated" );
416 else if ( name.equals( "color_subtree" ) ) {
417 index = Configuration.color_subtree;
419 else if ( name.equals( "go_to_swiss_prot" ) ) {
420 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [go_to_swiss_prot] is deprecated" );
426 int getClickToOptionsCount() {
427 return clickto_options.length;
430 String getClickToTitle( final int which ) {
431 return clickto_options[ which ][ 0 ];
434 public int getDefaultBootstrapSamples() {
435 return _default_bootstrap_samples;
438 int getDefaultDisplayClicktoOption() {
439 return default_clickto;
442 public NodeFill getDefaultNodeFill() {
443 return _default_node_fill;
446 public NodeShape getDefaultNodeShape() {
447 return _default_node_shape;
450 public short getDefaultNodeShapeSize() {
451 return _default_node_shape_size;
454 SortedMap<String, Color> getDisplayColors() {
455 return _display_colors;
458 String getDisplayTitle( final int which ) {
459 return display_options[ which ][ 0 ];
462 Map<String, Color> getDomainColors() {
463 if ( _domain_colors == null ) {
464 _domain_colors = new Hashtable<String, Color>();
466 return _domain_colors;
469 public Color getDomainStructureBaseColor() {
470 return _domain_structure_base_color;
473 public Color getDomainStructureFontColor() {
474 return _domain_structure_font_color;
477 int getGraphicsExportX() {
478 return _graphics_export_x;
481 int getGraphicsExportY() {
482 return _graphics_export_y;
485 Color getGuiBackgroundColor() {
486 return _gui_background_color;
489 Color getGuiButtonBackgroundColor() {
490 return _gui_button_background_color;
493 Color getGuiButtonBorderColor() {
494 return _gui_button_border_color;
497 Color getGuiButtonTextColor() {
498 return _gui_button_text_color;
501 Color getGuiCheckboxAndButtonActiveColor() {
502 return _gui_checkbox_and_button_active_color;
505 Color getGuiCheckboxTextColor() {
506 return _gui_checkbox_text_color;
509 Color getGuiMenuBackgroundColor() {
510 return _gui_menu_background_color;
513 Color getGuiMenuTextColor() {
514 return _gui_menu_text_color;
517 double getMinConfidenceValue() {
518 return _min_confidence_value;
521 NODE_LABEL_DIRECTION getNodeLabelDirection() {
522 return _node_label_direction;
525 short getNumberOfDigitsAfterCommaForBranchLengthValues() {
526 return _number_of_digits_after_comma_for_branch_length_values;
529 short getNumberOfDigitsAfterCommaForConfidenceValues() {
530 return _number_of_digits_after_comma_for_confidence_values;
533 short getOvMaxHeight() {
534 return _ov_max_height;
537 short getOvMaxWidth() {
538 return _ov_max_width;
541 OVERVIEW_PLACEMENT_TYPE getOvPlacement() {
542 return _ov_placement;
545 PHYLOGENY_GRAPHICS_TYPE getPhylogenyGraphicsType() {
546 return _phylogeny_graphics_type;
549 float getPrintLineWidth() {
550 return _print_line_width;
553 Hashtable<String, Color> getSpeciesColors() {
554 if ( _species_colors == null ) {
555 _species_colors = new Hashtable<String, Color>();
557 return _species_colors;
560 TreeColorSet getTreeColorSet() {
564 TreeFontSet getTreeFontSet() {
568 WebLink getWebLink( final String source ) {
569 return getWebLinks().get( source );
572 Map<String, WebLink> getWebLinks() {
576 public boolean isAbbreviateScientificTaxonNames() {
577 return _abbreviate_scientific_names;
580 boolean isAntialiasScreen() {
581 return _antialias_screen;
584 public boolean isBackgroundColorGradient() {
585 return _background_color_gradient;
588 public boolean isColorLabelsSameAsParentBranch() {
589 return _color_labels_same_as_parent_branch;
593 * Convenience method.
595 * @return true if value in configuration file was 'yes'
597 boolean isDrawAsPhylogram() {
598 return doCheckOption( display_as_phylogram );
601 boolean isEditable() {
605 boolean isExtractPfamTaxonomyCodesInNhParsing() {
606 return _nh_parsing_extract_pfam_taxonomy_codes;
609 boolean isHasWebLink( final String source ) {
610 return getWebLinks().containsKey( source );
614 * Only used by ArchaeoptryxE.
617 boolean isHideControlPanelAndMenubar() {
618 return _hide_controls_and_menus;
621 boolean isInternalNumberAreConfidenceForNhParsing() {
622 return _internal_number_are_confidence_for_nh_parsing;
625 boolean isReplaceUnderscoresInNhParsing() {
626 return _nh_parsing_replace_underscores;
629 boolean isShowBranchLengthValues() {
630 return _show_branch_length_values;
633 public boolean isShowDefaultNodeShapes() {
634 return _show_default_node_shapes;
637 public boolean isShowDomainLabels() {
638 return _show_domain_labels;
641 boolean isShowOverview() {
642 return _show_overview;
645 boolean isShowScale() {
649 public boolean isTaxonomyColorizeNodeShapes() {
650 return _taxonomy_colorize_node_shapes;
653 final boolean isUseNativeUI() {
654 if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() && AptxUtil.isJava15() ) {
657 return _ui == UI.NATIVE;
661 * Only used by ArchaeoptryxE.
664 boolean isUseTabbedDisplay() {
665 return _use_tabbed_display;
668 boolean isValidatePhyloXmlAgainstSchema() {
669 return _validate_against_phyloxml_xsd_schema;
672 private boolean parseBoolean( final String str ) {
673 final String my_str = str.trim().toLowerCase();
674 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
677 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
681 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse boolean value from [" + str + "]" );
686 private double parseDouble( final String str ) {
689 d = Double.parseDouble( str );
691 catch ( final Exception e ) {
692 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse double from [" + str + "]" );
698 private float parseFloat( final String str ) {
701 f = Float.parseFloat( str );
703 catch ( final Exception e ) {
704 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse float from [" + str + "]" );
710 private int parseInt( final String str ) {
713 i = Integer.parseInt( str );
715 catch ( final Exception e ) {
716 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse integer from [" + str + "]" );
722 private short parseShort( final String str ) {
725 i = Short.parseShort( str );
727 catch ( final Exception e ) {
728 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse short from [" + str + "]" );
734 private void processFontFamily( final StringTokenizer st ) {
735 setBaseFontFamilyName( "" );
736 final String font_str = ( ( String ) st.nextElement() ).trim();
737 final String[] fonts = font_str.split( ",+" );
738 for( String font : fonts ) {
739 font = font.replace( '_', ' ' ).trim();
740 if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
741 setBaseFontFamilyName( font );
747 public void putDisplayColors( final String key, final Color color ) {
748 getDisplayColors().put( key, color );
752 * read each line of config file, process non-comment lines
753 * @throws IOException
755 private void readConfig( final BufferedReader conf_in ) throws IOException {
758 line = conf_in.readLine();
759 if ( line != null ) {
761 // skip comments and blank lines
762 if ( !line.startsWith( "#" ) && ( !ForesterUtil.isEmpty( line ) ) ) {
763 // convert runs of spaces to tabs
764 line = line.replaceAll( "\\s+", "\t" );
765 final StringTokenizer st = new StringTokenizer( line, "\t" );
769 } while ( line != null );
772 public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
773 _abbreviate_scientific_names = abbreviate_scientific_names;
776 private void setAntialiasScreen( final boolean antialias_screen ) {
777 _antialias_screen = antialias_screen;
780 public void setBackgroundColorGradient( final boolean background_color_gradient ) {
781 _background_color_gradient = background_color_gradient;
784 public void setBaseFontFamilyName( final String base_font_family_name ) {
785 _base_font_family_name = base_font_family_name;
788 public void setBaseFontSize( final int base_font_size ) {
789 _base_font_size = base_font_size;
792 private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
793 _cladogram_type = cladogram_type;
796 public void setColorizeBranches( final boolean b ) {
797 display_options[ color_branches ][ 2 ] = b ? "yes" : "no";
800 public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
801 _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
804 private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
805 _default_bootstrap_samples = default_bootstrap_samples;
808 public void setDefaultNodeFill( final NodeFill default_node_fill ) {
809 _default_node_fill = default_node_fill;
812 public void setDefaultNodeShape( final NodeShape default_node_shape ) {
813 _default_node_shape = default_node_shape;
816 public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
817 _default_node_shape_size = default_node_shape_size;
820 public void setDisplayAsPhylogram( final boolean b ) {
821 display_options[ display_as_phylogram ][ 2 ] = b ? "yes" : "no";
824 public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
825 _display_colors = display_colors;
828 public void setDisplayConfidenceValues( final boolean b ) {
829 display_options[ write_confidence_values ][ 2 ] = b ? "yes" : "no";
832 public void setDisplayInternalData( final boolean b ) {
833 display_options[ display_internal_data ][ 2 ] = b ? "yes" : "no";
836 public void setDisplayNodeNames( final boolean b ) {
837 display_options[ show_node_names ][ 2 ] = b ? "yes" : "no";
840 public void setDisplaySequenceAcc( final boolean b ) {
841 display_options[ show_sequence_acc ][ 2 ] = b ? "yes" : "no";
844 public void setDisplaySequenceNames( final boolean b ) {
845 display_options[ show_gene_names ][ 2 ] = b ? "yes" : "no";
848 public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
849 _display_sequence_relations = display_sequence_relations;
852 public void setDisplaySequenceSymbols( final boolean b ) {
853 display_options[ show_gene_symbols ][ 2 ] = b ? "yes" : "no";
856 public void setDisplayTaxonomyCode( final boolean b ) {
857 display_options[ show_tax_code ][ 2 ] = b ? "yes" : "no";
860 public void setDisplayTaxonomyCommonNames( final boolean b ) {
861 display_options[ show_taxonomy_common_names ][ 2 ] = b ? "yes" : "no";
864 public void setDisplayTaxonomyImages( final boolean b ) {
865 display_options[ show_taxonomy_images ][ 2 ] = b ? "yes" : "no";
868 public void setDisplayTaxonomyScientificNames( final boolean b ) {
869 display_options[ show_taxonomy_scientific_names ][ 2 ] = b ? "yes" : "no";
872 public void setDynamicallyHideData( final boolean b ) {
873 display_options[ dynamically_hide_data ][ 2 ] = b ? "yes" : "no";
876 private void setEditable( final boolean editable ) {
877 _editable = editable;
880 public void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
881 _nh_parsing_extract_pfam_taxonomy_codes = nh_parsing_extract_pfam_taxonomy_codes;
884 private void setGraphicsExportX( final int graphics_export_x ) {
885 _graphics_export_x = graphics_export_x;
888 private void setGraphicsExportY( final int graphics_export_y ) {
889 _graphics_export_y = graphics_export_y;
892 private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
893 _internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
897 * Set a key-value(s) tuple
899 private void setKeyValue( final StringTokenizer st ) {
900 String key = ( String ) st.nextElement();
901 key = key.replace( ':', ' ' );
903 key = key.toLowerCase();
904 // Handle single value settings first:
905 if ( key.equals( "default_click_to" ) ) {
906 final String clickto_name = ( String ) st.nextElement();
907 default_clickto = getClickToIndex( clickto_name );
908 if ( default_clickto == -1 ) {
909 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "invalid value [" + clickto_name
910 + "] for [default_click_to]" );
913 else if ( default_clickto == DEPRECATED ) {
917 else if ( key.equals( "native_ui" ) ) {
918 final String my_str = ( ( String ) st.nextElement() ).trim().toLowerCase();
919 if ( my_str.equals( "yes" ) || my_str.equals( "true" ) ) {
922 else if ( my_str.equals( "no" ) || my_str.equals( "false" ) ) {
923 _ui = UI.CROSSPLATFORM;
925 else if ( my_str.equals( "?" ) ) {
929 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not parse yes/no/? value from [" + my_str
934 else if ( key.equals( "path_to_mafft" ) ) {
935 setPathToMafft( new File( (String) st.nextElement() ) );
937 else if ( key.equals( "path_to_clustalo" ) ) {
938 setPathToClustalOmega( new File( (String) st.nextElement() ) );
940 else if ( key.equals( "path_to_fastme" ) ) {
941 setPathToFastME( new File( (String) st.nextElement() ) );
943 else if ( key.equals( "path_to_mafft" ) ) {
944 setPathToMafft( new File( (String) st.nextElement() ) );
946 else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
947 setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
949 else if ( key.equals( "antialias_screen" ) ) {
950 setAntialiasScreen( parseBoolean( ( String ) st.nextElement() ) );
952 else if ( key.equals( "phylogeny_graphics_type" ) ) {
953 final String type_str = ( ( String ) st.nextElement() ).trim();
954 if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CONVEX.toString() ) ) {
955 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CONVEX );
957 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CURVED.toString() ) ) {
958 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CURVED );
960 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE.toString() ) ) {
961 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.EURO_STYLE );
963 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.ROUNDED.toString() ) ) {
964 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.ROUNDED );
966 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR.toString() ) ) {
967 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
969 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR.toString() ) ) {
970 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.TRIANGULAR );
972 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.UNROOTED.toString() ) ) {
973 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.UNROOTED );
975 else if ( type_str.equalsIgnoreCase( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR.toString() ) ) {
976 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.CIRCULAR );
979 setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
980 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
981 + "] for [phylogeny_graphics_type]" );
984 else if ( key.equals( "min_confidence_value" ) ) {
985 final String mcv_str = ( ( String ) st.nextElement() ).trim();
986 final double d = parseDouble( mcv_str );
987 setMinConfidenceValue( d );
989 else if ( key.equals( "font_family" ) ) {
990 processFontFamily( st );
992 else if ( key.equals( "font_size" ) ) {
993 final String size_str = ( ( String ) st.nextElement() ).trim();
994 final int i = parseInt( size_str );
995 setBaseFontSize( i );
997 else if ( key.equals( "graphics_export_x" ) ) {
998 final String str = ( ( String ) st.nextElement() ).trim();
999 final int i = parseInt( str );
1000 setGraphicsExportX( i );
1002 else if ( key.equals( "graphics_export_y" ) ) {
1003 final String str = ( ( String ) st.nextElement() ).trim();
1004 final int i = parseInt( str );
1005 setGraphicsExportY( i );
1007 else if ( key.equals( "pdf_export_line_width" ) ) {
1008 final String str = ( ( String ) st.nextElement() ).trim();
1009 final float f = parseFloat( str );
1011 setPrintLineWidth( f );
1014 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1015 "value for [pdf_export_line_width] cannot be zero or negative" );
1018 else if ( key.equals( "default_number_of_bootstrap_resamples" ) ) {
1019 final String str = ( ( String ) st.nextElement() ).trim();
1020 final int i = parseInt( str );
1022 setDefaultBootstrapSamples( i );
1026 .printWarningMessage( Constants.PRG_NAME,
1027 "value for [default_number_of_bootstrap_resamples] cannot be negative" );
1030 else if ( key.equals( "show_scale" ) ) {
1031 setShowScale( parseBoolean( ( String ) st.nextElement() ) );
1033 else if ( key.equals( "show_overview" ) ) {
1034 setShowOverview( parseBoolean( ( String ) st.nextElement() ) );
1036 else if ( key.equals( "show_branch_length_values" ) ) {
1037 setShowBranchLengthValues( parseBoolean( ( String ) st.nextElement() ) );
1039 else if ( key.equals( "background_gradient" ) ) {
1040 setBackgroundColorGradient( parseBoolean( ( String ) st.nextElement() ) );
1042 else if ( key.equals( "color_labels_same_as_branch_length_values" ) ) {
1043 setColorLabelsSameAsParentBranch( parseBoolean( ( String ) st.nextElement() ) );
1045 else if ( key.equals( "show_domain_labels" ) ) {
1046 setShowDomainLabels( parseBoolean( ( String ) st.nextElement() ) );
1048 else if ( key.equals( "abbreviate_scientific_names" ) ) {
1049 setAbbreviateScientificTaxonNames( parseBoolean( ( String ) st.nextElement() ) );
1051 else if ( key.equals( "cladogram_type" ) ) {
1052 final String type_str = ( ( String ) st.nextElement() ).trim();
1053 if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.NON_LINED_UP.toString() ) ) {
1054 setCladogramType( Options.CLADOGRAM_TYPE.NON_LINED_UP );
1056 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP.toString() ) ) {
1057 setCladogramType( Options.CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
1059 else if ( type_str.equalsIgnoreCase( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP.toString() ) ) {
1060 setCladogramType( Options.CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
1063 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1064 + "] for [cladogram_type]" );
1067 else if ( key.equals( "non_lined_up_cladogram" ) ) {
1069 .printWarningMessage( Constants.PRG_NAME,
1070 "configuration key [non_lined_up_cladogram] is deprecated, use [cladogram_type] instead" );
1072 else if ( key.equals( "hide_controls_and_menus" ) ) {
1073 _hide_controls_and_menus = parseBoolean( ( String ) st.nextElement() );
1075 else if ( key.equals( "use_tabbed_display" ) ) {
1076 _use_tabbed_display = parseBoolean( ( String ) st.nextElement() );
1078 else if ( key.equals( "overview_width" ) ) {
1079 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1082 else if ( key.equals( "overview_height" ) ) {
1083 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1084 setOvMaxHeight( i );
1086 else if ( key.equals( "overview_placement_type" ) ) {
1087 final String type_str = ( ( String ) st.nextElement() ).trim();
1088 if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT.toTag() ) ) {
1089 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1091 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT.toTag() ) ) {
1092 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_RIGHT );
1094 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT.toTag() ) ) {
1095 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_LEFT );
1097 else if ( type_str.equalsIgnoreCase( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT.toTag() ) ) {
1098 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.LOWER_RIGHT );
1101 setOvPlacement( OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT );
1102 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1103 + "] for [overview_placement_type]" );
1106 else if ( key.equals( "node_label_direction" ) ) {
1107 final String type_str = ( ( String ) st.nextElement() ).trim();
1108 if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.HORIZONTAL.toString() ) ) {
1109 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1111 else if ( type_str.equalsIgnoreCase( NODE_LABEL_DIRECTION.RADIAL.toString() ) ) {
1112 setNodeLabelDirection( NODE_LABEL_DIRECTION.RADIAL );
1115 setNodeLabelDirection( NODE_LABEL_DIRECTION.HORIZONTAL );
1116 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + type_str
1117 + "] for [node_label_direction]" );
1120 else if ( key.equals( "branch_length_value_digits" ) ) {
1121 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1123 setNumberOfDigitsAfterCommaForBranchLengthValue( i );
1126 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1127 + "] for [branch_length_value_digits]" );
1130 else if ( key.equals( "confidence_value_digits" ) ) {
1131 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1133 setNumberOfDigitsAfterCommaForConfidenceValues( i );
1136 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "illegal value [" + i
1137 + "] for [confidence_value_digits]" );
1140 else if ( key.equals( "allow_editing" ) ) {
1141 setEditable( parseBoolean( ( String ) st.nextElement() ) );
1143 else if ( key.equals( "display_sequence_relations" ) ) {
1144 setDisplaySequenceRelations( parseBoolean( ( String ) st.nextElement() ) );
1146 else if ( key.equals( "replace_underscores_in_nh_parsing" ) ) {
1147 final boolean r = parseBoolean( ( String ) st.nextElement() );
1148 if ( r && isExtractPfamTaxonomyCodesInNhParsing() ) {
1150 .printWarningMessage( Constants.PRG_NAME,
1151 "attempt to extract taxonomies and replace underscores at the same time" );
1154 setReplaceUnderscoresInNhParsing( r );
1157 else if ( key.equals( "extract_taxonomy_codes_in_nh_parsing" ) ) {
1158 final boolean e = parseBoolean( ( String ) st.nextElement() );
1159 if ( e && isReplaceUnderscoresInNhParsing() ) {
1161 .printWarningMessage( Constants.PRG_NAME,
1162 "attempt to extract taxonomies and replace underscores at the same time" );
1165 setExtractPfamTaxonomyCodesInNhParsing( e );
1168 else if ( key.equals( "internal_labels_are_confidence_values" ) ) {
1169 setInternalNumberAreConfidenceForNhParsing( parseBoolean( ( String ) st.nextElement() ) );
1171 else if ( key.equals( "gui_background_color" ) ) {
1172 _gui_background_color = Color.decode( ( String ) st.nextElement() );
1174 else if ( key.equals( "gui_checkbox_text_color" ) ) {
1175 _gui_checkbox_text_color = Color.decode( ( String ) st.nextElement() );
1177 else if ( key.equals( "gui_checkbox_and_button_active_color" ) ) {
1178 _gui_checkbox_and_button_active_color = Color.decode( ( String ) st.nextElement() );
1180 else if ( key.equals( "gui_button_text_color" ) ) {
1181 _gui_button_text_color = Color.decode( ( String ) st.nextElement() );
1183 else if ( key.equals( "gui_button_background_color" ) ) {
1184 _gui_button_background_color = Color.decode( ( String ) st.nextElement() );
1186 else if ( key.equals( "gui_menu_background_color" ) ) {
1187 _gui_menu_background_color = Color.decode( ( String ) st.nextElement() );
1189 else if ( key.equals( "gui_menu_text_color" ) ) {
1190 _gui_menu_text_color = Color.decode( ( String ) st.nextElement() );
1192 else if ( key.equals( "gui_button_border_color" ) ) {
1193 _gui_button_border_color = Color.decode( ( String ) st.nextElement() );
1195 else if ( key.equals( "domain_structure_font_color" ) ) {
1196 _domain_structure_font_color = Color.decode( ( String ) st.nextElement() );
1198 else if ( key.equals( "domain_structure_base_color" ) ) {
1199 _domain_structure_base_color = Color.decode( ( String ) st.nextElement() );
1201 else if ( key.equals( "show_default_node_shapes" ) ) {
1202 setShowDefaultNodeShapes( parseBoolean( ( ( String ) st.nextElement() ).trim() ) );
1204 else if ( key.equals( "default_node_size" ) ) {
1205 final short i = parseShort( ( ( String ) st.nextElement() ).trim() );
1206 setDefaultNodeShapeSize( i );
1208 else if ( key.equals( "default_node_fill" ) ) {
1209 final String fill_str = ( ( String ) st.nextElement() ).trim();
1210 if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.NONE.toString() ) ) {
1211 setDefaultNodeFill( NodeFill.NONE );
1213 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.GRADIENT.toString() ) ) {
1214 setDefaultNodeFill( NodeFill.GRADIENT );
1216 else if ( fill_str.equalsIgnoreCase( NodeVisualization.NodeFill.SOLID.toString() ) ) {
1217 setDefaultNodeFill( NodeFill.SOLID );
1220 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + fill_str
1221 + "] for [default_node_fill]" );
1224 else if ( key.equals( "default_node_shape" ) ) {
1225 final String shape_str = ( ( String ) st.nextElement() ).trim();
1226 if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.CIRCLE.toString() ) ) {
1227 setDefaultNodeShape( NodeShape.CIRCLE );
1229 else if ( shape_str.equalsIgnoreCase( NodeVisualization.NodeShape.RECTANGLE.toString() ) ) {
1230 setDefaultNodeShape( NodeShape.RECTANGLE );
1233 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + shape_str
1234 + "] for [default_node_shape]" );
1237 else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
1238 setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
1240 else if ( st.countTokens() >= 2 ) { // counts the tokens that are not
1243 if ( key.equals( "use_real_br_lengths" ) || key.equals( "phylogram" ) ) {
1244 key_index = Configuration.display_as_phylogram;
1245 if ( key.equals( "use_real_br_lengths" ) ) {
1247 .printWarningMessage( Constants.PRG_NAME,
1248 "configuration key [use_real_br_lengths] is deprecated, use [phylogram] instead" );
1251 else if ( key.equals( "rollover" ) ) {
1252 key_index = Configuration.node_data_popup;
1254 else if ( key.equals( "color_according_to_species" ) ) {
1255 key_index = Configuration.color_according_to_species;
1257 else if ( key.equals( "show_node_names" ) ) {
1258 key_index = Configuration.show_node_names;
1260 else if ( key.equals( "show_taxonomy" ) || key.equals( "show_taxonomy_code" ) ) {
1261 key_index = Configuration.show_tax_code;
1262 if ( key.equals( "show_taxonomy" ) ) {
1264 .printWarningMessage( Constants.PRG_NAME,
1265 "configuration key [show_taxonomy] is deprecated, use [show_taxonomy_code] instead" );
1268 else if ( key.equals( "write_br_length_values" ) ) {
1269 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1270 "configuration key [write_br_length_values] is deprecated" );
1271 key_index = DEPRECATED;
1273 else if ( key.equals( "write_bootstrap_values" ) || key.equals( "write_confidence_values" ) ) {
1274 key_index = Configuration.write_confidence_values;
1275 if ( key.equals( "write_bootstrap_values" ) ) {
1277 .printWarningMessage( Constants.PRG_NAME,
1278 "configuration key [write_bootstrap_values] is deprecated, use [write_confidence_values] instead" );
1281 else if ( key.equals( "write_events" ) || key.equals( "write_dup_spec" ) ) {
1282 key_index = Configuration.write_events;
1283 if ( key.equals( "write_dup_spec" ) ) {
1285 .printWarningMessage( Constants.PRG_NAME,
1286 "configuration key [write_dup_spec] is deprecated, use [write_events] instead" );
1289 else if ( key.equals( "color_branches" ) ) {
1290 key_index = Configuration.color_branches;
1292 else if ( key.equals( "width_branches" ) ) {
1293 key_index = Configuration.width_branches;
1295 else if ( key.equals( "color_orthologous" ) ) {
1296 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1297 "configuration key [color_orthologous] is deprecated" );
1299 else if ( key.equals( "color_subtree_neighbors" ) ) {
1300 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1301 "configuration key [color_subtree_neighbors] is deprecated" );
1303 else if ( key.equals( "color_super_orthologous" ) ) {
1304 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1305 "configuration key [color_super_orthologous] is deprecated" );
1307 else if ( key.equals( "mark_nodes_with_box" ) ) {
1308 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1309 "configuration key [mark_nodes_with_box] is deprecated" );
1310 key_index = DEPRECATED;
1312 else if ( key.equals( "show_domain_architectures" ) ) {
1313 key_index = Configuration.show_domain_architectures;
1315 else if ( key.equals( "show_annotations" ) ) {
1316 key_index = Configuration.show_annotation;
1318 else if ( key.equals( "show_binary_characters" ) ) {
1319 key_index = Configuration.show_binary_characters;
1321 else if ( key.equals( "show_binary_character_counts" ) ) {
1322 key_index = Configuration.show_binary_character_counts;
1324 else if ( key.equals( "show_gene_names" ) ) {
1325 key_index = Configuration.show_gene_names;
1327 else if ( key.equals( "show_gene_symbols" ) ) {
1328 key_index = Configuration.show_gene_symbols;
1330 else if ( key.equals( "show_sequence_acc" ) ) {
1331 key_index = Configuration.show_sequence_acc;
1333 else if ( key.equals( "show_node_ids" ) ) {
1335 .printWarningMessage( Constants.PRG_NAME, "configuration key [show_node_ids] is deprecated" );
1336 key_index = DEPRECATED;
1338 else if ( key.equals( "display_internal_data" ) ) {
1339 key_index = Configuration.display_internal_data;
1341 else if ( key.equals( "dynamically_hide_data" ) ) {
1342 key_index = Configuration.dynamically_hide_data;
1344 else if ( key.equals( "show_taxonomy_names" ) ) {
1345 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1346 "configuration key [show_taxonomy_names] is deprecated" );
1347 key_index = DEPRECATED;
1349 else if ( key.equals( "show_taxonomy_scientific_names" ) ) {
1350 key_index = Configuration.show_taxonomy_scientific_names;
1352 else if ( key.equals( "show_taxonomy_common_names" ) ) {
1353 key_index = Configuration.show_taxonomy_common_names;
1355 else if ( key.equals( "show_taxonomy_images" ) ) {
1356 key_index = Configuration.show_taxonomy_images;
1358 else if ( key.equals( "color_according_to_annotation" ) ) {
1359 key_index = Configuration.color_according_to_annotation;
1361 else if ( key.equals( "show_vector_data" ) ) {
1362 key_index = Configuration.show_vector_data;
1364 else if ( key.equals( "show_properties" ) ) {
1365 key_index = Configuration.show_properties;
1367 else if ( key.equals( "show_relation_confidence" ) ) {
1368 key_index = Configuration.show_relation_confidence;
1370 else if ( key.equals( "show_custom_node_shapes" ) ) {
1371 key_index = Configuration.show_custom_node_shapes;
1373 // If we've found the key, set the values
1374 if ( key_index >= 0 ) {
1375 display_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1376 display_options[ key_index ][ 2 ] = ( String ) st.nextElement();
1377 // otherwise, keep looking
1380 if ( key_index == DEPRECATED ) {
1383 else if ( key.equals( "click_to" ) ) {
1384 final String click_to_name = ( String ) st.nextElement();
1385 key_index = getClickToIndex( click_to_name );
1386 if ( key_index >= 0 ) {
1387 clickto_options[ key_index ][ 1 ] = ( String ) st.nextElement();
1389 else if ( key_index == DEPRECATED ) {
1393 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown click-to option: "
1397 else if ( key.equals( "species_color" ) ) {
1398 getSpeciesColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1400 else if ( key.equals( "domain_color" ) ) {
1401 getDomainColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1403 else if ( key.equals( "annotation_color" ) ) {
1404 getAnnotationColors()
1405 .put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1407 else if ( key.equals( "function_color" ) ) {
1408 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1409 "configuration key [function_color] is deprecated" );
1411 else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
1412 putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
1414 else if ( key.equals( WEB_LINK_KEY ) ) {
1415 if ( st.countTokens() == 3 ) {
1416 createWebLink( ( String ) st.nextElement(),
1417 ( String ) st.nextElement(),
1418 ( String ) st.nextElement() );
1421 ForesterUtil.printWarningMessage( Constants.PRG_NAME,
1422 "illegal format in configuration file for key [" + key + "]" );
1426 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key
1427 + "] in: " + config_filename );
1432 ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown configuration key [" + key + "] in: "
1433 + config_filename );
1437 public void setMinConfidenceValue( final double min_confidence_value ) {
1438 _min_confidence_value = min_confidence_value;
1441 public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
1442 _node_label_direction = node_label_direction;
1445 public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short _number_of_digits_after_comma_for_branch_length_values ) {
1446 this._number_of_digits_after_comma_for_branch_length_values = _number_of_digits_after_comma_for_branch_length_values;
1449 public void setNumberOfDigitsAfterCommaForConfidenceValues( final short _number_of_digits_after_comma_for_confidence_values ) {
1450 this._number_of_digits_after_comma_for_confidence_values = _number_of_digits_after_comma_for_confidence_values;
1453 private void setOvMaxHeight( final short ov_max_height ) {
1454 _ov_max_height = ov_max_height;
1457 private void setOvMaxWidth( final short ov_max_width ) {
1458 _ov_max_width = ov_max_width;
1461 private void setOvPlacement( final OVERVIEW_PLACEMENT_TYPE ov_placement ) {
1462 _ov_placement = ov_placement;
1465 public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
1466 _phylogeny_graphics_type = phylogeny_graphics_type;
1469 public void setPrintLineWidth( final float print_line_width ) {
1470 _print_line_width = print_line_width;
1473 public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
1474 _nh_parsing_replace_underscores = nh_parsing_replace_underscores;
1477 public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
1478 _show_branch_length_values = show_branch_length_values;
1481 public void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
1482 _show_default_node_shapes = show_default_node_shapes;
1485 public void setShowDomainLabels( final boolean show_domain_labels ) {
1486 _show_domain_labels = show_domain_labels;
1489 private void setShowOverview( final boolean show_overview ) {
1490 _show_overview = show_overview;
1493 public void setShowScale( final boolean show_scale ) {
1494 _show_scale = show_scale;
1497 public void setTaxonomyColorize( final boolean b ) {
1498 display_options[ color_according_to_species ][ 2 ] = b ? "yes" : "no";
1501 public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
1502 _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
1505 public void setUseBranchesWidths( final boolean b ) {
1506 display_options[ width_branches ][ 2 ] = b ? "yes" : "no";
1509 private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
1510 _validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
1513 void setWebLinks( final SortedMap<String, WebLink> weblinks ) {
1514 _weblinks = weblinks;
1517 static String getDefaultFontFamilyName() {
1518 return DEFAULT_FONT_FAMILY;
1522 public File getPathToMafft() {
1528 public File getPathToClustalOmega() {
1533 public File getPathToFastME() {
1538 public void setPathToMafft( final File mafft ) {
1544 public void setPathToClustalOmega( final File clustalo ) {
1545 _clustalo = clustalo ;
1549 public void setPathToFastME( final File fastme ) {
1553 static enum TRIPLET {
1554 TRUE, FALSE, UNKNOWN
1558 NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN