From: gmungoc Date: Thu, 12 Dec 2019 16:23:11 +0000 (+0000) Subject: JAL-3490 unit test for ignore hidden regions with selection group X-Git-Tag: Release_2_11_1_1~13^2~10^2~1^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bc07c82cde95d498cf6919422baf7ad3994e1bf2;p=jalview.git JAL-3490 unit test for ignore hidden regions with selection group --- diff --git a/src/jalview/analysis/Finder.java b/src/jalview/analysis/Finder.java index 5d42905..0d8665f 100644 --- a/src/jalview/analysis/Finder.java +++ b/src/jalview/analysis/Finder.java @@ -164,14 +164,10 @@ public class Finder implements FinderI getSequence(ignoreHidden); boolean found = false; - while (!found || findAll) + while ((!found || findAll) && sequenceIndex < end) { found = findNextMatch(searchString, searchPattern, searchDescription, ignoreHidden); - if (sequenceIndex >= end) - { - break; - } } } diff --git a/test/jalview/analysis/FinderTest.java b/test/jalview/analysis/FinderTest.java index 78a27ac..725be33 100644 --- a/test/jalview/analysis/FinderTest.java +++ b/test/jalview/analysis/FinderTest.java @@ -401,7 +401,7 @@ public class FinderTest * result */ @Test(groups = "Functional") - public void testFind_maximalResultOnly() + public void testFindAll_maximalResultOnly() { Finder f = new Finder(av); f.findAll("M+", false, false, false); @@ -495,7 +495,7 @@ public class FinderTest * Test finding next match of a sequence pattern in a selection group */ @Test(groups = "Functional") - public void testFind_inSelection() + public void testFindNext_inSelection() { /* * select sequences 2 and 3, columns 4-6 which contains @@ -549,7 +549,7 @@ public class FinderTest * Test finding all matches of a search pattern in a selection group */ @Test(groups = "Functional") - public void testFind_findAllInSelection() + public void testFindAll_inSelection() { /* * select sequences 2 and 3, columns 4-6 which contains @@ -795,7 +795,7 @@ public class FinderTest } @Test(groups = "Functional") - public void testFind_skipHiddenColumns() + public void testFind_ignoreHiddenColumns() { /* * 0 5 9 @@ -878,5 +878,32 @@ public class FinderTest assertSame(match.getSequence(), al.getSequenceAt(0)); assertEquals(match.getStart(), 14); // G assertEquals(match.getEnd(), 14); + + /* + * now select columns 0-9 and search for A.*H + * this should match in the second sequence (split as 3 matches) + * but not the first (as H is outside the selection) + */ + SequenceGroup selection = new SequenceGroup(); + selection.setStartRes(0); + selection.setEndRes(9); + al.getSequences().forEach(seq -> selection.addSequence(seq, false)); + av.setSelectionGroup(selection); + f.findAll("A.*H", false, false, true); + searchResults = f.getSearchResults(); + assertEquals(searchResults.getSize(), 3); + // match made of contiguous matches A, DE, H + 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 + match = searchResults.getResults().get(2); + assertSame(match.getSequence(), al.getSequenceAt(1)); + assertEquals(match.getStart(), 7); // H (there is no G) + assertEquals(match.getEnd(), 7); } }