involvesSequence to check if searchResults intersect with a specific sequence
authorjprocter <Jim Procter>
Wed, 12 Nov 2008 11:03:56 +0000 (11:03 +0000)
committerjprocter <Jim Procter>
Wed, 12 Nov 2008 11:03:56 +0000 (11:03 +0000)
src/jalview/datamodel/SearchResults.java

index e62c150..329f447 100755 (executable)
@@ -57,7 +57,29 @@ public class SearchResults
 
     matches = tmp;
   }
-
+  /**
+   * Quickly check if the given sequence is referred to in the search results
+   * @param sequence (specific alignment sequence or a dataset sequence)
+   * @return true if the results involve sequence
+   */
+  public boolean involvesSequence(SequenceI sequence)
+  {
+    if (matches==null || matches.length==0)
+    {
+      return false;
+    }
+    SequenceI ds = sequence.getDatasetSequence();
+    for (int m=0; m<matches.length; m++)
+    {
+      if (matches[m].sequence!=null &&
+              (matches[m].sequence==sequence 
+              || matches[m].sequence==ds))
+      {
+        return true;
+      }
+    }
+    return false;
+  }
   /**
    * This Method returns the search matches which lie between the start and end
    * points of the sequence in question. It is optimised for returning objects