X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequence.java;h=68bf8f223592ca7f3f28decffc0e4196b825e35b;hb=195c41c18f6a059b334d063312cd15de6a937ea5;hp=6b143ce32258902bf40a77d078a5ee6f37da88d5;hpb=a9315b41e948f66f4632f7d419fda643bc0b9354;p=jalview.git diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 6b143ce..68bf8f2 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -1,25 +1,30 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8) - * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors * * This file is part of Jalview. * * Jalview is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. * * Jalview is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ 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; @@ -50,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 @@ -486,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) @@ -711,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 { @@ -896,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; @@ -921,7 +930,9 @@ public class Sequence implements SequenceI { this.annotation.removeElement(annotation); if (this.annotation.size() == 0) + { this.annotation = null; + } } } @@ -1000,6 +1011,17 @@ public class Sequence implements SequenceI datasetSequence.setPDBId(getPDBId()); setPDBId(null); datasetSequence.updatePDBIds(); + if (annotation != null) + { + for (AlignmentAnnotation aa : annotation) + { + AlignmentAnnotation _aa = new AlignmentAnnotation(aa); + _aa.sequenceRef = datasetSequence; + _aa.adjustForAlignment(); // uses annotation's own record of + // sequence-column mapping + datasetSequence.addAlignmentAnnotation(_aa); + } + } } return datasetSequence; } @@ -1022,7 +1044,9 @@ public class Sequence implements SequenceI for (int i = 0; i < annotations.length; i++) { if (annotations[i] != null) + { addAlignmentAnnotation(annotations[i]); + } } } } @@ -1208,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; + } + }