From b48d82f75a2ff2f4e181092080371b8ab1abd618 Mon Sep 17 00:00:00 2001 From: "cmzmasek@gmail.com" Date: Tue, 14 Oct 2014 22:21:22 +0000 Subject: [PATCH] regex search --- .../org/forester/archaeopteryx/ArchaeopteryxE.java | 30 ++---- .../org/forester/archaeopteryx/ControlPanel.java | 4 +- .../src/org/forester/archaeopteryx/MainFrame.java | 15 ++- .../forester/archaeopteryx/MainFrameApplet.java | 17 +-- .../archaeopteryx/MainFrameApplication.java | 13 +-- .../src/org/forester/archaeopteryx/Options.java | 6 +- .../org/forester/phylogeny/PhylogenyMethods.java | 109 +++++++++++--------- 7 files changed, 88 insertions(+), 106 deletions(-) diff --git a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java index ffac851..36afa08 100644 --- a/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java +++ b/forester/java/src/org/forester/archaeopteryx/ArchaeopteryxE.java @@ -116,7 +116,6 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { private JCheckBoxMenuItem _search_whole_words_only_cbmi; private JCheckBoxMenuItem _inverse_search_result_cbmi; private JCheckBoxMenuItem _search_with_regex_cbmi; - private JCheckBoxMenuItem _show_overview_cbmi; private JMenuItem _choose_minimal_confidence_mi; private JMenuItem _collapse_species_specific_subtrees; @@ -253,6 +252,9 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { getMainPanel().getControlPanel().search1(); } else if ( o == _search_whole_words_only_cbmi ) { + if ( ( _search_with_regex_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ) { + _search_with_regex_cbmi.setSelected( false ); + } updateOptions( getOptions() ); getMainPanel().getControlPanel().search0(); getMainPanel().getControlPanel().search1(); @@ -263,6 +265,12 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { getMainPanel().getControlPanel().search1(); } else if ( o == _search_with_regex_cbmi ) { + if ( ( _search_whole_words_only_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) { + _search_whole_words_only_cbmi.setSelected( false ); + } + if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) { + _search_case_senstive_cbmi.setSelected( true ); + } updateOptions( getOptions() ); getMainPanel().getControlPanel().search0(); getMainPanel().getControlPanel().search1(); @@ -797,16 +805,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { _options_jmenu .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) ); _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) ); - - - - _options_jmenu - .add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) ); - - - - - + _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) ); _options_jmenu .add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( MainFrame.INVERSE_SEARCH_RESULT_LABEL ) ); customizeJMenuItem( _choose_font_mi ); @@ -840,12 +839,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { customizeRadioButtonMenuItem( _ext_node_dependent_cladogram_rbmi, getOptions().getCladogramType() == CLADOGRAM_TYPE.EXT_NODE_SUM_DEP ); customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() ); - - customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() ); - - - customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() ); customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() ); customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() ); @@ -1364,9 +1358,7 @@ public class ArchaeopteryxE extends JApplet implements ActionListener { && _show_confidence_stddev_cbmi.isSelected() ); options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ); - options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) - && _search_with_regex_cbmi.isSelected() ); - + options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() ); options.setInverseSearchResult( ( _inverse_search_result_cbmi != null ) && _inverse_search_result_cbmi.isSelected() ); if ( ( _rectangular_type_cbmi != null ) && _rectangular_type_cbmi.isSelected() ) { diff --git a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java index f532cc9..cffdfea 100644 --- a/forester/java/src/org/forester/archaeopteryx/ControlPanel.java +++ b/forester/java/src/org/forester/archaeopteryx/ControlPanel.java @@ -1822,7 +1822,7 @@ final class ControlPanel extends JPanel implements ActionListener { continue; } query = query.trim(); - if ( query.indexOf( '+' ) >= 0 ) { + if ( ( query.indexOf( '+' ) >= 0 ) && !getOptions().isSearchWithRegex() ) { nodes.addAll( PhylogenyMethods.searchDataLogicalAnd( query.split( "\\++" ), tree, getOptions().isSearchCaseSensitive(), @@ -1835,8 +1835,6 @@ final class ControlPanel extends JPanel implements ActionListener { getOptions().isSearchCaseSensitive(), !getOptions().isMatchWholeTermsOnly(), getOptions().isSearchWithRegex(), - - isShowDomainArchitectures() ) ); } } diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrame.java b/forester/java/src/org/forester/archaeopteryx/MainFrame.java index 7708753..84d6185 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrame.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrame.java @@ -96,7 +96,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { static final String SEARCH_SUBHEADER = "Search:"; static final String DISPLAY_SUBHEADER = "Display:"; static final String SEARCH_TERMS_ONLY_LABEL = "Match Complete Terms Only"; - static final String SEARCH_REGEX_LABEL = "Search with Regular Expressions"; + static final String SEARCH_REGEX_LABEL = "Search with Regular Expressions"; static final String SEARCH_CASE_SENSITIVE_LABEL = "Case Sensitive"; static final String INVERSE_SEARCH_RESULT_LABEL = "Negate Result"; static final String COLOR_BY_TAXONOMIC_GROUP = "Colorize by Taxonomic Group"; @@ -454,6 +454,9 @@ public abstract class MainFrame extends JFrame implements ActionListener { getMainPanel().getControlPanel().search1(); } else if ( o == _search_whole_words_only_cbmi ) { + if ( ( _search_with_regex_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ) { + _search_with_regex_cbmi.setSelected( false ); + } updateOptions( getOptions() ); getMainPanel().getControlPanel().search0(); getMainPanel().getControlPanel().search1(); @@ -464,6 +467,12 @@ public abstract class MainFrame extends JFrame implements ActionListener { getMainPanel().getControlPanel().search1(); } else if ( o == _search_with_regex_cbmi ) { + if ( ( _search_whole_words_only_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) { + _search_whole_words_only_cbmi.setSelected( false ); + } + if ( ( _search_case_senstive_cbmi != null ) && _search_with_regex_cbmi.isSelected() ) { + _search_case_senstive_cbmi.setSelected( true ); + } updateOptions( getOptions() ); getMainPanel().getControlPanel().search0(); getMainPanel().getControlPanel().search1(); @@ -1388,9 +1397,7 @@ public abstract class MainFrame extends JFrame implements ActionListener { && _allow_errors_in_distance_to_parent_cbmi.isSelected() ); options.setMatchWholeTermsOnly( ( _search_whole_words_only_cbmi != null ) && _search_whole_words_only_cbmi.isSelected() ); - options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) - && _search_with_regex_cbmi.isSelected() ); - + options.setSearchWithRegex( ( _search_with_regex_cbmi != null ) && _search_with_regex_cbmi.isSelected() ); options.setInverseSearchResult( ( _inverse_search_result_cbmi != null ) && _inverse_search_result_cbmi.isSelected() ); if ( _graphics_export_visible_only_cbmi != null ) { diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java index c6bd428..863bd08 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplet.java @@ -246,14 +246,7 @@ public final class MainFrameApplet extends MainFrame { _options_jmenu .add( _search_case_senstive_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_CASE_SENSITIVE_LABEL ) ); _options_jmenu.add( _search_whole_words_only_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_TERMS_ONLY_LABEL ) ); - - - - _options_jmenu - .add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) ); - - - + _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_LABEL ) ); _options_jmenu.add( _inverse_search_result_cbmi = new JCheckBoxMenuItem( INVERSE_SEARCH_RESULT_LABEL ) ); customizeJMenuItem( _choose_font_mi ); customizeJMenuItem( _switch_colors_mi ); @@ -286,15 +279,7 @@ public final class MainFrameApplet extends MainFrame { customizeCheckBoxMenuItem( _show_overview_cbmi, getOptions().isShowOverview() ); customizeCheckBoxMenuItem( _label_direction_cbmi, getOptions().getNodeLabelDirection() == NODE_LABEL_DIRECTION.RADIAL ); - - - customizeCheckBoxMenuItem( _search_with_regex_cbmi, getOptions().isSearchWithRegex() ); - - - - - customizeCheckBoxMenuItem( _search_whole_words_only_cbmi, getOptions().isMatchWholeTermsOnly() ); customizeCheckBoxMenuItem( _inverse_search_result_cbmi, getOptions().isInverseSearchResult() ); customizeCheckBoxMenuItem( _show_confidence_stddev_cbmi, getOptions().isShowConfidenceStddev() ); diff --git a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java index 6d0ba08..cc6fbe5 100644 --- a/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java +++ b/forester/java/src/org/forester/archaeopteryx/MainFrameApplication.java @@ -935,13 +935,7 @@ public final class MainFrameApplication extends MainFrame { _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 ) ); - - - + _options_jmenu.add( _search_with_regex_cbmi = new JCheckBoxMenuItem( MainFrame.SEARCH_REGEX_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:" ), @@ -1036,12 +1030,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() ); diff --git a/forester/java/src/org/forester/archaeopteryx/Options.java b/forester/java/src/org/forester/archaeopteryx/Options.java index b6992f0..8167a92 100644 --- a/forester/java/src/org/forester/archaeopteryx/Options.java +++ b/forester/java/src/org/forester/archaeopteryx/Options.java @@ -256,7 +256,7 @@ final public class Options { final boolean isMatchWholeTermsOnly() { return _match_whole_terms_only; } - + final boolean isSearchWithRegex() { return _search_with_regex; } @@ -366,7 +366,7 @@ final public class Options { final void setMatchWholeTermsOnly( final boolean search_whole_words_only ) { _match_whole_terms_only = search_whole_words_only; } - + final void setSearchWithRegex( final boolean search_with_regex ) { _search_with_regex = search_with_regex; } @@ -481,7 +481,7 @@ final public class Options { _base_font = new Font( Configuration.getDefaultFontFamilyName(), Font.PLAIN, 10 ); _match_whole_terms_only = false; _search_with_regex = false; - _search_case_sensitive = false; + _search_case_sensitive = true; _print_line_width = Constants.PDF_LINE_WIDTH_DEFAULT; _show_overview = true; _ov_placement = OVERVIEW_PLACEMENT_TYPE.UPPER_LEFT; diff --git a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java index 025b098..f7aa56d 100644 --- a/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java +++ b/forester/java/src/org/forester/phylogeny/PhylogenyMethods.java @@ -941,8 +941,7 @@ public class PhylogenyMethods { final boolean case_sensitive, final boolean partial, final boolean regex, - final boolean search_domains - ) { + final boolean search_domains ) { final List nodes = new ArrayList(); if ( phy.isEmpty() || ( query == null ) ) { return nodes; @@ -957,15 +956,19 @@ public class PhylogenyMethods { match = true; } else if ( node.getNodeData().isHasTaxonomy() - && match( node.getNodeData().getTaxonomy().getTaxonomyCode(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getTaxonomy().getTaxonomyCode(), query, case_sensitive, partial, regex ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() - && match( node.getNodeData().getTaxonomy().getCommonName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getTaxonomy().getCommonName(), query, case_sensitive, partial, regex ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() - && match( node.getNodeData().getTaxonomy().getScientificName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getTaxonomy().getScientificName(), + query, + case_sensitive, + partial, + regex ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() @@ -973,28 +976,29 @@ public class PhylogenyMethods { && match( node.getNodeData().getTaxonomy().getIdentifier().getValue(), query, case_sensitive, - partial ) ) { + partial, + regex ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() && !node.getNodeData().getTaxonomy().getSynonyms().isEmpty() ) { final List syns = node.getNodeData().getTaxonomy().getSynonyms(); I: for( final String syn : syns ) { - if ( match( syn, query, case_sensitive, partial ) ) { + if ( match( syn, query, case_sensitive, partial, regex ) ) { match = true; break I; } } } if ( !match && node.getNodeData().isHasSequence() - && match( node.getNodeData().getSequence().getName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getSequence().getName(), query, case_sensitive, partial, regex ) ) { match = true; } if ( !match && node.getNodeData().isHasSequence() - && match( node.getNodeData().getSequence().getGeneName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getSequence().getGeneName(), query, case_sensitive, partial, regex ) ) { match = true; } if ( !match && node.getNodeData().isHasSequence() - && match( node.getNodeData().getSequence().getSymbol(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getSequence().getSymbol(), query, case_sensitive, partial, regex ) ) { match = true; } if ( !match @@ -1003,28 +1007,28 @@ public class PhylogenyMethods { && match( node.getNodeData().getSequence().getAccession().getValue(), query, case_sensitive, - partial ) ) { + partial, + regex ) ) { match = true; } if ( search_domains && !match && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) { final DomainArchitecture da = node.getNodeData().getSequence().getDomainArchitecture(); I: for( int i = 0; i < da.getNumberOfDomains(); ++i ) { - if ( match( da.getDomain( i ).getName(), query, case_sensitive, partial ) ) { + if ( match( da.getDomain( i ).getName(), query, case_sensitive, partial, regex ) ) { match = true; break I; } } } - // if ( !match && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) ) { for( final Annotation ann : node.getNodeData().getSequence().getAnnotations() ) { - if ( match( ann.getDesc(), query, case_sensitive, partial ) ) { + if ( match( ann.getDesc(), query, case_sensitive, partial, regex ) ) { match = true; break; } - if ( match( ann.getRef(), query, case_sensitive, partial ) ) { + if ( match( ann.getRef(), query, case_sensitive, partial, regex ) ) { match = true; break; } @@ -1033,15 +1037,15 @@ public class PhylogenyMethods { if ( !match && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getCrossReferences() != null ) ) { for( final Accession x : node.getNodeData().getSequence().getCrossReferences() ) { - if ( match( x.getComment(), query, case_sensitive, partial ) ) { + if ( match( x.getComment(), query, case_sensitive, partial, regex ) ) { match = true; break; } - if ( match( x.getSource(), query, case_sensitive, partial ) ) { + if ( match( x.getSource(), query, case_sensitive, partial, regex ) ) { match = true; break; } - if ( match( x.getValue(), query, case_sensitive, partial ) ) { + if ( match( x.getValue(), query, case_sensitive, partial, regex ) ) { match = true; break; } @@ -1051,14 +1055,14 @@ public class PhylogenyMethods { if ( !match && ( node.getNodeData().getBinaryCharacters() != null ) ) { Iterator it = node.getNodeData().getBinaryCharacters().getPresentCharacters().iterator(); I: while ( it.hasNext() ) { - if ( match( it.next(), query, case_sensitive, partial ) ) { + if ( match( it.next(), query, case_sensitive, partial, regex ) ) { match = true; break I; } } it = node.getNodeData().getBinaryCharacters().getGainedCharacters().iterator(); I: while ( it.hasNext() ) { - if ( match( it.next(), query, case_sensitive, partial ) ) { + if ( match( it.next(), query, case_sensitive, partial, regex ) ) { match = true; break I; } @@ -1088,19 +1092,31 @@ public class PhylogenyMethods { if ( ForesterUtil.isEmpty( query ) ) { continue; } - if ( match( node.getName(), query, case_sensitive, partial ) ) { + if ( match( node.getName(), query, case_sensitive, partial, false ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() - && match( node.getNodeData().getTaxonomy().getTaxonomyCode(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getTaxonomy().getTaxonomyCode(), + query, + case_sensitive, + partial, + false ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() - && match( node.getNodeData().getTaxonomy().getCommonName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getTaxonomy().getCommonName(), + query, + case_sensitive, + partial, + false ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() - && match( node.getNodeData().getTaxonomy().getScientificName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getTaxonomy().getScientificName(), + query, + case_sensitive, + partial, + false ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() @@ -1108,29 +1124,31 @@ public class PhylogenyMethods { && match( node.getNodeData().getTaxonomy().getIdentifier().getValue(), query, case_sensitive, - partial ) ) { + partial, + false ) ) { match = true; } else if ( node.getNodeData().isHasTaxonomy() && !node.getNodeData().getTaxonomy().getSynonyms().isEmpty() ) { final List syns = node.getNodeData().getTaxonomy().getSynonyms(); I: for( final String syn : syns ) { - if ( match( syn, query, case_sensitive, partial ) ) { + if ( match( syn, query, case_sensitive, partial, false ) ) { match = true; break I; } } } if ( !match && node.getNodeData().isHasSequence() - && match( node.getNodeData().getSequence().getName(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getSequence().getName(), query, case_sensitive, partial, false ) ) { match = true; } - if ( !match && node.getNodeData().isHasSequence() - && match( node.getNodeData().getSequence().getGeneName(), query, case_sensitive, partial ) ) { + if ( !match + && node.getNodeData().isHasSequence() + && match( node.getNodeData().getSequence().getGeneName(), query, case_sensitive, partial, false ) ) { match = true; } if ( !match && node.getNodeData().isHasSequence() - && match( node.getNodeData().getSequence().getSymbol(), query, case_sensitive, partial ) ) { + && match( node.getNodeData().getSequence().getSymbol(), query, case_sensitive, partial, false ) ) { match = true; } if ( !match @@ -1139,14 +1157,15 @@ public class PhylogenyMethods { && match( node.getNodeData().getSequence().getAccession().getValue(), query, case_sensitive, - partial ) ) { + partial, + false ) ) { match = true; } if ( search_domains && !match && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getDomainArchitecture() != null ) ) { final DomainArchitecture da = node.getNodeData().getSequence().getDomainArchitecture(); I: for( int i = 0; i < da.getNumberOfDomains(); ++i ) { - if ( match( da.getDomain( i ).getName(), query, case_sensitive, partial ) ) { + if ( match( da.getDomain( i ).getName(), query, case_sensitive, partial, false ) ) { match = true; break I; } @@ -1156,11 +1175,11 @@ public class PhylogenyMethods { if ( !match && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAnnotations() != null ) ) { for( final Annotation ann : node.getNodeData().getSequence().getAnnotations() ) { - if ( match( ann.getDesc(), query, case_sensitive, partial ) ) { + if ( match( ann.getDesc(), query, case_sensitive, partial, false ) ) { match = true; break; } - if ( match( ann.getRef(), query, case_sensitive, partial ) ) { + if ( match( ann.getRef(), query, case_sensitive, partial, false ) ) { match = true; break; } @@ -1169,15 +1188,15 @@ public class PhylogenyMethods { if ( !match && node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getCrossReferences() != null ) ) { for( final Accession x : node.getNodeData().getSequence().getCrossReferences() ) { - if ( match( x.getComment(), query, case_sensitive, partial ) ) { + if ( match( x.getComment(), query, case_sensitive, partial, false ) ) { match = true; break; } - if ( match( x.getSource(), query, case_sensitive, partial ) ) { + if ( match( x.getSource(), query, case_sensitive, partial, false ) ) { match = true; break; } - if ( match( x.getValue(), query, case_sensitive, partial ) ) { + if ( match( x.getValue(), query, case_sensitive, partial, false ) ) { match = true; break; } @@ -1187,14 +1206,14 @@ public class PhylogenyMethods { if ( !match && ( node.getNodeData().getBinaryCharacters() != null ) ) { Iterator it = node.getNodeData().getBinaryCharacters().getPresentCharacters().iterator(); I: while ( it.hasNext() ) { - if ( match( it.next(), query, case_sensitive, partial ) ) { + if ( match( it.next(), query, case_sensitive, partial, false ) ) { match = true; break I; } } it = node.getNodeData().getBinaryCharacters().getGainedCharacters().iterator(); I: while ( it.hasNext() ) { - if ( match( it.next(), query, case_sensitive, partial ) ) { + if ( match( it.next(), query, case_sensitive, partial, false ) ) { match = true; break I; } @@ -1618,16 +1637,8 @@ public class PhylogenyMethods { private static boolean match( final String s, final String query, final boolean case_sensitive, - final boolean partial ) { - return match( s, query, case_sensitive, partial, false ); - } - - private static boolean match( final String s, - final String query, - final boolean case_sensitive, final boolean partial, final boolean regex ) { - if ( ForesterUtil.isEmpty( s ) || ForesterUtil.isEmpty( query ) ) { return false; } @@ -1648,13 +1659,13 @@ public class PhylogenyMethods { } } catch ( final PatternSyntaxException e ) { - throw e; + return false; } if ( p != null ) { return p.matcher( my_s ).find(); } else { - throw new RuntimeException( "failed to create new pattern" ); + return false; } } else if ( partial ) { -- 1.7.10.2