{
if (matchFeatureDesc)
{
+ // TODO - record last matched
matched = searchSequenceFeatures(residueIndex, searchPattern);
}
residueIndex = Integer.MAX_VALUE;
* sequence to the list of match ids, (but not as a duplicate). Answers true
* if a match was added, else false.
*
+ * TODO: allow incremental searching (ie next feature matched after last)
+ *
* @param seq
* @param searchPattern
* @return
if (searchPattern.search(feature.type) || (feature.description != null
&& searchPattern.search(feature.description)))
{
- searchResults.addResult(seq, seq.findIndex(feature.getBegin()),
- seq.findIndex(feature.getEnd()));
+ searchResults.addResult(seq, feature.getBegin(), feature.getEnd());
matched = true;
}
}
import jalview.datamodel.SearchResultMatchI;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
import jalview.gui.JvOptionPane;
DataSourceType.PASTE);
av = af.getViewport();
al = av.getAlignment();
+ al.getSequenceAt(0).addSequenceFeature(
+ new SequenceFeature("BBBB", "FeatureB", 9, 11, ""));
+ al.getSequenceAt(3).addSequenceFeature(
+ new SequenceFeature("BBAB", "FeatureA", 1, 3, ""));
+ al.getSequenceAt(3).addSequenceFeature(
+ new SequenceFeature("AAAA", "FeatureA", 9, 11, ""));
}
@AfterMethod(alwaysRun = true)
assertEquals(match.getStart(), 7); // H (there is no G)
assertEquals(match.getEnd(), 7);
}
+
+ @Test(groups = "Functional")
+ public void testFind_featuresOnly()
+ {
+ Finder f = new Finder(av);
+ // no match when not searching feature descriptions
+ f.findAll("Feature", false, false, false, true);
+ assertEquals(f.getSearchResults().getCount(), 0);
+
+ // no match when case sensitive on feature descriptions
+ f.findAll("feature", true, false, true, true);
+ assertEquals(f.getSearchResults().getCount(), 0);
+
+ // search feature descriptions - all match
+ f.findAll("Feature", false, false, true, true);
+ assertEquals(f.getSearchResults().getCount(), 3);
+
+ List<SequenceI> seqs = f.getSearchResults().getMatchingSubSequences();
+ // assume order is preserved in results
+ assertEquals(al.getSequenceAt(0).getDatasetSequence(),
+ seqs.get(0).getDatasetSequence());
+ assertEquals(seqs.get(0).getStart(), 9);
+ assertEquals(seqs.get(0).getEnd(), 11);
+ assertEquals(al.getSequenceAt(3).getDatasetSequence(),
+ seqs.get(1).getDatasetSequence());
+ assertEquals(seqs.get(1).getStart(), 9);
+ assertEquals(seqs.get(1).getEnd(), 11);
+ assertEquals(al.getSequenceAt(3).getDatasetSequence(),
+ seqs.get(2).getDatasetSequence());
+ assertEquals(seqs.get(2).getStart(), 1);
+ assertEquals(seqs.get(2).getEnd(), 3);
+ }
}