JAL-1644 improvment of finder logic to include the sequence description field
[jalview.git] / src / jalview / analysis / Finder.java
index 1179435..b253642 100644 (file)
@@ -1,25 +1,31 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
+ * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
- * 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.analysis;
 
-import java.util.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SearchResults;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
 
-import jalview.datamodel.*;
+import java.util.Vector;
 
 public class Finder
 {
@@ -84,7 +90,6 @@ public class Finder
     boolean found = false;
     int end = alignment.getHeight();
 
-
     // /////////////////////////////////////////////
 
     if (selection != null)
@@ -99,7 +104,7 @@ public class Finder
     while (!found && (seqIndex < end))
     {
       seq = (Sequence) alignment.getSequenceAt(seqIndex);
-      
+
       if ((selection != null && selection.getSize() > 0)
               && !selection.getSequences(null).contains(seq))
       {
@@ -121,9 +126,10 @@ public class Finder
           {
             searchResults.addResult(seq, res, res);
             hasResults = true;
-            //resIndex=seq.getLength();
+            // resIndex=seq.getLength();
             // seqIndex++;
-            if (!findAll) {
+            if (!findAll)
+            {
               found = true;
               break;
             }
@@ -143,6 +149,18 @@ public class Finder
             break;
           }
         }
+
+        if (regex.search(seq.getDescription()))
+        {
+          idMatch.addElement(seq);
+          hasResults = true;
+          if (!findAll)
+          {
+            // stop and return the match
+            found = true;
+            break;
+          }
+        }
       }
       item = seq.getSequenceAsString();