X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=68bf8f223592ca7f3f28decffc0e4196b825e35b;hb=195c41c18f6a059b334d063312cd15de6a937ea5;hp=534b6fda2e5dc012b7569cea3c429592adc7e46f;hpb=47168f025aefdaa044802bd5f8f510ffe43a4808;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 534b6fd..68bf8f2 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; @@ -53,14 +55,16 @@ public class Sequence implements SequenceI String vamsasId; DBRefEntry[] dbrefs; - + RNA rna; /** * 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 @@ -489,7 +493,9 @@ public class Sequence implements SequenceI public char[] getSequence(int start, int end) { if (start < 0) + { start = 0; + } // JBPNote - left to user to pad the result here (TODO:Decide on this // policy) if (start >= sequence.length) @@ -714,7 +720,7 @@ public class Sequence implements SequenceI { tmp = new char[i]; System.arraycopy(sequence, 0, tmp, 0, i); - j=sequence.length; + j = sequence.length; } else { @@ -899,7 +905,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; @@ -924,7 +930,9 @@ public class Sequence implements SequenceI { this.annotation.removeElement(annotation); if (this.annotation.size() == 0) + { this.annotation = null; + } } } @@ -1005,14 +1013,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); } } } @@ -1037,7 +1044,9 @@ public class Sequence implements SequenceI for (int i = 0; i < annotations.length; i++) { if (annotations[i] != null) + { addAlignmentAnnotation(annotations[i]); + } } } } @@ -1223,9 +1232,39 @@ public class Sequence implements SequenceI { index = value; } - - public void setRNA(RNA r){rna=r;} - - public RNA getRNA() { return rna; } - + + public void setRNA(RNA r) + { + rna = r; + } + + public RNA getRNA() + { + return rna; + } + + /** + * Returns a (possibly empty) list of any annotations that match on given + * calcId (source) and label (type). Null values do not match. + * + * @param calcId + * @param label + */ + @Override + public List getAlignmentAnnotations(String calcId, + String label) + { + List result = new ArrayList(); + if (this.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; + } + }