+ * Searches for a match with the sequence features, and if found, adds the
+ * sequence to the list of match ids, (but not as a duplicate). Answers true
+ * if a match was added, else false.
+ *
+ * @param seq
+ * @param searchPattern
+ * @return
+ */
+ protected boolean searchSequenceFeatures(int from, Regex searchPattern)
+ {
+ if (lastFeatureSequenceIndex != sequenceIndex)
+ {
+ lastFeatureSequenceIndex = sequenceIndex;
+ lastFeature = null;
+ }
+ SequenceI seq = viewport.getAlignment().getSequenceAt(sequenceIndex);
+ SequenceFeaturesI sf = seq.getFeatures();
+
+ // TODO - stash feature list and search incrementally
+ List<SequenceFeature> allFeatures = null;
+ if (frm != null)
+ {
+ allFeatures = frm.findFeaturesAtResidue(seq, seq.getStart(),
+ seq.getEnd());
+ }
+ else
+ {
+ allFeatures = sf.getAllFeatures(null);
+ }
+ // so we can check we are advancing when debugging
+ long fpos = 0;
+
+ for (SequenceFeature feature : allFeatures)
+ {
+ fpos++;
+ if (lastFeature != null)
+ {
+ // iterate till we find last feature matched
+ if (lastFeature != feature)
+ {
+ continue;
+ }
+ else
+ {
+ lastFeature = null;
+ continue;
+ }
+ }
+
+ if (searchPattern.search(feature.type) || (feature.description != null
+ && searchPattern.search(feature.description)))
+ {
+ searchResults.addResult(seq, feature.getBegin(), feature.getEnd());
+ lastFeature = feature;
+ return true;
+ }
+ }
+ residueIndex = Integer.MAX_VALUE;
+ lastFeature = null;
+ return false;
+ }
+
+ /**