From 9b5106c49c8fa0a7269f38ad1825851eb8ba5b85 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 14 Mar 2018 13:52:41 +0000 Subject: [PATCH] JAL-2933 pass viewport in Finder constructor, find acts on viewport selection if any --- src/jalview/analysis/Finder.java | 44 +++--- src/jalview/api/FinderI.java | 20 ++- src/jalview/appletgui/Finder.java | 10 +- src/jalview/gui/Finder.java | 10 +- test/jalview/analysis/FinderTest.java | 161 +++++++++++--------- .../controller/AlignViewControllerTest.java | 4 +- 6 files changed, 128 insertions(+), 121 deletions(-) diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 0996830..3cbef6d 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -20,6 +20,7 @@ */ package jalview.analysis; +import jalview.api.AlignViewportI; import jalview.api.FinderI; import jalview.datamodel.AlignmentI; import jalview.datamodel.Range; @@ -52,14 +53,9 @@ public class Finder implements FinderI private Vector idMatches; /* - * the alignment to search over + * the viewport to search over */ - private AlignmentI alignment; - - /* - * (optional) selection to restrict search to - */ - private SequenceGroup selection; + private AlignViewportI viewport; /* * sequence index in alignment to search from @@ -74,20 +70,20 @@ public class Finder implements FinderI private int columnIndex; /** - * Constructor for searching an alignment + * Constructor for searching a viewport * - * @param al + * @param av */ - public Finder(AlignmentI al) + public Finder(AlignViewportI av) { - this.alignment = al; + this.viewport = av; this.sequenceIndex = 0; this.columnIndex = -1; } @Override - public void findAll(String theSearchString, SequenceGroup sg, - boolean matchCase, boolean searchDescription) + public void findAll(String theSearchString, boolean matchCase, + boolean searchDescription) { /* * search from the start @@ -95,7 +91,7 @@ public class Finder implements FinderI sequenceIndex = 0; columnIndex = -1; - doFind(theSearchString, sg, matchCase, searchDescription, true); + doFind(theSearchString, matchCase, searchDescription, true); /* * reset to start for next search @@ -105,10 +101,10 @@ public class Finder implements FinderI } @Override - public void findNext(String theSearchString, SequenceGroup sg, - boolean matchCase, boolean searchDescription) + public void findNext(String theSearchString, boolean matchCase, + boolean searchDescription) { - doFind(theSearchString, sg, matchCase, searchDescription, false); + doFind(theSearchString, matchCase, searchDescription, false); if (searchResults.isEmpty() && idMatches.isEmpty()) { @@ -121,19 +117,16 @@ public class Finder implements FinderI } /** - * Performs a 'find next' or 'find all', optionally restricted to the - * specified selection region + * Performs a 'find next' or 'find all' * * @param theSearchString - * @param selectionRegion * @param matchCase * @param searchDescription * @param findAll */ - protected void doFind(String theSearchString, SequenceGroup selectionRegion, - boolean matchCase, boolean searchDescription, boolean findAll) + protected void doFind(String theSearchString, boolean matchCase, + boolean searchDescription, boolean findAll) { - this.selection = selectionRegion; String searchString = matchCase ? theSearchString : theSearchString.toUpperCase(); Regex searchPattern = new Regex(searchString); @@ -142,11 +135,13 @@ public class Finder implements FinderI searchResults = new SearchResults(); idMatches = new Vector<>(); + SequenceGroup selection = viewport.getSelectionGroup(); if (selection != null && selection.getSize() < 1) { selection = null; // ? ignore column-only selection } + AlignmentI alignment = viewport.getAlignment(); int end = alignment.getHeight(); while (sequenceIndex < end) @@ -184,6 +179,7 @@ public class Finder implements FinderI * restrict search to (next) visible column region, * in case there are hidden columns */ + AlignmentI alignment = viewport.getAlignment(); VisibleContigsIterator visibleRegions = alignment.getHiddenColumns() .getVisContigsIterator(column, alignment.getWidth(), false); @@ -199,6 +195,7 @@ public class Finder implements FinderI /* * restrict search to selected region if there is one */ + SequenceGroup selection = viewport.getSelectionGroup(); if (selection != null) { int selectionStart = selection.getStartRes(); @@ -233,6 +230,7 @@ public class Finder implements FinderI protected boolean findNextMatch(SequenceI seq, String searchString, Regex searchPattern, boolean matchDescription) { + SequenceGroup selection = viewport.getSelectionGroup(); if (selection != null && !selection.contains(seq)) { /* diff --git a/src/jalview/api/FinderI.java b/src/jalview/api/FinderI.java index a1a3efd..19f6136 100644 --- a/src/jalview/api/FinderI.java +++ b/src/jalview/api/FinderI.java @@ -1,7 +1,6 @@ package jalview.api; import jalview.datamodel.SearchResultsI; -import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import java.util.List; @@ -16,7 +15,7 @@ public interface FinderI * Performs a find for the given search string (interpreted as a regular * expression). Search may optionally be case-sensitive, and may optionally * including match in sequence description (sequence id is always searched). - * If selection is not null, then the find is restricted to the + * If the viewport has an active selection, then the find is restricted to the * selection region. Sequences matched by id or description can be retrieved * by getIdMatches(), and matched residue patterns by getSearchResults(). * @@ -25,26 +24,25 @@ public interface FinderI * @param searchDescription * @return */ - void findAll(String theSearchString, SequenceGroup selection, - boolean caseSensitive, boolean searchDescription); + void findAll(String theSearchString, boolean caseSensitive, + boolean searchDescription); /** * Finds the next match for the given search string (interpreted as a regular * expression), starting from the position after the last match found. Search * may optionally be case-sensitive, and may optionally including match in - * sequence description (sequence id is always searched). If - * selection is not null, then the find is restricted to the - * selection region. Sequences matched by id or description can be retrieved - * by getIdMatches(), and matched residue patterns by getSearchResults(). + * sequence description (sequence id is always searched). If the viewport has + * an active selection, then the find is restricted to the selection region. + * Sequences matched by id or description can be retrieved by getIdMatches(), + * and matched residue patterns by getSearchResults(). * * @param theSearchString - * @param selection * @param caseSensitive * @param searchDescription * @return */ - void findNext(String theSearchString, SequenceGroup selection, - boolean caseSensitive, boolean searchDescription); + void findNext(String theSearchString, boolean caseSensitive, + boolean searchDescription); /** * Returns the (possibly empty) list of sequences matched on sequence name or diff --git a/src/jalview/appletgui/Finder.java b/src/jalview/appletgui/Finder.java index 4b55574..2fc3441 100644 --- a/src/jalview/appletgui/Finder.java +++ b/src/jalview/appletgui/Finder.java @@ -25,7 +25,6 @@ import jalview.api.FinderI; import jalview.datamodel.SearchResultMatchI; import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.util.MessageManager; @@ -163,23 +162,20 @@ public class Finder extends Panel implements ActionListener /* * first time we searched this viewport */ - finder = new jalview.analysis.Finder(av.getAlignment()); + finder = new jalview.analysis.Finder(av); finders.put(av, finder); } String searchString = textfield.getText(); - SequenceGroup selectionGroup = av.getSelectionGroup(); boolean isCaseSensitive = caseSensitive.getState(); boolean doSearchDescription = searchDescription.getState(); if (doFindAll) { - finder.findAll(searchString, selectionGroup, isCaseSensitive, - doSearchDescription); + finder.findAll(searchString, isCaseSensitive, doSearchDescription); } else { - finder.findNext(searchString, selectionGroup, isCaseSensitive, - doSearchDescription); + finder.findNext(searchString, isCaseSensitive, doSearchDescription); } searchResults = finder.getSearchResults(); diff --git a/src/jalview/gui/Finder.java b/src/jalview/gui/Finder.java index dcc3518..a4d7ad0 100755 --- a/src/jalview/gui/Finder.java +++ b/src/jalview/gui/Finder.java @@ -25,7 +25,6 @@ import jalview.api.FinderI; import jalview.datamodel.SearchResultMatchI; import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.jbgui.GFinder; import jalview.util.MessageManager; @@ -269,22 +268,19 @@ public class Finder extends GFinder /* * first time we've searched this viewport */ - finder = new jalview.analysis.Finder(av.getAlignment()); + finder = new jalview.analysis.Finder(av); finders.put(av, finder); } - SequenceGroup selectionGroup = av.getSelectionGroup(); boolean isCaseSensitive = caseSensitive.isSelected(); boolean doSearchDescription = searchDescription.isSelected(); if (doFindAll) { - finder.findAll(searchString, selectionGroup, isCaseSensitive, - doSearchDescription); + finder.findAll(searchString, isCaseSensitive, doSearchDescription); } else { - finder.findNext(searchString, selectionGroup, isCaseSensitive, - doSearchDescription); + finder.findNext(searchString, isCaseSensitive, doSearchDescription); } searchResults = finder.getSearchResults(); diff --git a/test/jalview/analysis/FinderTest.java b/test/jalview/analysis/FinderTest.java index e453dd3..e2a94ef 100644 --- a/test/jalview/analysis/FinderTest.java +++ b/test/jalview/analysis/FinderTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertSame; import static org.testng.Assert.assertTrue; +import jalview.api.AlignViewportI; import jalview.api.FinderI; import jalview.bin.Cache; import jalview.datamodel.Alignment; @@ -35,12 +36,14 @@ import jalview.datamodel.SearchResultsI; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.gui.AlignFrame; +import jalview.gui.AlignViewport; 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; @@ -59,6 +62,8 @@ public class FinderTest private AlignmentI al; + private AlignViewportI av; + @BeforeClass(groups = "Functional") public void setUp() { @@ -70,7 +75,14 @@ public class FinderTest + "seq3 --bcdEFH\n" + "seq4 aa---aMMMMMaaa\n"; af = new FileLoader().LoadFileWaitTillLoaded(seqData, DataSourceType.PASTE); - al = af.getViewport().getAlignment(); + av = af.getViewport(); + al = av.getAlignment(); + } + + @AfterMethod + public void tearDownAfterTest() + { + av.setSelectionGroup(null); } /** @@ -82,8 +94,8 @@ public class FinderTest /* * find next match only */ - Finder f = new Finder(al); - f.findNext("E.H", null, false, false); // 'E, any character, H' + Finder f = new Finder(av); + f.findNext("E.H", false, false); // 'E, any character, H' // should match seq2 efH only SearchResultsI sr = f.getSearchResults(); assertEquals(sr.getSize(), 1); @@ -92,8 +104,8 @@ public class FinderTest assertEquals(matches.get(0).getStart(), 5); assertEquals(matches.get(0).getEnd(), 7); - f = new Finder(al); - f.findAll("E.H", null, false, false); // 'E, any character, H' + f = new Finder(av); + f.findAll("E.H", false, false); // 'E, any character, H' // should match seq2 efH and seq3 EFH sr = f.getSearchResults(); assertEquals(sr.getSize(), 2); @@ -112,12 +124,12 @@ public class FinderTest @Test(groups = "Functional") public void testFind_residueNumber() { - Finder f = new Finder(al); + Finder f = new Finder(av); /* * find first match should return seq1 residue 9 */ - f.findNext("9", null, false, false); + f.findNext("9", false, false); SearchResultsI sr = f.getSearchResults(); assertEquals(sr.getSize(), 1); List matches = sr.getResults(); @@ -128,8 +140,8 @@ public class FinderTest /* * find all matches should return seq1 and seq4 (others are too short) */ - f = new Finder(al); - f.findAll("9", null, false, false); + f = new Finder(av); + f.findAll("9", false, false); sr = f.getSearchResults(); assertEquals(sr.getSize(), 2); matches = sr.getResults(); @@ -143,8 +155,8 @@ public class FinderTest /* * parsing of search string as integer is strict */ - f = new Finder(al); - f.findNext(" 9", null, false, false); + f = new Finder(av); + f.findNext(" 9", false, false); assertTrue(f.getSearchResults().isEmpty()); } @@ -158,10 +170,10 @@ public class FinderTest * start at second sequence; colIndex of -1 * means sequence id / description is searched */ - Finder f = new Finder(al); + Finder f = new Finder(av); PA.setValue(f, "sequenceIndex", 1); PA.setValue(f, "columnIndex", -1); - f.findNext("e", null, false, false); // matches id + f.findNext("e", false, false); // matches id assertTrue(f.getSearchResults().isEmpty()); assertEquals(f.getIdMatches().size(), 1); @@ -170,10 +182,10 @@ public class FinderTest // colIndex is now 0 - for use in next find next // searching A--BCDefHI assertEquals(PA.getValue(f, "columnIndex"), 0); - f = new Finder(al); + f = new Finder(av); PA.setValue(f, "sequenceIndex", 1); PA.setValue(f, "columnIndex", 0); - f.findNext("e", null, false, false); // matches in sequence + f.findNext("e", false, false); // matches in sequence assertTrue(f.getIdMatches().isEmpty()); assertEquals(f.getSearchResults().getSize(), 1); List matches = f.getSearchResults().getResults(); @@ -186,10 +198,10 @@ public class FinderTest assertEquals(PA.getValue(f, "columnIndex"), 7); // find next from end of sequence - finds next sequence id - f = new Finder(al); + f = new Finder(av); PA.setValue(f, "sequenceIndex", 1); PA.setValue(f, "columnIndex", 7); - f.findNext("e", null, false, false); + f.findNext("e", false, false); assertEquals(f.getIdMatches().size(), 1); assertSame(f.getIdMatches().get(0), al.getSequenceAt(2)); assertTrue(f.getSearchResults().isEmpty()); @@ -205,11 +217,13 @@ public class FinderTest al2.getSequenceAt(0).setDescription("BRAF"); al2.getSequenceAt(1).setDescription("braf"); + AlignViewportI av2 = new AlignViewport(al2); + /* * find first match only */ - Finder f = new Finder(al2); - f.findNext("rAF", null, false, true); + Finder f = new Finder(av2); + f.findNext("rAF", false, true); assertEquals(f.getIdMatches().size(), 1); assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0)); assertTrue(f.getSearchResults().isEmpty()); @@ -217,8 +231,8 @@ public class FinderTest /* * find all matches */ - f = new Finder(al2); - f.findAll("rAF", null, false, true); + f = new Finder(av2); + f.findAll("rAF", false, true); assertEquals(f.getIdMatches().size(), 2); assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0)); assertSame(f.getIdMatches().get(1), al2.getSequenceAt(1)); @@ -227,8 +241,8 @@ public class FinderTest /* * case sensitive */ - f = new Finder(al2); - f.findAll("RAF", null, true, true); + f = new Finder(av2); + f.findAll("RAF", true, true); assertEquals(f.getIdMatches().size(), 1); assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0)); assertTrue(f.getSearchResults().isEmpty()); @@ -239,12 +253,12 @@ public class FinderTest al2.getSequenceAt(0).setDescription("the efh sequence"); al2.getSequenceAt(0).setName("mouseEFHkinase"); al2.getSequenceAt(1).setName("humanEFHkinase"); - f = new Finder(al2); + f = new Finder(av2); /* * sequence matches should have no duplicates */ - f.findAll("EFH", null, false, true); + f.findAll("EFH", false, true); assertEquals(f.getIdMatches().size(), 2); assertSame(f.getIdMatches().get(0), al2.getSequenceAt(0)); assertSame(f.getIdMatches().get(1), al2.getSequenceAt(1)); @@ -266,13 +280,13 @@ public class FinderTest @Test(groups = "Functional") public void testFindAll_sequenceIds() { - Finder f = new Finder(al); + Finder f = new Finder(av); /* * case insensitive; seq1 occurs twice in sequence id but * only one match should be returned */ - f.findAll("SEQ1", null, false, false); + f.findAll("SEQ1", false, false); assertEquals(f.getIdMatches().size(), 1); assertSame(f.getIdMatches().get(0), al.getSequenceAt(0)); SearchResultsI searchResults = f.getSearchResults(); @@ -281,8 +295,8 @@ public class FinderTest /* * case sensitive */ - f = new Finder(al); - f.findAll("SEQ1", null, true, false); + f = new Finder(av); + f.findAll("SEQ1", true, false); searchResults = f.getSearchResults(); assertTrue(searchResults.isEmpty()); @@ -290,9 +304,10 @@ public class FinderTest * match both sequence id and sequence */ AlignmentI al2 = new Alignment(al); + AlignViewportI av2 = new AlignViewport(al2); al2.addSequence(new Sequence("aBz", "xyzabZpqrAbZ")); - f = new Finder(al2); - f.findAll("ABZ", null, false, false); + f = new Finder(av2); + f.findAll("ABZ", false, false); assertEquals(f.getIdMatches().size(), 1); assertSame(f.getIdMatches().get(0), al2.getSequenceAt(4)); searchResults = f.getSearchResults(); @@ -316,8 +331,8 @@ public class FinderTest /* * efh should be matched in seq2 only */ - FinderI f = new Finder(al); - f.findNext("EfH", null, false, false); + FinderI f = new Finder(av); + f.findNext("EfH", false, false); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); SearchResultMatchI match = searchResults.getResults().get(0); @@ -328,8 +343,8 @@ public class FinderTest /* * I should be found in seq1 (twice) and seq2 (once) */ - f = new Finder(al); - f.findNext("I", null, false, false); // find next: seq1/16 + f = new Finder(av); + f.findNext("I", false, false); // find next: seq1/16 searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -337,7 +352,7 @@ public class FinderTest assertEquals(match.getStart(), 16); assertEquals(match.getEnd(), 16); - f.findNext("I", null, false, false); // find next: seq1/18 + f.findNext("I", false, false); // find next: seq1/18 searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -345,7 +360,7 @@ public class FinderTest assertEquals(match.getStart(), 18); assertEquals(match.getEnd(), 18); - f.findNext("I", null, false, false); // find next: seq2/8 + f.findNext("I", false, false); // find next: seq2/8 searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -353,13 +368,13 @@ public class FinderTest assertEquals(match.getStart(), 8); assertEquals(match.getEnd(), 8); - f.findNext("I", null, false, false); + f.findNext("I", false, false); assertTrue(f.getSearchResults().isEmpty()); /* * find should reset to start of alignment after a failed search */ - f.findNext("I", null, false, false); // find next: seq1/16 + f.findNext("I", false, false); // find next: seq1/16 searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -375,8 +390,8 @@ public class FinderTest @Test(groups = "Functional") public void testFind_maximalResultOnly() { - Finder f = new Finder(al); - f.findAll("M+", null, false, false); + Finder f = new Finder(av); + f.findAll("M+", false, false); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); SearchResultMatchI match = searchResults.getResults().get(0); @@ -391,8 +406,8 @@ public class FinderTest @Test(groups = "Functional") public void testFind_findAll() { - Finder f = new Finder(al); - f.findAll("EfH", null, false, false); + Finder f = new Finder(av); + f.findAll("EfH", false, false); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 2); SearchResultMatchI match = searchResults.getResults().get(0); @@ -407,7 +422,7 @@ public class FinderTest /* * find all I should find 2 positions in seq1, 1 in seq2 */ - f.findAll("I", null, false, false); + f.findAll("I", false, false); searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 3); match = searchResults.getResults().get(0); @@ -430,12 +445,12 @@ public class FinderTest @Test(groups = "Functional") public void testFind_findAllCaseSensitive() { - Finder f = new Finder(al); + Finder f = new Finder(av); /* * BC should match seq1/9-10 and seq2/2-3 */ - f.findAll("BC", null, true, false); + f.findAll("BC", true, false); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 2); SearchResultMatchI match = searchResults.getResults().get(0); @@ -450,8 +465,8 @@ public class FinderTest /* * bc should match seq3/1-2 */ - f = new Finder(al); - f.findAll("bc", null, true, false); + f = new Finder(av); + f.findAll("bc", true, false); searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -459,7 +474,7 @@ public class FinderTest assertEquals(match.getStart(), 1); assertEquals(match.getEnd(), 2); - f.findAll("bC", null, true, false); + f.findAll("bC", true, false); assertTrue(f.getSearchResults().isEmpty()); } @@ -479,9 +494,10 @@ public class FinderTest sg.setEndRes(5); sg.addSequence(al.getSequenceAt(1), false); sg.addSequence(al.getSequenceAt(2), false); + av.setSelectionGroup(sg); - FinderI f = new Finder(al); - f.findNext("b", sg, false, false); + FinderI f = new Finder(av); + f.findNext("b", false, false); assertTrue(f.getIdMatches().isEmpty()); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); @@ -493,12 +509,12 @@ public class FinderTest /* * a second Find should not return the 'b' in seq3 as outside the selection */ - f.findNext("b", sg, false, false); + f.findNext("b", false, false); assertTrue(f.getSearchResults().isEmpty()); assertTrue(f.getIdMatches().isEmpty()); - f = new Finder(al); - f.findNext("d", sg, false, false); + f = new Finder(av); + f.findNext("d", false, false); assertTrue(f.getIdMatches().isEmpty()); searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); @@ -506,7 +522,7 @@ public class FinderTest assertSame(match.getSequence(), al.getSequenceAt(1)); assertEquals(match.getStart(), 4); assertEquals(match.getEnd(), 4); - f.findNext("d", sg, false, false); + f.findNext("d", false, false); assertTrue(f.getIdMatches().isEmpty()); searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); @@ -532,12 +548,13 @@ public class FinderTest sg.setEndRes(5); sg.addSequence(al.getSequenceAt(1), false); sg.addSequence(al.getSequenceAt(2), false); + av.setSelectionGroup(sg); /* * search for 'e' should match two sequence ids and one residue */ - Finder f = new Finder(al); - f.findAll("e", sg, false, false); + Finder f = new Finder(av); + f.findAll("e", false, false); assertEquals(f.getIdMatches().size(), 2); assertSame(f.getIdMatches().get(0), al.getSequenceAt(1)); assertSame(f.getIdMatches().get(1), al.getSequenceAt(2)); @@ -551,8 +568,8 @@ public class FinderTest /* * search for 'Q' should match two sequence ids only */ - f = new Finder(al); - f.findAll("Q", sg, false, false); + f = new Finder(av); + f.findAll("Q", false, false); assertEquals(f.getIdMatches().size(), 2); assertSame(f.getIdMatches().get(0), al.getSequenceAt(1)); assertSame(f.getIdMatches().get(1), al.getSequenceAt(2)); @@ -577,12 +594,13 @@ public class FinderTest sg.addSequence(al.getSequenceAt(1), false); sg.addSequence(al.getSequenceAt(2), false); sg.addSequence(al.getSequenceAt(3), false); - + av.setSelectionGroup(sg); + /* * search for 'I' should match two sequence positions */ - Finder f = new Finder(al); - f.findAll("I", sg, false, false); + Finder f = new Finder(av); + f.findAll("I", false, false); assertTrue(f.getIdMatches().isEmpty()); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 2); @@ -621,8 +639,8 @@ public class FinderTest * find all search for D should ignore hidden positions in seq1 and seq3, * find the visible D in seq2 */ - Finder f = new Finder(al); - f.findAll("D", null, false, false); + Finder f = new Finder(av); + f.findAll("D", false, false); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); SearchResultMatchI match = searchResults.getResults().get(0); @@ -635,8 +653,8 @@ public class FinderTest * find all 'aaa' should find end of seq4 only */ hc.hideColumns(2, 5); - f = new Finder(al); - f.findAll("aaa", null, false, false); + f = new Finder(av); + f.findAll("aaa", false, false); searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -647,7 +665,7 @@ public class FinderTest /* * find all 'BE' should not match across hidden columns in seq1 */ - f.findAll("BE", null, false, false); + f.findAll("BE", false, false); assertTrue(f.getSearchResults().isEmpty()); /* @@ -656,8 +674,8 @@ public class FinderTest */ hc.revealAllHiddenColumns(new ColumnSelection()); hc.hideColumns(8, 13); - f = new Finder(al); - f.findNext("H", null, false, false); + f = new Finder(av); + f.findNext("H", false, false); searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 1); match = searchResults.getResults().get(0); @@ -693,13 +711,14 @@ public class FinderTest sg.addSequence(al.getSequenceAt(2), false); sg.setStartRes(0); sg.setEndRes(13); + av.setSelectionGroup(sg); /* * find all search for A or H * should match seq2/1, seq2/7, not seq3/6 */ - Finder f = new Finder(al); - f.findAll("[AH]", sg, false, false); + Finder f = new Finder(av); + f.findAll("[AH]", false, false); SearchResultsI searchResults = f.getSearchResults(); assertEquals(searchResults.getSize(), 2); SearchResultMatchI match = searchResults.getResults().get(0); diff --git a/test/jalview/controller/AlignViewControllerTest.java b/test/jalview/controller/AlignViewControllerTest.java index ad86f32..2669c99 100644 --- a/test/jalview/controller/AlignViewControllerTest.java +++ b/test/jalview/controller/AlignViewControllerTest.java @@ -223,8 +223,8 @@ public class AlignViewControllerTest /* * test Match/Find works first */ - FinderI f = new Finder(af.getViewport().getAlignment()); - f.findAll("M+", null, true, false); + FinderI f = new Finder(af.getViewport()); + f.findAll("M+", true, false); assertEquals( "Finder found different set of results to manually created SearchResults", sr, f.getSearchResults()); -- 1.7.10.2