From 50a8dcccc09f983c21f0c9a8a3653c379c348a4b Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 26 Apr 2007 17:12:27 +0000 Subject: [PATCH] get annotation by label string --- src/jalview/datamodel/Sequence.java | 35 ++++++++++++++++++++++++++++++++++ src/jalview/datamodel/SequenceI.java | 6 ++++++ 2 files changed, 41 insertions(+) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 81a0f40..673177c 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -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; + } + } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index dd92c70..64a21dd 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -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); } -- 1.7.10.2