JAL-1738 JAL-345 fix for JAL-2302 only report Matches that are not contained by the...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 2 Nov 2016 15:33:09 +0000 (15:33 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 2 Nov 2016 15:33:09 +0000 (15:33 +0000)
src/jalview/analysis/Finder.java

index 086765c..ff03788 100644 (file)
@@ -21,6 +21,7 @@
 package jalview.analysis;
 
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResultMatchI;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.SearchResultsI;
 import jalview.datamodel.Sequence;
@@ -103,6 +104,7 @@ public class Finder
         selection = null;
       }
     }
+    SearchResultMatchI lastm = null;
 
     while (!found && (seqIndex < end))
     {
@@ -193,7 +195,6 @@ public class Finder
       }
 
       String noGaps = noGapsSB.toString();
-
       for (int r = resIndex; r < noGaps.length(); r++)
       {
 
@@ -216,8 +217,13 @@ public class Finder
                   - 1
                   + Integer.parseInt(spaces
                           .elementAt(regex.matchedTo() - 1).toString()));
-
-          searchResults.addResult(seq, sres, eres);
+          // only add result if not contained in previous result
+          if (lastm == null
+                  || (lastm.getSequence() != seq || (!(lastm.getStart() <= sres && lastm
+                          .getEnd() >= eres))))
+          {
+            lastm = searchResults.addResult(seq, sres, eres);
+          }
           hasResults = true;
           if (!findAll)
           {