javadoc and new method to get alignment sequence index using a SearchResults object
authorjprocter <Jim Procter>
Wed, 12 Nov 2008 11:03:07 +0000 (11:03 +0000)
committerjprocter <Jim Procter>
Wed, 12 Nov 2008 11:03:07 +0000 (11:03 +0000)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java

index 1312e22..08c04f5 100755 (executable)
@@ -441,8 +441,9 @@ public class Alignment implements AlignmentI
     return result;
 
   }
-
-  /**    */
+  /* (non-Javadoc)
+   * @see jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SequenceI)
+   */
   public int findIndex(SequenceI s)
   {
     int i = 0;
@@ -459,6 +460,23 @@ public class Alignment implements AlignmentI
 
     return -1;
   }
+  /* (non-Javadoc)
+   * @see jalview.datamodel.AlignmentI#findIndex(jalview.datamodel.SearchResults)
+   */
+  public int findIndex(SearchResults results)
+  {
+    int i=0;
+    
+    while (i<sequences.size())
+    {
+      if (results.involvesSequence(getSequenceAt(i)))
+      {
+        return i;
+      }
+      i++;
+    }
+    return -1;
+  }
 
   /**
    * DOCUMENT ME!
@@ -904,4 +922,5 @@ public class Alignment implements AlignmentI
     }
     return removed;
   }
+
 }
index b4075a0..af5b7c4 100755 (executable)
@@ -122,7 +122,7 @@ public interface AlignmentI
    * @param s
    *                Sequence to look for.
    * 
-   * @return Index of sequence within the alignment.
+   * @return Index of sequence within the alignment or -1 if not found
    */
   public int findIndex(SequenceI s);
 
@@ -359,4 +359,11 @@ public interface AlignmentI
    */
   public SequenceI findName(SequenceI startAfter, String token, boolean b);
 
+  /**
+   * find first sequence in alignment which is involved in the given search result object
+   * @param results
+   * @return -1 or index of sequence in alignment
+   */
+  public int findIndex(SearchResults results);
+
 }