Merge commit 'ab43013b7e357b84b4abade0dba949668dfb2a0e' into develop
[jalview.git] / src / jalview / analysis / Finder.java
index edf9deb..faf79d1 100644 (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
 {
@@ -39,6 +42,8 @@ public class Finder
 
   boolean caseSensitive = false;
 
+  private boolean includeDescription = false;
+
   boolean findAll = false;
 
   com.stevesoft.pat.Regex regex = null;
@@ -146,6 +151,19 @@ public class Finder
             break;
           }
         }
+
+        if (isIncludeDescription() && seq.getDescription() != null
+                && regex.search(seq.getDescription()))
+        {
+          idMatch.addElement(seq);
+          hasResults = true;
+          if (!findAll)
+          {
+            // stop and return the match
+            found = true;
+            break;
+          }
+        }
       }
       item = seq.getSequenceAsString();
 
@@ -188,7 +206,7 @@ public class Finder
           {
             continue;
           }
-
+// if invalid string used, then regex has no matched to/from
           int sres = seq
                   .findPosition(resIndex
                           + Integer.parseInt(spaces.elementAt(resIndex)
@@ -358,4 +376,14 @@ public class Finder
   {
     this.seqIndex = seqIndex;
   }
+
+  public boolean isIncludeDescription()
+  {
+    return includeDescription;
+  }
+
+  public void setIncludeDescription(boolean includeDescription)
+  {
+    this.includeDescription = includeDescription;
+  }
 }