- if (regex.searchFrom(noGaps, r))
- {
- resIndex = regex.matchedFrom();
-
- if ((selection != null && selection.getSize() > 0)
- && ((resIndex + Integer.parseInt(spaces.elementAt(
- resIndex).toString())) < selection.getStartRes()))
- {
- continue;
- }
- // if invalid string used, then regex has no matched to/from
- int sres = seq
- .findPosition(resIndex
- + Integer.parseInt(spaces.elementAt(resIndex)
- .toString()));
- int eres = seq.findPosition(regex.matchedTo()
- - 1
- + Integer.parseInt(spaces
- .elementAt(regex.matchedTo() - 1).toString()));
- // only add result if not contained in previous result
- if (lastm == null
- || (lastm.getSequence() != seq || (!(lastm.getStart() <= sres && lastm
- .getEnd() >= eres))))
- {
- lastm = searchResults.addResult(seq, sres, eres);
- }
- hasResults = true;
- if (!findAll)
- {
- // thats enough, break and display the result
- found = true;
- resIndex++;
-
- break;
- }
-
- r = resIndex;
- }
- else
- {
- break;
- }
- }
+ /**
+ * Finds the next match in the given sequence, starting at column at
+ * <code>columnIndex</code>. Answers true if a match is found, else false. If
+ * a match is found, <code>columnIndex</code> is advanced to the column after
+ * the start of the matched region, ready for a search from the next position.
+ *
+ * @param seq
+ * @param searchString
+ * @param searchPattern
+ * @param matchDescription
+ * @return
+ */
+ protected boolean findNextMatch(SequenceI seq, String searchString,
+ Regex searchPattern, boolean matchDescription)
+ {
+ SequenceGroup selection = viewport.getSelectionGroup();
+ if (selection != null && !selection.contains(seq))
+ {
+ /*
+ * this sequence is not in the selection - advance to next sequence
+ */
+ return false;
+ }