- void buildOptionsMenu() {
- _options_jmenu = MainFrame.createMenu( OPTIONS_HEADER, getConfiguration() );
- _options_jmenu.addChangeListener( new ChangeListener() {
-
- @Override
- public void stateChanged( final ChangeEvent e ) {
- MainFrame.setOvPlacementColorChooseMenuItem( _overview_placment_mi, getOptions() );
- MainFrame.setTextColorChooseMenuItem( _switch_colors_mi, getCurrentTreePanel() );
- MainFrame
- .setTextMinSupportMenuItem( _choose_minimal_confidence_mi, getOptions(), getCurrentTreePanel() );
- MainFrame.setTextForFontChooserMenuItem( _choose_font_mi, MainFrame
- .createCurrentFontDesc( getMainPanel().getTreeFontSet() ) );
- setTextForGraphicsSizeChooserMenuItem( _print_size_mi, getOptions() );
- setTextForPdfLineWidthChooserMenuItem( _choose_pdf_width_mi, getOptions() );
- MainFrame.updateOptionsMenuDependingOnPhylogenyType( getMainPanel(),
- _show_scale_cbmi,
- _show_branch_length_values_cbmi,
- _non_lined_up_cladograms_rbmi,
- _uniform_cladograms_rbmi,
- _ext_node_dependent_cladogram_rbmi,
- _label_direction_cbmi );
- MainFrame.setCycleNodeFillMenuItem( _cycle_node_fill_mi, getOptions() );
- MainFrame.setCycleNodeShapeMenuItem( _cycle_node_shape_mi, getOptions() );
- MainFrame.setTextNodeSizeMenuItem( _choose_node_size_mi, getOptions() );
- }
- } );
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( DISPLAY_SUBHEADER ), getConfiguration() ) );
- _options_jmenu
- .add( _ext_node_dependent_cladogram_rbmi = new JRadioButtonMenuItem( MainFrame.NONUNIFORM_CLADOGRAMS_LABEL ) );
- _options_jmenu.add( _uniform_cladograms_rbmi = new JRadioButtonMenuItem( MainFrame.UNIFORM_CLADOGRAMS_LABEL ) );
- _options_jmenu.add( _non_lined_up_cladograms_rbmi = new JRadioButtonMenuItem( NON_LINED_UP_CLADOGRAMS_LABEL ) );
- _radio_group_1 = new ButtonGroup();
- _radio_group_1.add( _ext_node_dependent_cladogram_rbmi );
- _radio_group_1.add( _uniform_cladograms_rbmi );
- _radio_group_1.add( _non_lined_up_cladograms_rbmi );
- ///////
- _options_jmenu.add( _show_overview_cbmi = new JCheckBoxMenuItem( SHOW_OVERVIEW_LABEL ) );
- _options_jmenu.add( _show_scale_cbmi = new JCheckBoxMenuItem( DISPLAY_SCALE_LABEL ) );
- _options_jmenu
- .add( _show_branch_length_values_cbmi = new JCheckBoxMenuItem( DISPLAY_BRANCH_LENGTH_VALUES_LABEL ) );
- _options_jmenu
- .add( _show_default_node_shapes_internal_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_INT ) );
- _options_jmenu
- .add( _show_default_node_shapes_external_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL_EXT ) );
- if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
- _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_LABEL ) );
- }
- _options_jmenu.add( _show_annotation_ref_source = new JCheckBoxMenuItem( SHOW_ANN_REF_SOURCE_LABEL ) );
- _options_jmenu.add( _show_confidence_stddev_cbmi = new JCheckBoxMenuItem( SHOW_CONF_STDDEV_LABEL ) );
- _options_jmenu.add( _color_by_taxonomic_group_cbmi = new JCheckBoxMenuItem( COLOR_BY_TAXONOMIC_GROUP ) );
- _options_jmenu.add( _color_labels_same_as_parent_branch = new JCheckBoxMenuItem( COLOR_LABELS_LABEL ) );
- _color_labels_same_as_parent_branch.setToolTipText( MainFrame.COLOR_LABELS_TIP );
- _options_jmenu.add( _abbreviate_scientific_names = new JCheckBoxMenuItem( ABBREV_SN_LABEL ) );
- _options_jmenu.add( _label_direction_cbmi = new JCheckBoxMenuItem( LABEL_DIRECTION_LABEL ) );
- _label_direction_cbmi.setToolTipText( LABEL_DIRECTION_TIP );
- _options_jmenu.add( _screen_antialias_cbmi = new JCheckBoxMenuItem( SCREEN_ANTIALIAS_LABEL ) );
- _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( BG_GRAD_LABEL ) );
- _options_jmenu.add( _cycle_node_shape_mi = new JMenuItem( MainFrame.CYCLE_NODE_SHAPE_LABEL ) );
- _options_jmenu.add( _cycle_node_fill_mi = new JMenuItem( MainFrame.CYCLE_NODE_FILL_LABEL ) );
- _options_jmenu.add( _choose_node_size_mi = new JMenuItem( MainFrame.CHOOSE_NODE_SIZE_LABEL ) );
- _options_jmenu.add( _choose_minimal_confidence_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _overview_placment_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _switch_colors_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _choose_font_mi = new JMenuItem( "" ) );
- ///////
- _options_jmenu.addSeparator();
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( SEARCH_SUBHEADER ), getConfiguration() ) );
- _options_jmenu.add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( SEARCH_CASE_SENSITIVE_LABEL ) );
- _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( SEARCH_TERMS_ONLY_LABEL ) );
- _options_jmenu.add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( INVERSE_SEARCH_RESULT_LABEL ) );
- _options_jmenu.addSeparator();
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Graphics Export & Printing:" ),
- getConfiguration() ) );
- _options_jmenu.add( _antialias_print_cbmi = new JCheckBoxMenuItem( "Antialias" ) );
- _options_jmenu.add( _print_black_and_white_cbmi = new JCheckBoxMenuItem( "Export in Black and White" ) );
- _options_jmenu
- .add( _print_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PDF export and Printing" ) );
- _options_jmenu
- .add( _graphics_export_using_actual_size_cbmi = new JCheckBoxMenuItem( "Use Current Image Size for PNG, JPG, and GIF export" ) );
- _options_jmenu
- .add( _graphics_export_visible_only_cbmi = new JCheckBoxMenuItem( "Limit to Visible ('Screenshot') for PNG, JPG, and GIF export" ) );
- _options_jmenu.add( _print_size_mi = new JMenuItem( "" ) );
- _options_jmenu.add( _choose_pdf_width_mi = new JMenuItem( "" ) );
- _options_jmenu.addSeparator();
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/NHX/Nexus Input:" ), getConfiguration() ) );
- _options_jmenu
- .add( _internal_number_are_confidence_for_nh_parsing_cbmi = new JCheckBoxMenuItem( "Internal Node Names are Confidence Values" ) );
- _options_jmenu.add( _replace_underscores_cbmi = new JCheckBoxMenuItem( "Replace Underscores with Spaces" ) );
- _options_jmenu
- .add( _allow_errors_in_distance_to_parent_cbmi = new JCheckBoxMenuItem( "Ignore Distance Values Format Errors" ) );
- //
- _options_jmenu.add( _extract_taxonomy_no_rbmi = new JRadioButtonMenuItem( "No Taxonomy Extraction" ) );
- _options_jmenu
- .add( _extract_taxonomy_pfam_strict_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids from Pfam-style Node Names" ) );
- _options_jmenu
- .add( _extract_taxonomy_pfam_relaxed_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids from Pfam-style like Node Names" ) );
- _options_jmenu
- .add( _extract_taxonomy_agressive_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes/Ids/Scientific Names from Node Names" ) );
- _extract_taxonomy_pfam_strict_rbmi
- .setToolTipText( "To extract taxonomy codes/ids from node names in the form of e.g. \"BCL2_MOUSE/123-304\" or \"BCL2_10090/123-304\"" );
- _extract_taxonomy_pfam_relaxed_rbmi
- .setToolTipText( "To extract taxonomy codes/ids from node names in the form of e.g. \"bax_MOUSE\" or \"bax_10090\"" );
- _extract_taxonomy_agressive_rbmi
- .setToolTipText( "To extract taxonomy codes/ids or scientific names from node names in the form of e.g. \"MOUSE\" or \"10090\" or \"xyz_Nematostella_vectensis\"" );
- _radio_group_2 = new ButtonGroup();
- _radio_group_2.add( _extract_taxonomy_no_rbmi );
- _radio_group_2.add( _extract_taxonomy_pfam_strict_rbmi );
- _radio_group_2.add( _extract_taxonomy_pfam_relaxed_rbmi );
- _radio_group_2.add( _extract_taxonomy_agressive_rbmi );
- //
- _options_jmenu.add( customizeMenuItemAsLabel( new JMenuItem( "Newick/Nexus Output:" ), getConfiguration() ) );
- _options_jmenu
- .add( _use_brackets_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_BRACKETS_FOR_CONF_IN_NH_LABEL ) );
- _use_brackets_for_conf_in_nh_export_cbmi
- .setToolTipText( "e.g. \"0.1[90]\" for a branch with support 90 and a length of 0.1" );
- _options_jmenu
- .add( _use_internal_names_for_conf_in_nh_export_cbmi = new JCheckBoxMenuItem( USE_INTERNAL_NAMES_FOR_CONF_IN_NH_LABEL ) );
- customizeJMenuItem( _choose_font_mi );
- customizeJMenuItem( _choose_minimal_confidence_mi );
- customizeJMenuItem( _switch_colors_mi );
- customizeJMenuItem( _print_size_mi );
- customizeJMenuItem( _choose_pdf_width_mi );
- customizeJMenuItem( _overview_placment_mi );
- customizeCheckBoxMenuItem( _show_default_node_shapes_external_cbmi, getOptions()
- .isShowDefaultNodeShapesExternal() );
- customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions()
- .isShowDefaultNodeShapesInternal() );
- customizeJMenuItem( _cycle_node_shape_mi );
- customizeJMenuItem( _cycle_node_fill_mi );
- customizeJMenuItem( _choose_node_size_mi );
- customizeCheckBoxMenuItem( _color_labels_same_as_parent_branch, getOptions().isColorLabelsSameAsParentBranch() );
- customizeCheckBoxMenuItem( _color_by_taxonomic_group_cbmi, getOptions().isColorByTaxonomicGroup() );
- customizeCheckBoxMenuItem( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
- customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
- customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
- customizeCheckBoxMenuItem( _show_annotation_ref_source, getOptions().isShowAnnotationRefSource() );
- customizeCheckBoxMenuItem( _abbreviate_scientific_names, getOptions().isAbbreviateScientificTaxonNames() );
- customizeCheckBoxMenuItem( _search_case_senstive_cbmi, getOptions().isSearchCaseSensitive() );
- customizeCheckBoxMenuItem( _show_scale_cbmi, getOptions().isShowScale() );
- customizeRadioButtonMenuItem( _non_lined_up_cladograms_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP );
- customizeRadioButtonMenuItem( _uniform_cladograms_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.TOTAL_NODE_SUM_DEP );
- customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi,
- getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP );
- customizeCheckBoxMenuItem( _show_branch_length_values_cbmi, getOptions().isShowBranchLengthValues() );
- customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() );
- customizeCheckBoxMenuItem( _label_direction_cbmi,
- getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL );
- customizeCheckBoxMenuItem( _antialias_print_cbmi, getOptions().isAntialiasPrint() );
- customizeCheckBoxMenuItem( _print_black_and_white_cbmi, getOptions().isPrintBlackAndWhite() );
- customizeCheckBoxMenuItem( _internal_number_are_confidence_for_nh_parsing_cbmi, getOptions()
- .isInternalNumberAreConfidenceForNhParsing() );
- customizeRadioButtonMenuItem( _extract_taxonomy_no_rbmi,
- getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.NO );
- customizeRadioButtonMenuItem( _extract_taxonomy_pfam_strict_rbmi,
- getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_STRICT );
- customizeRadioButtonMenuItem( _extract_taxonomy_pfam_relaxed_rbmi,
- getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_RELAXED );
- customizeRadioButtonMenuItem( _extract_taxonomy_agressive_rbmi,
- getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.AGGRESSIVE );
- customizeCheckBoxMenuItem( _replace_underscores_cbmi, getOptions().isReplaceUnderscoresInNhParsing() );
- customizeCheckBoxMenuItem( _allow_errors_in_distance_to_parent_cbmi, getOptions()
- .isReplaceUnderscoresInNhParsing() );
- customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() );
- customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() );
- customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() );
- customizeCheckBoxMenuItem( _print_using_actual_size_cbmi, getOptions().isPrintUsingActualSize() );
- customizeCheckBoxMenuItem( _graphics_export_using_actual_size_cbmi, getOptions()
- .isGraphicsExportUsingActualSize() );
- customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() );
- customizeCheckBoxMenuItem( _use_brackets_for_conf_in_nh_export_cbmi, getOptions()
- .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.IN_SQUARE_BRACKETS );
- customizeCheckBoxMenuItem( _use_internal_names_for_conf_in_nh_export_cbmi, getOptions()
- .getNhConversionSupportValueStyle() == NH_CONVERSION_SUPPORT_VALUE_STYLE.AS_INTERNAL_NODE_NAMES );
- _jmenubar.add( _options_jmenu );
- }
-
- void buildPhylogeneticInferenceMenu() {
- final InferenceManager im = getInferenceManager();
- _inference_menu = MainFrame.createMenu( "Inference", getConfiguration() );
- _inference_menu.add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) );
- customizeJMenuItem( _inference_from_msa_item );
- _inference_from_msa_item.setToolTipText( "Basic phylogenetic inference from MSA" );
- if ( im.canDoMsa() ) {
- _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );
- customizeJMenuItem( _inference_from_seqs_item );
- _inference_from_seqs_item
- .setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );
- }
- else {
- _inference_menu
- .add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences (no program found)" ) );
- customizeJMenuItem( _inference_from_seqs_item );
- _inference_from_seqs_item.setEnabled( false );
- }
- _jmenubar.add( _inference_menu );
- }
-
- void buildToolsMenu() {
- _tools_menu = createMenu( "Tools", getConfiguration() );
- _tools_menu.add( _confcolor_item = new JMenuItem( "Colorize Branches Depending on Confidence" ) );
- customizeJMenuItem( _confcolor_item );
- _tools_menu.add( _color_rank_jmi = new JMenuItem( "Colorize Subtrees via Taxonomic Rank" ) );
- customizeJMenuItem( _color_rank_jmi );
- _color_rank_jmi.setToolTipText( "for example, at \"Class\" level, colorize mammal specific subtree red" );
- _tools_menu.add( _taxcolor_item = new JMenuItem( "Taxonomy Colorize Branches" ) );
- customizeJMenuItem( _taxcolor_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _remove_visual_styles_item = new JMenuItem( "Delete All Visual Styles From Nodes" ) );
- _remove_visual_styles_item
- .setToolTipText( "To remove all node visual styles (fonts, colors) from the current phylogeny." );
- customizeJMenuItem( _remove_visual_styles_item );
- _tools_menu.add( _remove_branch_color_item = new JMenuItem( "Delete All Colors From Branches" ) );
- _remove_branch_color_item.setToolTipText( "To remove all branch color values from the current phylogeny." );
- customizeJMenuItem( _remove_branch_color_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _annotate_item = new JMenuItem( "Annotate Sequences of Selected Nodes" ) );
- customizeJMenuItem( _annotate_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _midpoint_root_item = new JMenuItem( "Midpoint-Root" ) );
- customizeJMenuItem( _midpoint_root_item );
- _tools_menu.addSeparator();
- _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) );
- customizeJMenuItem( _collapse_species_specific_subtrees );
- _tools_menu
- .add( _collapse_below_threshold = new JMenuItem( "Collapse Branches with Confidence Below Threshold into Multifurcations" ) );
- customizeJMenuItem( _collapse_below_threshold );
- _collapse_below_threshold
- .setToolTipText( "To collapse branches with confidence values below a threshold into multifurcations (in the case of multiple confidences per branch: without at least one confidence value above a threshold)" );
- _tools_menu.addSeparator();
- _tools_menu
- .add( _extract_tax_code_from_node_names_jmi = new JMenuItem( "Extract Taxonomic Data from Node Names" ) );
- customizeJMenuItem( _extract_tax_code_from_node_names_jmi );
- _extract_tax_code_from_node_names_jmi
- .setToolTipText( "To extract SwissProt/Uniprot taxonomic codes (mnemonics) from nodes names in the form of 'xyz_CAEEL', Uniprot/NCBI identifiers form of 'xyz_6239', or scientific names form of 'xyz_Caenorhabditis_elegans'" );
- _tools_menu
- .add( _move_node_names_to_tax_sn_jmi = new JMenuItem( "Transfer Node Names to Taxonomic Scientific Names" ) );
- customizeJMenuItem( _move_node_names_to_tax_sn_jmi );
- _move_node_names_to_tax_sn_jmi.setToolTipText( "To interpret node names as taxonomic scientific names" );
- _tools_menu.add( _move_node_names_to_seq_names_jmi = new JMenuItem( "Transfer Node Names to Sequence Names" ) );
- customizeJMenuItem( _move_node_names_to_seq_names_jmi );
- _move_node_names_to_seq_names_jmi.setToolTipText( "To interpret node names as sequence (protein, gene) names" );
- _tools_menu.addSeparator();
- _tools_menu.add( _obtain_seq_information_jmi = new JMenuItem( "Obtain Sequence Information" ) );
- customizeJMenuItem( _obtain_seq_information_jmi );
- _obtain_seq_information_jmi.setToolTipText( "To add additional sequence information" );
- _tools_menu
- .add( _obtain_detailed_taxonomic_information_jmi = new JMenuItem( OBTAIN_DETAILED_TAXONOMIC_INFORMATION ) );
- customizeJMenuItem( _obtain_detailed_taxonomic_information_jmi );
- _obtain_detailed_taxonomic_information_jmi
- .setToolTipText( "To add additional taxonomic information (from UniProt Taxonomy)" );
- _tools_menu
- .add( _obtain_detailed_taxonomic_information_deleting_jmi = new JMenuItem( "Obtain Detailed Taxonomic Information (deletes nodes!)" ) );
- customizeJMenuItem( _obtain_detailed_taxonomic_information_deleting_jmi );
- _obtain_detailed_taxonomic_information_deleting_jmi
- .setToolTipText( "To add additional taxonomic information, deletes nodes for which taxonomy cannot found (from UniProt Taxonomy)" );
- _tools_menu.addSeparator();
- _tools_menu.add( _read_values_jmi = new JMenuItem( "Attach Vector/Expression Values" ) );
- customizeJMenuItem( _read_values_jmi );
- _read_values_jmi.setToolTipText( "To attach vector (e.g. gene expression) values to tree nodes (beta)" );
- _jmenubar.add( _tools_menu );
- _tools_menu.add( _read_seqs_jmi = new JMenuItem( "Attach Molecular Sequences" ) );
- customizeJMenuItem( _read_seqs_jmi );
- _read_seqs_jmi
- .setToolTipText( "To attach molecular sequences to tree nodes (from Fasta-formatted file) (beta)" );
- _jmenubar.add( _tools_menu );
- }
-
- @Override
- void close() {
- if ( isUnsavedDataPresent() ) {
- final int r = JOptionPane.showConfirmDialog( this,
- "Exit despite potentially unsaved changes?",
- "Exit?",
- JOptionPane.YES_NO_OPTION );
- if ( r != JOptionPane.YES_OPTION ) {
- return;
- }
- }
- exit();
- }
-
- void executeLineageInference() {
- if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
- return;
- }
- if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
- JOptionPane.showMessageDialog( this,
- "Phylogeny is not rooted.",
- "Cannot infer ancestral taxonomies",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- final AncestralTaxonomyInferrer inferrer = new AncestralTaxonomyInferrer( this,
- _mainpanel.getCurrentTreePanel(),
- _mainpanel.getCurrentPhylogeny()
- .copy() );
- new Thread( inferrer ).start();
- }
-
- void exit() {
- removeAllTextFrames();
- _mainpanel.terminate();
- _contentpane.removeAll();
- setVisible( false );
- dispose();
- System.exit( 0 );
- }
-
- void setMsa( final Msa msa ) {
- _msa = msa;
- }
-
- void setMsaFile( final File msa_file ) {
- _msa_file = msa_file;
- }
-
- void setSeqs( final List<Sequence> seqs ) {
- _seqs = seqs;
- }
-
- void setSeqsFile( final File seqs_file ) {
- _seqs_file = seqs_file;
- }
-
- void writePhylogenyToGraphicsFile( final String file_name, final GraphicsExportType type ) {
- _mainpanel.getCurrentTreePanel().calcParametersForPainting( _mainpanel.getCurrentTreePanel().getWidth(),
- _mainpanel.getCurrentTreePanel().getHeight(),
- true );
- String file_written_to = "";
- boolean error = false;
- try {
- file_written_to = AptxUtil.writePhylogenyToGraphicsFile( file_name,
- _mainpanel.getCurrentTreePanel().getWidth(),
- _mainpanel.getCurrentTreePanel().getHeight(),
- _mainpanel.getCurrentTreePanel(),
- _mainpanel.getControlPanel(),
- type,
- getOptions() );
- }
- catch ( final IOException e ) {
- error = true;
- JOptionPane.showMessageDialog( this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE );
- }
- if ( !error ) {
- if ( ( file_written_to != null ) && ( file_written_to.length() > 0 ) ) {
- JOptionPane.showMessageDialog( this,
- "Wrote image to: " + file_written_to,
- "Graphics Export",
- JOptionPane.INFORMATION_MESSAGE );
- }
- else {
- JOptionPane.showMessageDialog( this,
- "There was an unknown problem when attempting to write to an image file: \""
- + file_name + "\"",
- "Error",
- JOptionPane.ERROR_MESSAGE );
- }
- }
- _contentpane.repaint();
- }
-
- private void addExpressionValuesFromFile() {
- if ( ( getCurrentTreePanel() == null ) || ( getCurrentTreePanel().getPhylogeny() == null ) ) {
- JOptionPane.showMessageDialog( this,
- "Need to load evolutionary tree first",
- "Can Not Read Expression Values",
- JOptionPane.WARNING_MESSAGE );
- return;
- }
- final File my_dir = getCurrentDir();
- if ( my_dir != null ) {
- _values_filechooser.setCurrentDirectory( my_dir );
- }
- final int result = _values_filechooser.showOpenDialog( _contentpane );
- final File file = _values_filechooser.getSelectedFile();
- if ( ( file != null ) && ( file.length() > 0 ) && ( result == JFileChooser.APPROVE_OPTION ) ) {
- BasicTable<String> t = null;
- try {
- t = BasicTableParser.parse( file, '\t' );
- if ( t.getNumberOfColumns() < 2 ) {
- t = BasicTableParser.parse( file, ',' );
- }
- if ( t.getNumberOfColumns() < 2 ) {
- t = BasicTableParser.parse( file, ' ' );
- }
- }
- catch ( final IOException e ) {
- JOptionPane.showMessageDialog( this,
- e.getMessage(),
- "Could Not Read Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( t.getNumberOfColumns() < 2 ) {
- JOptionPane.showMessageDialog( this,
- "Table contains " + t.getNumberOfColumns() + " column(s)",
- "Problem with Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( t.getNumberOfRows() < 1 ) {
- JOptionPane.showMessageDialog( this,
- "Table contains zero rows",
- "Problem with Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
- if ( t.getNumberOfRows() != phy.getNumberOfExternalNodes() ) {
- JOptionPane.showMessageDialog( this,
- "Table contains " + t.getNumberOfRows() + " rows, but tree contains "
- + phy.getNumberOfExternalNodes() + " external nodes",
- "Warning",
- JOptionPane.WARNING_MESSAGE );
- }
- final DescriptiveStatistics stats = new BasicDescriptiveStatistics();
- int not_found = 0;
- for( final PhylogenyNodeIterator iter = phy.iteratorPreorder(); iter.hasNext(); ) {
- final PhylogenyNode node = iter.next();
- final String node_name = node.getName();
- if ( !ForesterUtil.isEmpty( node_name ) ) {
- int row = -1;
- try {
- row = t.findRow( node_name );
- }
- catch ( final IllegalArgumentException e ) {
- JOptionPane
- .showMessageDialog( this,
- e.getMessage(),
- "Error Mapping Node Identifiers to Expression Value Identifiers",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- if ( row < 0 ) {
- if ( node.isExternal() ) {
- not_found++;
- }
- continue;
- }
- final List<Double> l = new ArrayList<Double>();
- for( int col = 1; col < t.getNumberOfColumns(); ++col ) {
- double d = -100;
- try {
- d = Double.parseDouble( t.getValueAsString( col, row ) );
- }
- catch ( final NumberFormatException e ) {
- JOptionPane.showMessageDialog( this,
- "Could not parse \"" + t.getValueAsString( col, row )
- + "\" into a decimal value",
- "Issue with Expression Value Table",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- stats.addValue( d );
- l.add( d );
- }
- if ( !l.isEmpty() ) {
- if ( node.getNodeData().getProperties() != null ) {
- node.getNodeData().getProperties()
- .removePropertiesWithGivenReferencePrefix( PhyloXmlUtil.VECTOR_PROPERTY_REF );
- }
- node.getNodeData().setVector( l );
- }
- }
- }
- if ( not_found > 0 ) {
- JOptionPane.showMessageDialog( this, "Could not fine expression values for " + not_found
- + " external node(s)", "Warning", JOptionPane.WARNING_MESSAGE );
- }
- getCurrentTreePanel().setStatisticsForExpressionValues( stats );
- }
- }
-
- private void addSequencesFromFile() {
- if ( ( getCurrentTreePanel() == null ) || ( getCurrentTreePanel().getPhylogeny() == null ) ) {
- JOptionPane.showMessageDialog( this,
- "Need to load evolutionary tree first",
- "Can Not Read Sequences",
- JOptionPane.WARNING_MESSAGE );
- return;