/*
* find all matches should return seq1 and seq4 (others are too short)
+ * (and not matches in sequence ids)
*/
f = new Finder(av);
+ String name = al.getSequenceAt(0).getName();
+ al.getSequenceAt(0).setName("Q9XA0");
f.findAll("9", false, false, false);
sr = f.getSearchResults();
assertEquals(sr.getSize(), 2);
assertEquals(matches.get(0).getEnd(), 9);
assertEquals(matches.get(1).getStart(), 9);
assertEquals(matches.get(1).getEnd(), 9);
+ al.getSequenceAt(0).setName(name);
/*
* parsing of search string as integer is strict
* Test finding all matches, case-sensitive
*/
@Test(groups = "Functional")
- public void testFind_findAllCaseSensitive()
+ public void testFindAll_caseSensitive()
{
Finder f = new Finder(av);
assertEquals(match.getStart(), 7);
assertEquals(match.getEnd(), 7);
}
+
+ @Test(groups = "Functional")
+ public void testFind_skipHiddenColumns()
+ {
+ /*
+ * 0 5 9
+ * ABCD--EF-GHI
+ * A--BCDefHI
+ * --bcdEFH
+ * aa---aMMMMMaaa
+ */
+ HiddenColumns hc = new HiddenColumns();
+ hc.hideColumns(2, 4);
+ hc.hideColumns(7, 7);
+ al.setHiddenColumns(hc);
+
+ /*
+ * now have
+ * 015689
+ * AB-E-GHI
+ * A-DeHI
+ * --EF
+ * aaaMMMMaaa
+ */
+ Finder f = new Finder(av);
+ f.findAll("abe", false, false, true); // true = ignore hidden
+ SearchResultsI searchResults = f.getSearchResults();
+
+ /*
+ * match of seq1 ABE made up of AB and E
+ */
+ assertEquals(searchResults.getSize(), 2);
+ SearchResultMatchI match = searchResults.getResults().get(0);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 8); // A
+ assertEquals(match.getEnd(), 9); // B
+ match = searchResults.getResults().get(1);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 12); // E
+ assertEquals(match.getEnd(), 12);
+
+ f = new Finder(av);
+ f.findNext("a.E", false, false, true);
+ searchResults = f.getSearchResults();
+ assertEquals(searchResults.getSize(), 2);
+ match = searchResults.getResults().get(0);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 8); // A
+ assertEquals(match.getEnd(), 9); // B
+ match = searchResults.getResults().get(1);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 12); // E
+ assertEquals(match.getEnd(), 12);
+
+ f.findNext("a.E", false, false, true);
+ searchResults = f.getSearchResults();
+ assertEquals(searchResults.getSize(), 2);
+ match = searchResults.getResults().get(0);
+ assertSame(match.getSequence(), al.getSequenceAt(1));
+ assertEquals(match.getStart(), 1); // a
+ assertEquals(match.getEnd(), 1);
+ match = searchResults.getResults().get(1);
+ assertSame(match.getSequence(), al.getSequenceAt(1));
+ assertEquals(match.getStart(), 4); // D
+ assertEquals(match.getEnd(), 5); // e
+
+ /*
+ * find all matching across two hidden column regions
+ * note one 'match' is reported as three contiguous matches
+ */
+ f.findAll("BEG", false, false, true);
+ searchResults = f.getSearchResults();
+ assertEquals(searchResults.getSize(), 3);
+ match = searchResults.getResults().get(0);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 9); // B
+ assertEquals(match.getEnd(), 9);
+ match = searchResults.getResults().get(1);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 12); // E
+ assertEquals(match.getEnd(), 12);
+ match = searchResults.getResults().get(2);
+ assertSame(match.getSequence(), al.getSequenceAt(0));
+ assertEquals(match.getStart(), 14); // G
+ assertEquals(match.getEnd(), 14);
+ }
}