- _file_jmenu.addSeparator();
- _file_jmenu.add( _print_item = new JMenuItem( "Print..." ) );
- _file_jmenu.addSeparator();
- _file_jmenu.add( _close_item = new JMenuItem( "Close Tab" ) );
- _close_item.setToolTipText( "To close the current pane." );
- _close_item.setEnabled( true );
- _file_jmenu.addSeparator();
- _file_jmenu.add( _exit_item = new JMenuItem( "Exit" ) );
- // For print in color option item
- customizeJMenuItem( _open_item );
- _open_item
- .setFont( new Font( _open_item.getFont().getFontName(), Font.BOLD, _open_item.getFont().getSize() + 4 ) );
- customizeJMenuItem( _open_url_item );
- for( int i = 0; i < webservices_manager.getAvailablePhylogeniesWebserviceClients().size(); ++i ) {
- customizeJMenuItem( _load_phylogeny_from_webservice_menu_items[ i ] );
- }
- customizeJMenuItem( _save_item );
- if ( getConfiguration().isEditable() ) {
- customizeJMenuItem( _new_item );
- }
- customizeJMenuItem( _close_item );
- customizeJMenuItem( _save_all_item );
- customizeJMenuItem( _write_to_pdf_item );
- customizeJMenuItem( _write_to_png_item );
- customizeJMenuItem( _write_to_jpg_item );
- customizeJMenuItem( _write_to_gif_item );
- customizeJMenuItem( _write_to_tif_item );
- customizeJMenuItem( _write_to_bmp_item );
- customizeJMenuItem( _print_item );
- customizeJMenuItem( _exit_item );
- _jmenubar.add( _file_jmenu );
- }
-
- 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_confidence_stddev_cbmi = new JCheckBoxMenuItem( SHOW_CONF_STDDEV_LABEL ) );
- _options_jmenu.add( _show_default_node_shapes_cbmi = new JCheckBoxMenuItem( DISPLAY_NODE_BOXES_LABEL ) );
- _options_jmenu
- .add( _taxonomy_colorize_node_shapes_cbmi = new JCheckBoxMenuItem( MainFrame.TAXONOMY_COLORIZE_NODE_SHAPES_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( _label_direction_cbmi = new JCheckBoxMenuItem( LABEL_DIRECTION_LABEL ) );
- _label_direction_cbmi.setToolTipText( LABEL_DIRECTION_TIP );
- _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( _screen_antialias_cbmi = new JCheckBoxMenuItem( SCREEN_ANTIALIAS_LABEL ) );
- _options_jmenu.add( _background_gradient_cbmi = new JCheckBoxMenuItem( BG_GRAD_LABEL ) );
- if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) {
- _options_jmenu.add( _show_domain_labels = new JCheckBoxMenuItem( SHOW_DOMAIN_LABELS_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( _extract_taxonomy_no_rbmi = new JRadioButtonMenuItem( "No Taxonomy Extraction" ) );
- _options_jmenu
- .add( _extract_taxonomy_pfam_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes from Pfam-style Node Names" ) );
- _extract_taxonomy_pfam_rbmi
- .setToolTipText( "To extract 5-letter taxonomy codes from node names in the form of \"BCL2_MOUSE/134-298\"" );
- _options_jmenu
- .add( _extract_taxonomy_yes_rbmi = new JRadioButtonMenuItem( "Extract Taxonomy Codes from Node Names" ) );
- _extract_taxonomy_yes_rbmi
- .setToolTipText( "To extract 5-letter taxonomy codes from node names in the form of \"BCL2_MOUSE\" or \"BCL2_MOUSE B-cell lymphoma 2...\"" );
- _radio_group_2 = new ButtonGroup();
- _radio_group_2.add( _extract_taxonomy_no_rbmi );
- _radio_group_2.add( _extract_taxonomy_pfam_rbmi );
- _radio_group_2.add( _extract_taxonomy_yes_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_cbmi, getOptions().isShowDefaultNodeShapes() );
- customizeCheckBoxMenuItem( _taxonomy_colorize_node_shapes_cbmi, getOptions().isTaxonomyColorizeNodeShapes() );
- 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( _screen_antialias_cbmi, getOptions().isAntialiasScreen() );
- customizeCheckBoxMenuItem( _background_gradient_cbmi, getOptions().isBackgroundColorGradient() );
- customizeCheckBoxMenuItem( _show_domain_labels, getOptions().isShowDomainLabels() );
- 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_yes_rbmi,
- getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.YES );
- customizeRadioButtonMenuItem( _extract_taxonomy_pfam_rbmi,
- getOptions().getTaxonomyExtraction() == TAXONOMY_EXTRACTION.PFAM_STYLE_ONLY );
- customizeCheckBoxMenuItem( _replace_underscores_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.add( _remove_branch_color_item = new JMenuItem( "Delete Branch Colors" ) );
- _remove_branch_color_item.setToolTipText( "To delete 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_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.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.addSeparator();
- if ( !Constants.__RELEASE ) {
- _tools_menu.add( _function_analysis = new JMenuItem( "Add UniProtKB Annotations" ) );
- customizeJMenuItem( _function_analysis );
- _function_analysis
- .setToolTipText( "To add UniProtKB annotations for sequences with appropriate identifiers" );
- _tools_menu.addSeparator();
- }
- _tools_menu.add( _read_values_jmi = new JMenuItem( "Read Vector/Expression Values" ) );
- customizeJMenuItem( _read_values_jmi );
- _read_values_jmi.setToolTipText( "To add vector (e.g. gene expression) values (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 executeFunctionAnalysis() {
- if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
- return;
- }
- final GoAnnotation a = new GoAnnotation( this,
- _mainpanel.getCurrentTreePanel(),
- _mainpanel.getCurrentPhylogeny() );
- new Thread( a ).start();
- }
-
- void executeGSDI() {
- if ( !isOKforSDI( false, true ) ) {
- return;
- }
- if ( !_mainpanel.getCurrentPhylogeny().isRooted() ) {
- JOptionPane.showMessageDialog( this,
- "Gene tree is not rooted.",
- "Cannot execute GSDI",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
- gene_tree.setAllNodesToNotCollapse();
- gene_tree.recalculateNumberOfExternalDescendants( false );
- GSDI gsdi = null;
- final Phylogeny species_tree = _species_tree.copy();
- try {
- gsdi = new GSDI( gene_tree, species_tree, false, true, true );
- }
- catch ( final SDIException e ) {
- JOptionPane.showMessageDialog( this,
- e.getLocalizedMessage(),
- "Error during GSDI",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- catch ( final Exception e ) {
- AptxUtil.unexpectedException( e );
- return;
- }
- gene_tree.setRerootable( false );
- _mainpanel.getCurrentTreePanel().setTree( gene_tree );
- _mainpanel.getCurrentPhylogeny().clearHashIdToNodeMap();
- _mainpanel.getCurrentPhylogeny().recalculateNumberOfExternalDescendants( true );
- _mainpanel.getCurrentTreePanel().resetNodeIdToDistToLeafMap();
- _mainpanel.getCurrentTreePanel().setEdited( true );
- getControlPanel().setShowEvents( true );
- showWhole();
- final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
- _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
- showWhole();
- _mainpanel.getTabbedPane().setSelectedIndex( selected );
- showWhole();
- _mainpanel.getCurrentTreePanel().setEdited( true );
- JOptionPane.showMessageDialog( this, "Duplications: " + gsdi.getDuplicationsSum() + "\n"
- + "Potential duplications: " + gsdi.getSpeciationOrDuplicationEventsSum() + "\n" + "Speciations: "
- + gsdi.getSpeciationsSum(), "GSDI successfully completed", JOptionPane.INFORMATION_MESSAGE );
- }
-
- void executeGSDIR() {
- if ( !isOKforSDI( false, true ) ) {
- return;
- }
- final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
- gene_tree.setAllNodesToNotCollapse();
- gene_tree.recalculateNumberOfExternalDescendants( false );
- GSDIR gsdir = null;
- final Phylogeny species_tree = _species_tree.copy();
- try {
- gsdir = new GSDIR( gene_tree, species_tree, true, true );
- }
- catch ( final SDIException e ) {
- JOptionPane.showMessageDialog( this,
- e.getLocalizedMessage(),
- "Error during GSDIR",
- JOptionPane.ERROR_MESSAGE );
- return;
- }
- catch ( final Exception e ) {
- AptxUtil.unexpectedException( e );
- return;
- }
- final List<Phylogeny> assigned_trees = gsdir.getMinDuplicationsSumGeneTrees();
- final List<Integer> shortests = GSDIR.getIndexesOfShortestTree( assigned_trees );
- final Phylogeny result_gene_tree = assigned_trees.get( shortests.get( 0 ) );
- result_gene_tree.setRerootable( false );
- result_gene_tree.clearHashIdToNodeMap();
- result_gene_tree.recalculateNumberOfExternalDescendants( true );
- _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
- getControlPanel().setShowEvents( true );
- showWhole();
- final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
- _mainpanel.addPhylogenyInNewTab( species_tree, getConfiguration(), "species tree", null );
- showWhole();
- _mainpanel.getTabbedPane().setSelectedIndex( selected );
- showWhole();
- _mainpanel.getCurrentTreePanel().setEdited( true );
- JOptionPane.showMessageDialog( this,
- "Duplications (min): " + gsdir.getMinDuplicationsSum() + "\n" + "Speciations: "
- + gsdir.getSpeciationsSum() + "\n"
- + "Number of root positions minimizing duplications sum: "
- + gsdir.getMinDuplicationsSumGeneTrees().size() + "\n"
- + "Number of shortest trees: " + shortests.size(),
- "GSDIR successfully completed",
- JOptionPane.INFORMATION_MESSAGE );
- }
-
- 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 executeSDIR( final boolean minimize_cost ) {
- if ( !isOKforSDI( true, true ) ) {
- return;
- }
- Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
- final SDIR sdiunrooted = new SDIR();
- gene_tree.setAllNodesToNotCollapse();
- gene_tree.recalculateNumberOfExternalDescendants( false );
- try {
- gene_tree = sdiunrooted.infer( gene_tree, _species_tree, minimize_cost, // minimize cost
- !minimize_cost, // minimize sum of dups
- true, // minimize height
- true, // return tree(s)
- 1 )[ 0 ]; // # of trees to return
- }
- catch ( final Exception e ) {
- JOptionPane.showMessageDialog( this, e.toString(), "Error during SDIR", JOptionPane.ERROR_MESSAGE );
- return;
- }
- final int duplications = sdiunrooted.getMinimalDuplications();
- gene_tree.setRerootable( false );
- _mainpanel.getCurrentTreePanel().setTree( gene_tree );
- getControlPanel().setShowEvents( true );
- showWhole();
- _mainpanel.getCurrentTreePanel().setEdited( true );
- JOptionPane.showMessageDialog( this,
- "Number of duplications: " + duplications,
- "SDIR successfully completed",
- JOptionPane.INFORMATION_MESSAGE );
- }
-
- void exit() {
- removeAllTextFrames();
- _mainpanel.terminate();
- _contentpane.removeAll();
- setVisible( false );
- dispose();
- System.exit( 0 );
- }
-
- boolean isOKforSDI( final boolean species_tree_has_to_binary, final boolean gene_tree_has_to_binary ) {
- if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
- return false;
- }
- else if ( ( _species_tree == null ) || _species_tree.isEmpty() ) {
- JOptionPane.showMessageDialog( this,
- "No species tree loaded",
- "Cannot execute SDI",
- JOptionPane.ERROR_MESSAGE );
- return false;
- }
- else if ( species_tree_has_to_binary && !_species_tree.isCompletelyBinary() ) {
- JOptionPane.showMessageDialog( this,
- "Species tree is not completely binary",
- "Cannot execute SDI",
- JOptionPane.ERROR_MESSAGE );
- return false;
- }
- else if ( gene_tree_has_to_binary && !_mainpanel.getCurrentPhylogeny().isCompletelyBinary() ) {
- JOptionPane.showMessageDialog( this,
- "Gene tree is not completely binary",
- "Cannot execute SDI",
- JOptionPane.ERROR_MESSAGE );
- return false;
- }
- else {
- return true;
- }
- }
-
- @Override
- void readPhylogeniesFromURL() {
- URL url = null;
- Phylogeny[] phys = null;
- final String message = "Please enter a complete URL, for example \"http://www.phyloxml.org/examples/apaf.xml\"";
- final String url_string = JOptionPane.showInputDialog( this,
- message,
- "Use URL/webservice to obtain a phylogeny",
- JOptionPane.QUESTION_MESSAGE );
- boolean nhx_or_nexus = false;
- if ( ( url_string != null ) && ( url_string.length() > 0 ) ) {
- try {
- url = new URL( url_string );
- PhylogenyParser parser = null;
- if ( url.getHost().toLowerCase().indexOf( "tolweb" ) >= 0 ) {
- parser = new TolParser();
- }
- else {
- parser = ParserUtils.createParserDependingOnUrlContents( url, getConfiguration()
- .isValidatePhyloXmlAgainstSchema() );
- }
- if ( parser instanceof NexusPhylogeniesParser ) {
- nhx_or_nexus = true;
- }
- else if ( parser instanceof NHXParser ) {
- nhx_or_nexus = true;
- }
- if ( _mainpanel.getCurrentTreePanel() != null ) {
- _mainpanel.getCurrentTreePanel().setWaitCursor();
- }
- else {
- _mainpanel.setWaitCursor();
- }
- final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
- phys = factory.create( url.openStream(), parser );
- }
- catch ( final MalformedURLException e ) {
- JOptionPane.showMessageDialog( this,
- "Malformed URL: " + url + "\n" + e.getLocalizedMessage(),
- "Malformed URL",
- JOptionPane.ERROR_MESSAGE );
- }
- catch ( final IOException e ) {
- JOptionPane.showMessageDialog( this,
- "Could not read from " + url + "\n"
- + ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
- "Failed to read URL",
- JOptionPane.ERROR_MESSAGE );
- }
- catch ( final Exception e ) {
- JOptionPane.showMessageDialog( this,
- ForesterUtil.wordWrap( e.getLocalizedMessage(), 80 ),
- "Unexpected Exception",
- JOptionPane.ERROR_MESSAGE );
- }
- finally {
- if ( _mainpanel.getCurrentTreePanel() != null ) {
- _mainpanel.getCurrentTreePanel().setArrowCursor();
- }
- else {
- _mainpanel.setArrowCursor();
- }
- }
- if ( ( phys != null ) && ( phys.length > 0 ) ) {
- if ( nhx_or_nexus && getOptions().isInternalNumberAreConfidenceForNhParsing() ) {
- for( final Phylogeny phy : phys ) {
- PhylogenyMethods.transferInternalNodeNamesToConfidence( phy );
- }
- }
- AptxUtil.addPhylogeniesToTabs( phys,
- new File( url.getFile() ).getName(),
- new File( url.getFile() ).toString(),
- getConfiguration(),
- getMainPanel() );
- _mainpanel.getControlPanel().showWhole();
- }
- }
- activateSaveAllIfNeeded();
- System.gc();
- }
-
- 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().setParametersForPainting( _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;