JAL-4061 JAL-4062 Find can now search features
[jalview.git] / src / jalview / api / FinderI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package jalview.api;
22
23 import java.util.List;
24
25 import jalview.datamodel.SearchResultsI;
26 import jalview.datamodel.SequenceI;
27
28 /**
29  * An interface for searching for a pattern in an aligment
30  */
31 public interface FinderI
32 {
33
34   /**
35    * Performs a find for the given search string (interpreted as a regular
36    * expression). Search may optionally be case-sensitive, and may optionally
37    * including match in sequence description (sequence id is always searched).
38    * If the viewport has an active selection, then the find is restricted to the
39    * selection region. Sequences matched by id or description can be retrieved
40    * by getIdMatches(), and matched residue patterns by getSearchResults().
41    * <p>
42    * If {@code ignoreHidden} is true, then any residues in hidden columns are
43    * ignored (skipped) when matching, so for example pattern {@code KRT} would
44    * match sequence {@code KRqmT} (where {@code qm} are in hidden columns).
45    * <p>
46    * Matches of entirely hidden patterns are not returned. Matches that span
47    * hidden regions on one or both sides may be returned.
48    * 
49    * @param theSearchString
50    * @param caseSensitive
51    * @param searchDescription
52    * @param searchFeatureDesc
53    * @param ignoreHidden
54    * @return
55    */
56   void findAll(String theSearchString, boolean caseSensitive,
57           boolean searchDescription, boolean searchFeatureDesc,
58           boolean ignoreHidden);
59
60   /**
61    * Finds the next match for the given search string (interpreted as a regular
62    * expression), starting from the position after the last match found. Search
63    * may optionally be case-sensitive, and may optionally including match in
64    * sequence description (sequence id is always searched). If the viewport has
65    * an active selection, then the find is restricted to the selection region.
66    * Sequences matched by id or description can be retrieved by getIdMatches(),
67    * and matched residue patterns by getSearchResults().
68    * <p>
69    * If {@code ignoreHidden} is true, any hidden residues are skipped (matches
70    * may span them). If false, they are included for matching purposes. In
71    * either cases, entirely hidden matches are not returned.
72    * 
73    * @param theSearchString
74    * @param caseSensitive
75    * @param searchDescription
76    * @param searchFeatureDesc
77    * @param ignoreHidden
78    * @return
79    */
80   void findNext(String theSearchString, boolean caseSensitive,
81           boolean searchDescription, boolean searchFeatureDesc,
82           boolean ignoreHidden);
83
84   /**
85    * Returns the (possibly empty) list of sequences matched on sequence name or
86    * description
87    * 
88    * @return
89    */
90   List<SequenceI> getIdMatches();
91
92   /**
93    * Answers the search results (possibly empty) from the last search
94    * 
95    * @return
96    */
97   SearchResultsI getSearchResults();
98
99 }