X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=f628699dee035546020be7c2d4c014efbd6ab8d9;hb=2e7da637a195ff484f92a333675284f071657cd6;hp=d0020314431963b546b577af61ccad89677155fe;hpb=7ab5d6b0ba5fec1ea4a4239e79c476d841622485;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index d002031..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; @@ -59,8 +61,10 @@ public class Sequence implements SequenceI /** * This annotation is displayed below the alignment but the positions are tied * to the residues of this sequence + * + * TODO: change to List<> */ - Vector annotation; + Vector annotation; /** * The index of the sequence in a MSA @@ -899,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; @@ -1005,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); } } } @@ -1079,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)