X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=forester%2Fjava%2Fsrc%2Forg%2Fforester%2Farchaeopteryx%2FMainFrameApplication.java;h=e6d6092c5c293d04f904ffb018231d940401d965;hb=28cf1afacf61a15e72411b1e58c3694f78d6d0dd;hp=85e93363a49a8b8735e7ddc40b7b4165944d5069;hpb=f642399d323502c48c4ccb25ad6a4268a4152e6a;p=jalview.git diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 85e9336..e6d6092 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -93,6 +93,7 @@ import org.forester.phylogeny.PhylogenyMethods; import org.forester.phylogeny.PhylogenyNode; import org.forester.phylogeny.PhylogenyNode.NH_CONVERSION_SUPPORT_VALUE_STYLE; import org.forester.phylogeny.data.Confidence; +import org.forester.phylogeny.data.PhylogenyDataUtil; import org.forester.phylogeny.data.Sequence; import org.forester.phylogeny.data.Taxonomy; import org.forester.phylogeny.factories.ParserBasedPhylogenyFactory; @@ -142,11 +143,14 @@ public final class MainFrameApplication extends MainFrame { private JMenuItem _write_to_tif_item; private JMenuItem _write_to_png_item; private JMenuItem _write_to_bmp_item; + private JMenuItem _collapse_below_threshold; + private JMenuItem _collapse_below_branch_length; private File _current_dir; private ButtonGroup _radio_group_1; private ButtonGroup _radio_group_2; // Others: double _min_not_collapse = Constants.MIN_NOT_COLLAPSE_DEFAULT; + double _min_not_collapse_bl = 0.001; // Phylogeny Inference menu private JMenu _inference_menu; private JMenuItem _inference_from_msa_item; @@ -545,6 +549,12 @@ public final class MainFrameApplication extends MainFrame { } collapseBelowThreshold(); } + else if ( o == _collapse_below_branch_length ) { + if ( isSubtreeDisplayed() ) { + return; + } + collapseBelowBranchLengthThreshold(); + } else if ( ( o == _extract_taxonomy_pfam_strict_rbmi ) || ( o == _extract_taxonomy_pfam_relaxed_rbmi ) || ( o == _extract_taxonomy_agressive_rbmi ) ) { if ( _replace_underscores_cbmi != null ) { @@ -891,13 +901,14 @@ public final class MainFrameApplication extends MainFrame { _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_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 ) ); + _options_jmenu + .add( _show_default_node_shapes_for_marked_cbmi = new JCheckBoxMenuItem( MainFrame.DISPLAY_NODE_BOXES_LABEL_MARKED ) ); _options_jmenu.add( _line_up_renderable_data_cbmi = new JCheckBoxMenuItem( MainFrame.LINE_UP_RENDERABLE_DATA ) ); if ( getConfiguration().doDisplayOption( Configuration.show_domain_architectures ) ) { _options_jmenu.add( _right_line_up_domains_cbmi = new JCheckBoxMenuItem( MainFrame.RIGHT_LINE_UP_DOMAINS ) ); @@ -920,11 +931,12 @@ public final class MainFrameApplication extends MainFrame { _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( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) ); + _search_with_regex_cbmi.setToolTipText( MainFrame.SEARCH_WITH_REGEX_TIP ); _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:" ), @@ -946,7 +958,6 @@ public final class MainFrameApplication extends MainFrame { _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" ) ); @@ -965,7 +976,6 @@ public final class MainFrameApplication extends MainFrame { _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 ) ); @@ -983,6 +993,8 @@ public final class MainFrameApplication extends MainFrame { .isShowDefaultNodeShapesExternal() ); customizeCheckBoxMenuItem( _show_default_node_shapes_internal_cbmi, getOptions() .isShowDefaultNodeShapesInternal() ); + customizeCheckBoxMenuItem( _show_default_node_shapes_for_marked_cbmi, getOptions() + .isShowDefaultNodeShapesForMarkedNodes() ); customizeJMenuItem( _cycle_node_shape_mi ); customizeJMenuItem( _cycle_node_fill_mi ); customizeJMenuItem( _choose_node_size_mi ); @@ -1019,6 +1031,7 @@ public final class MainFrameApplication extends MainFrame { customizeCheckBoxMenuItem( _replace_underscores_cbmi, getOptions().isReplaceUnderscoresInNhParsing() ); customizeCheckBoxMenuItem( _allow_errors_in_distance_to_parent_cbmi, getOptions() .isReplaceUnderscoresInNhParsing() ); + customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() ); customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() ); customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() ); customizeCheckBoxMenuItem( _graphics_export_visible_only_cbmi, getOptions().isGraphicsExportVisibleOnly() ); @@ -1089,11 +1102,19 @@ public final class MainFrameApplication extends MainFrame { _tools_menu.addSeparator(); _tools_menu.add( _collapse_species_specific_subtrees = new JMenuItem( "Collapse Species-Specific Subtrees" ) ); customizeJMenuItem( _collapse_species_specific_subtrees ); + _collapse_species_specific_subtrees.setToolTipText( "To (reversibly) 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)" ); + .setToolTipText( "To (permanently) 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 + .add( _collapse_below_branch_length = new JMenuItem( "Collapse Branches with Branch Lengths Below Threshold into Multifurcations" ) ); + customizeJMenuItem( _collapse_below_branch_length ); + _collapse_below_branch_length + .setToolTipText( "To (permanently) collapse branches with branches with branch lengths below a threshold into multifurcations" ); + // _tools_menu.addSeparator(); _tools_menu .add( _extract_tax_code_from_node_names_jmi = new JMenuItem( "Extract Taxonomic Data from Node Names" ) ); @@ -1672,7 +1693,65 @@ public final class MainFrameApplication extends MainFrame { } } - private void collapse( final Phylogeny phy, final double m ) { + private void collapseBl( final Phylogeny phy ) { + final PhylogenyNodeIterator it = phy.iteratorPostorder(); + final List to_be_removed = new ArrayList(); + double min_bl = Double.MAX_VALUE; + boolean bl_present = false; + while ( it.hasNext() ) { + final PhylogenyNode n = it.next(); + if ( !n.isExternal() && !n.isRoot() ) { + final double bl = n.getDistanceToParent(); + if ( bl != PhylogenyDataUtil.BRANCH_LENGTH_DEFAULT ) { + bl_present = true; + if ( bl < getMinNotCollapseBlValue() ) { + to_be_removed.add( n ); + } + if ( bl < min_bl ) { + min_bl = bl; + } + } + } + } + if ( bl_present ) { + for( final PhylogenyNode node : to_be_removed ) { + PhylogenyMethods.removeNode( node, phy ); + } + if ( to_be_removed.size() > 0 ) { + phy.externalNodesHaveChanged(); + phy.clearHashIdToNodeMap(); + phy.recalculateNumberOfExternalDescendants( true ); + getCurrentTreePanel().resetNodeIdToDistToLeafMap(); + getCurrentTreePanel().updateSetOfCollapsedExternalNodes(); + getCurrentTreePanel().calculateLongestExtNodeInfo(); + getCurrentTreePanel().setNodeInPreorderToNull(); + getCurrentTreePanel().recalculateMaxDistanceToRoot(); + getCurrentTreePanel().resetPreferredSize(); + getCurrentTreePanel().setEdited( true ); + getCurrentTreePanel().repaint(); + repaint(); + } + if ( to_be_removed.size() > 0 ) { + JOptionPane.showMessageDialog( this, "Collapsed " + to_be_removed.size() + + " branches with\nbranch length values below " + getMinNotCollapseBlValue(), "Collapsed " + + to_be_removed.size() + " branches", JOptionPane.INFORMATION_MESSAGE ); + } + else { + JOptionPane.showMessageDialog( this, + "No branch collapsed,\nminimum branch length is " + min_bl, + "No branch collapsed", + JOptionPane.INFORMATION_MESSAGE ); + } + } + else { + JOptionPane.showMessageDialog( this, + "No branch collapsed because no branch length values present", + "No branch length values present", + JOptionPane.INFORMATION_MESSAGE ); + } + } + + private void collapse( final Phylogeny phy ) { final PhylogenyNodeIterator it = phy.iteratorPostorder(); final List to_be_removed = new ArrayList(); double min_support = Double.MAX_VALUE; @@ -1762,7 +1841,43 @@ public final class MainFrameApplication extends MainFrame { } if ( success && ( m >= 0.0 ) ) { setMinNotCollapseConfidenceValue( m ); - collapse( phy, m ); + collapse( phy ); + } + } + } + } + } + + private void collapseBelowBranchLengthThreshold() { + if ( getCurrentTreePanel() != null ) { + final Phylogeny phy = getCurrentTreePanel().getPhylogeny(); + if ( ( phy != null ) && !phy.isEmpty() ) { + final String s = ( String ) JOptionPane + .showInputDialog( this, + "Please enter the minimum branch length value\n", + "Minimal Branch Length Value", + JOptionPane.QUESTION_MESSAGE, + null, + null, + getMinNotCollapseBlValue() ); + if ( !ForesterUtil.isEmpty( s ) ) { + boolean success = true; + double m = 0.0; + final String m_str = s.trim(); + if ( !ForesterUtil.isEmpty( m_str ) ) { + try { + m = Double.parseDouble( m_str ); + } + catch ( final Exception ex ) { + success = false; + } + } + else { + success = false; + } + if ( success && ( m >= 0.0 ) ) { + setMinNotCollapseBlValue( m ); + collapseBl( phy ); } } } @@ -1918,6 +2033,10 @@ public final class MainFrameApplication extends MainFrame { return _min_not_collapse; } + private double getMinNotCollapseBlValue() { + return _min_not_collapse_bl; + } + private PhylogeneticInferenceOptions getPhylogeneticInferenceOptions() { if ( _phylogenetic_inference_options == null ) { _phylogenetic_inference_options = new PhylogeneticInferenceOptions(); @@ -2247,7 +2366,7 @@ public final class MainFrameApplication extends MainFrame { if ( n.isExternal() ) { if ( n.getNodeData().isHasSequence() ) { final Sequence s = n.getNodeData().getSequence(); - if ( ForesterUtil.isEmpty( s.getGeneName() ) ) { + if ( ForesterUtil.isEmpty( s.getGeneName() ) || s.getGeneName().startsWith( "LOC" ) ) { if ( ( s.getAccession() != null ) && !ForesterUtil.isEmpty( s.getAccession().getValue() ) ) { s.setGeneName( s.getAccession().getValue() ); @@ -2376,6 +2495,10 @@ public final class MainFrameApplication extends MainFrame { _min_not_collapse = min_not_collapse; } + private void setMinNotCollapseBlValue( final double min_not_collapse_bl ) { + _min_not_collapse_bl = min_not_collapse_bl; + } + private void setPhylogeneticInferenceOptions( final PhylogeneticInferenceOptions phylogenetic_inference_options ) { _phylogenetic_inference_options = phylogenetic_inference_options; }