import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
+import java.util.List;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
import jalview.api.AlignViewportI;
import jalview.api.FinderI;
import jalview.bin.Cache;
import jalview.gui.JvOptionPane;
import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-
-import java.util.List;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
import junit.extensions.PA;
public class FinderTest
* find next match only
*/
Finder f = new Finder(av);
- f.findNext("E.H", false, false, false); // 'E, any character, H'
+ f.findNext("E.H", false, false, false, false); // 'E, any character, H'
// should match seq2 efH only
SearchResultsI sr = f.getSearchResults();
assertEquals(sr.getCount(), 1);
assertEquals(matches.get(0).getEnd(), 7);
f = new Finder(av);
- f.findAll("E.H", false, false, false); // 'E, any character, H'
+ f.findAll("E.H", false, false, false, false); // 'E, any character, H'
// should match seq2 efH and seq3 EFH
sr = f.getSearchResults();
assertEquals(sr.getCount(), 2);
* single symbol should find *all* matching symbols
*/
Finder f = new Finder(av);
- f.findAll("M", false, false, false);
+ f.findAll("M", false, false, false, false);
SearchResultsI sr = f.getSearchResults();
assertEquals(sr.getCount(), 5);
/*
* find first match should return seq1 residue 9
*/
- f.findNext("9", false, false, false);
+ f.findNext("9", false, false, false, false);
SearchResultsI sr = f.getSearchResults();
assertEquals(sr.getCount(), 1);
List<SearchResultMatchI> matches = sr.getResults();
f = new Finder(av);
String name = al.getSequenceAt(0).getName();
al.getSequenceAt(0).setName("Q9XA0");
- f.findAll("9", false, false, false);
+ f.findAll("9", false, false, false, false);
sr = f.getSearchResults();
assertEquals(sr.getCount(), 2);
matches = sr.getResults();
* parsing of search string as integer is strict
*/
f = new Finder(av);
- f.findNext(" 9", false, false, false);
+ f.findNext(" 9", false, false, false, false);
assertTrue(f.getSearchResults().isEmpty());
}
Finder f = new Finder(av);
PA.setValue(f, "sequenceIndex", 1);
PA.setValue(f, "residueIndex", -1);
- f.findNext("e", false, false, false); // matches id
+ f.findNext("e", false, false, false, false); // matches id
assertTrue(f.getSearchResults().isEmpty());
assertEquals(f.getIdMatches().size(), 1);
f = new Finder(av);
PA.setValue(f, "sequenceIndex", 1);
PA.setValue(f, "residueIndex", 0);
- f.findNext("e", false, false, false); // matches in sequence
+ f.findNext("e", false, false, false, false); // matches in sequence
assertTrue(f.getIdMatches().isEmpty());
assertEquals(f.getSearchResults().getCount(), 1);
List<SearchResultMatchI> matches = f.getSearchResults().getResults();
f = new Finder(av);
PA.setValue(f, "sequenceIndex", 1);
PA.setValue(f, "residueIndex", 7);
- f.findNext("e", false, false, false);
+ f.findNext("e", false, false, false, false);
assertEquals(f.getIdMatches().size(), 1);
assertSame(f.getIdMatches().get(0), al.getSequenceAt(2));
assertTrue(f.getSearchResults().isEmpty());
* find first match only
*/
Finder f = new Finder(av2);
- f.findNext("rAF", false, true, false);
+ f.findNext("rAF", false, true, false, false);
assertEquals(f.getIdMatches().size(), 1);
assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0));
assertTrue(f.getSearchResults().isEmpty());
* find all matches
*/
f = new Finder(av2);
- f.findAll("rAF", false, true, false);
+ f.findAll("rAF", false, true, false, false);
assertEquals(f.getIdMatches().size(), 2);
assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0));
assertSame(f.getIdMatches().get(1), al2.getSequenceAt(1));
* case sensitive
*/
f = new Finder(av2);
- f.findAll("RAF", true, true, false);
+ f.findAll("RAF", true, true, false, false);
assertEquals(f.getIdMatches().size(), 1);
assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0));
assertTrue(f.getSearchResults().isEmpty());
/*
* sequence matches should have no duplicates
*/
- f.findAll("EFH", false, true, false);
+ f.findAll("EFH", false, true, false, false);
assertEquals(f.getIdMatches().size(), 2);
assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0));
assertSame(f.getIdMatches().get(1), al2.getSequenceAt(1));
* case insensitive; seq1 occurs twice in sequence id but
* only one match should be returned
*/
- f.findAll("SEQ1", false, false, false);
+ f.findAll("SEQ1", false, false, false, false);
assertEquals(f.getIdMatches().size(), 1);
assertSame(f.getIdMatches().get(0), al.getSequenceAt(0));
SearchResultsI searchResults = f.getSearchResults();
* case sensitive
*/
f = new Finder(av);
- f.findAll("SEQ1", true, false, false);
+ f.findAll("SEQ1", true, false, false, false);
searchResults = f.getSearchResults();
assertTrue(searchResults.isEmpty());
AlignViewportI av2 = new AlignViewport(al2);
al2.addSequence(new Sequence("aBz", "xyzabZpqrAbZ"));
f = new Finder(av2);
- f.findAll("ABZ", false, false, false);
+ f.findAll("ABZ", false, false, false, false);
assertEquals(f.getIdMatches().size(), 1);
assertSame(f.getIdMatches().get(0), al2.getSequenceAt(4));
searchResults = f.getSearchResults();
* efh should be matched in seq2 only
*/
FinderI f = new Finder(av);
- f.findNext("EfH", false, false, false);
+ f.findNext("EfH", false, false, false, false);
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
SearchResultMatchI match = searchResults.getResults().get(0);
* I should be found in seq1 (twice) and seq2 (once)
*/
f = new Finder(av);
- f.findNext("I", false, false, false); // find next: seq1/16
+ f.findNext("I", false, false, false, false); // find next: seq1/16
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
assertEquals(match.getStart(), 16);
assertEquals(match.getEnd(), 16);
- f.findNext("I", false, false, false); // find next: seq1/18
+ f.findNext("I", false, false, false, false); // find next: seq1/18
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
assertEquals(match.getStart(), 18);
assertEquals(match.getEnd(), 18);
- f.findNext("I", false, false, false); // find next: seq2/8
+ f.findNext("I", false, false, false, false); // find next: seq2/8
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
assertEquals(match.getStart(), 8);
assertEquals(match.getEnd(), 8);
- f.findNext("I", false, false, false);
+ f.findNext("I", false, false, false, false);
assertTrue(f.getSearchResults().isEmpty());
/*
* find should reset to start of alignment after a failed search
*/
- f.findNext("I", false, false, false); // find next: seq1/16
+ f.findNext("I", false, false, false, false); // find next: seq1/16
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
public void testFindAll_maximalResultOnly()
{
Finder f = new Finder(av);
- f.findAll("M+", false, false, false);
+ f.findAll("M+", false, false, false, false);
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
SearchResultMatchI match = searchResults.getResults().get(0);
public void testFindAll()
{
Finder f = new Finder(av);
- f.findAll("EfH", false, false, false);
+ f.findAll("EfH", false, false, false, false);
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
SearchResultMatchI match = searchResults.getResults().get(0);
/*
* find all I should find 2 positions in seq1, 1 in seq2
*/
- f.findAll("I", false, false, false);
+ f.findAll("I", false, false, false, false);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 3);
match = searchResults.getResults().get(0);
/*
* BC should match seq1/9-10 and seq2/2-3
*/
- f.findAll("BC", true, false, false);
+ f.findAll("BC", true, false, false, false);
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
SearchResultMatchI match = searchResults.getResults().get(0);
* bc should match seq3/1-2
*/
f = new Finder(av);
- f.findAll("bc", true, false, false);
+ f.findAll("bc", true, false, false, false);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
assertEquals(match.getStart(), 1);
assertEquals(match.getEnd(), 2);
- f.findAll("bC", true, false, false);
+ f.findAll("bC", true, false, false, false);
assertTrue(f.getSearchResults().isEmpty());
}
av.setSelectionGroup(sg);
FinderI f = new Finder(av);
- f.findNext("b", false, false, false);
+ f.findNext("b", false, false, false, false);
assertTrue(f.getIdMatches().isEmpty());
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
/*
* a second Find should not return the 'b' in seq3 as outside the selection
*/
- f.findNext("b", false, false, false);
+ f.findNext("b", false, false, false, false);
assertTrue(f.getSearchResults().isEmpty());
assertTrue(f.getIdMatches().isEmpty());
f = new Finder(av);
- f.findNext("d", false, false, false);
+ f.findNext("d", false, false, false, false);
assertTrue(f.getIdMatches().isEmpty());
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
assertSame(match.getSequence(), al.getSequenceAt(1));
assertEquals(match.getStart(), 4);
assertEquals(match.getEnd(), 4);
- f.findNext("d", false, false, false);
+ f.findNext("d", false, false, false, false);
assertTrue(f.getIdMatches().isEmpty());
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
* search for 'e' should match two sequence ids and one residue
*/
Finder f = new Finder(av);
- f.findAll("e", false, false, false);
+ f.findAll("e", false, false, false, false);
assertEquals(f.getIdMatches().size(), 2);
assertSame(f.getIdMatches().get(0), al.getSequenceAt(1));
assertSame(f.getIdMatches().get(1), al.getSequenceAt(2));
* search for 'Q' should match two sequence ids only
*/
f = new Finder(av);
- f.findAll("Q", false, false, false);
+ f.findAll("Q", false, false, false, false);
assertEquals(f.getIdMatches().size(), 2);
assertSame(f.getIdMatches().get(0), al.getSequenceAt(1));
assertSame(f.getIdMatches().get(1), al.getSequenceAt(2));
* search for 'I' should match two sequence positions
*/
Finder f = new Finder(av);
- f.findAll("I", false, false, false);
+ f.findAll("I", false, false, false, false);
assertTrue(f.getIdMatches().isEmpty());
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
hc.hideColumns(3, 3);
al.setHiddenColumns(hc);
Finder f = new Finder(av);
- f.findAll("aaa", false, false, false);
+ f.findAll("aaa", false, false, false, false);
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
SearchResultMatchI match = searchResults.getResults().get(0);
* find the visible D in seq2
*/
f = new Finder(av);
- f.findAll("D", false, false, false);
+ f.findAll("D", false, false, false, false);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
* consecutive in the visible columns
*/
f = new Finder(av);
- f.findAll("AD", false, false, false);
+ f.findAll("AD", false, false, false, false);
searchResults = f.getSearchResults();
assertTrue(searchResults.isEmpty());
* (first run includes hidden gaps)
*/
f = new Finder(av);
- f.findAll("aaa", false, false, false);
+ f.findAll("aaa", false, false, false, false);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
match = searchResults.getResults().get(0);
*/
hc.hideColumns(2, 5);
f = new Finder(av);
- f.findAll("aaa", false, false, false);
+ f.findAll("aaa", false, false, false, false);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
match = searchResults.getResults().get(0);
/*
* find all 'BE' should not match across hidden columns in seq1
*/
- f.findAll("BE", false, false, false);
+ f.findAll("BE", false, false, false, false);
assertTrue(f.getSearchResults().isEmpty());
/*
hc.revealAllHiddenColumns(new ColumnSelection());
hc.hideColumns(8, 13);
f = new Finder(av);
- f.findNext("H", false, false, false);
+ f.findNext("H", false, false, false, false);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
match = searchResults.getResults().get(0);
* should match seq2/1, seq2/7, not seq3/6
*/
Finder f = new Finder(av);
- f.findAll("[AH]", false, false, false);
+ f.findAll("[AH]", false, false, false, false);
SearchResultsI searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 2);
SearchResultMatchI match = searchResults.getResults().get(0);
* aaaMMMMaaa
*/
Finder f = new Finder(av);
- f.findAll("abe", false, false, true); // true = ignore hidden
+ f.findAll("abe", false, false, false, true); // true = ignore hidden
SearchResultsI searchResults = f.getSearchResults();
/*
assertEquals(match.getEnd(), 12);
f = new Finder(av);
- f.findNext("a.E", false, false, true);
+ f.findNext("a.E", false, false, false, true);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
assertEquals(searchResults.getResults().size(), 2);
assertEquals(match.getStart(), 12); // E
assertEquals(match.getEnd(), 12);
- f.findNext("a.E", false, false, true);
+ f.findNext("a.E", false, false, false, true);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
assertEquals(searchResults.getResults().size(), 2);
* find all matching across two hidden column regions
* note one 'match' is returned as three contiguous matches
*/
- f.findAll("BEG", false, false, true);
+ f.findAll("BEG", false, false, false, true);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
assertEquals(searchResults.getResults().size(), 3);
selection.setEndRes(9);
al.getSequences().forEach(seq -> selection.addSequence(seq, false));
av.setSelectionGroup(selection);
- f.findAll("A.*H", false, false, true);
+ f.findAll("A.*H", false, false, false, true);
searchResults = f.getSearchResults();
assertEquals(searchResults.getCount(), 1);
assertEquals(searchResults.getResults().size(), 3);