X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=f628699dee035546020be7c2d4c014efbd6ab8d9;hb=2755c8765d39da0da2be087b301d47fc153d9236;hp=9cc7d545e7d387c7be57aa519e9e48173c296af2;hpb=c7cc8fdf1696503da09134cd3ee6b9cadce38ff7;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 9cc7d54..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; @@ -1007,14 +1009,13 @@ public class Sequence implements SequenceI datasetSequence.updatePDBIds(); if (annotation != null) { - Vector _annot = annotation; - annotation = null; - for (AlignmentAnnotation aa : _annot) + for (AlignmentAnnotation aa : annotation) { - aa.sequenceRef = datasetSequence; - aa.adjustForAlignment(); // uses annotation's own record of + AlignmentAnnotation _aa = new AlignmentAnnotation(aa); + _aa.sequenceRef = datasetSequence; + _aa.adjustForAlignment(); // uses annotation's own record of // sequence-column mapping - datasetSequence.addAlignmentAnnotation(aa); + datasetSequence.addAlignmentAnnotation(_aa); } } } @@ -1081,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)