From: gmungoc Date: Fri, 10 Oct 2014 14:03:58 +0000 (+0100) Subject: JAL-1264 added getAlignmentAnnotations(calcId, label) X-Git-Tag: Jalview_2_9~169^2~22^2~14 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2755c8765d39da0da2be087b301d47fc153d9236;p=jalview.git JAL-1264 added getAlignmentAnnotations(calcId, label) --- diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 945a9d4..f628699 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -22,7 +22,9 @@ package jalview.datamodel; import jalview.analysis.AlignSeq; +import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import java.util.Vector; import fr.orsay.lri.varna.models.rna.RNA; @@ -901,7 +903,7 @@ public class Sequence implements SequenceI AlignmentAnnotation[] ret = new AlignmentAnnotation[annotation.size()]; for (int r = 0; r < ret.length; r++) { - ret[r] = (AlignmentAnnotation) annotation.elementAt(r); + ret[r] = annotation.elementAt(r); } return ret; @@ -1080,6 +1082,33 @@ public class Sequence implements SequenceI return anns; } + /** + * Returns a list of any annotations on the sequence that match the given + * calcId (source) and label (type). Null values do not match. + * + * @param calcId + * @param label + * @return + */ + @Override + public List getAlignmentAnnotations(String calcId, + String label) + { + List result = new ArrayList(); + if (annotation != null) + { + for (AlignmentAnnotation ann : annotation) + { + if (ann.calcId != null && ann.calcId.equals(calcId) + && ann.label != null && ann.label.equals(label)) + { + result.add(ann); + } + } + } + return result; + } + public boolean updatePDBIds() { if (datasetSequence != null) diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index b10a4d4..366b776 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -20,6 +20,7 @@ */ package jalview.datamodel; +import java.util.List; import java.util.Vector; import fr.orsay.lri.varna.models.rna.RNA; @@ -342,6 +343,17 @@ public interface SequenceI public AlignmentAnnotation[] getAnnotation(String label); /** + * Return a list of any annotations which match the given calcId (source) and + * label (type). Null values do not match. + * + * @param calcId + * @param label + * @return + */ + public List getAlignmentAnnotations(String calcId, + String label); + + /** * create a new dataset sequence (if necessary) for this sequence and sets * this sequence to refer to it. This call will move any features or * references on the sequence onto the dataset. It will also make a duplicate