indicate the database id source associated with the sequences being submitted.
[jalview.git] / src / jalview / datamodel / SearchResults.java
index e62c150..2400524 100755 (executable)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
- * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -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