get annotation by label string
authorjprocter <Jim Procter>
Thu, 26 Apr 2007 17:12:27 +0000 (17:12 +0000)
committerjprocter <Jim Procter>
Thu, 26 Apr 2007 17:12:27 +0000 (17:12 +0000)
src/jalview/datamodel/Sequence.java
src/jalview/datamodel/SequenceI.java

index 81a0f40..673177c 100755 (executable)
@@ -837,6 +837,41 @@ public class Sequence
     }
   }
 
+  /* (non-Javadoc)
+   * @see jalview.datamodel.SequenceI#getAnnotation(java.lang.String)
+   */
+  public AlignmentAnnotation[] getAnnotation(String label)
+  {
+    if (annotation==null || annotation.size()==0)
+    {
+      return null;
+    }
+    
+    Vector subset = new Vector();
+    Enumeration e = annotation.elements();
+    while (e.hasMoreElements())
+    {
+      AlignmentAnnotation ann = (AlignmentAnnotation) e.nextElement();
+      if (ann.label!=null && ann.label.equals(label))
+      {
+        subset.addElement(ann);
+      }
+    }
+    if (subset.size()==0)
+    {
+      return null;
+    }
+    AlignmentAnnotation[] anns = new AlignmentAnnotation[subset.size()];
+    int i=0;
+    e = subset.elements();
+    while (e.hasMoreElements())
+    {
+      anns[i++] = (AlignmentAnnotation) e.nextElement();
+    }
+    subset.removeAllElements();
+    return anns;
+  }
+
 }
 
 
index dd92c70..64a21dd 100755 (executable)
@@ -269,5 +269,11 @@ public interface SequenceI
    * @param revealed
    */
   public void setAlignmentAnnotation(AlignmentAnnotation[] annotation);
+  /**
+   * Get one or more alignment annotations with a particular label.  
+   * @param label string which each returned annotation must have as a label.
+   * @return null or array of annotations.
+   */
+  public AlignmentAnnotation[] getAnnotation(String label);
 
 }