+ else
+ {
+ i++;
+ }
+ }
+ Annotation[] ann = annotations;
+ annotations = new Annotation[i];
+ System.arraycopy(ann, 0, annotations, 0, i);
+ ann = null;
+ return iSize;
+ }
+
+ /**
+ * Associate this annotation with the aligned residues of a particular
+ * sequence. sequenceMapping will be updated in the following way: null
+ * sequenceI - existing mapping will be discarded but annotations left in
+ * mapped positions. valid sequenceI not equal to current sequenceRef: mapping
+ * is discarded and rebuilt assuming 1:1 correspondence TODO: overload with
+ * parameter to specify correspondence between current and new sequenceRef
+ *
+ * @param sequenceI
+ */
+ public void setSequenceRef(SequenceI sequenceI)
+ {
+ if (sequenceI != null)
+ {
+ if (sequenceRef != null)
+ {
+ boolean rIsDs = sequenceRef.getDatasetSequence() == null, tIsDs = sequenceI
+ .getDatasetSequence() == null;
+ if (sequenceRef != sequenceI
+ && (rIsDs && !tIsDs && sequenceRef != sequenceI
+ .getDatasetSequence())
+ && (!rIsDs && tIsDs && sequenceRef.getDatasetSequence() != sequenceI)
+ && (!rIsDs && !tIsDs && sequenceRef.getDatasetSequence() != sequenceI
+ .getDatasetSequence())
+ && !sequenceRef.equals(sequenceI))
+ {
+ // if sequenceRef isn't intersecting with sequenceI
+ // throw away old mapping and reconstruct.
+ sequenceRef = null;
+ if (sequenceMapping != null)
+ {
+ sequenceMapping = null;
+ // compactAnnotationArray();
+ }
+ createSequenceMapping(sequenceI, 1, true);
+ adjustForAlignment();
+ }
+ else
+ {
+ // Mapping carried over
+ sequenceRef = sequenceI;
+ }
+ }
+ else
+ {
+ // No mapping exists
+ createSequenceMapping(sequenceI, 1, true);
+ adjustForAlignment();
+ }
+ }
+ else
+ {
+ // throw away the mapping without compacting.
+ sequenceMapping = null;
+ sequenceRef = null;
+ }
+ }
+
+ /**
+ * @return the score
+ */
+ public double getScore()
+ {
+ return score;
+ }
+
+ /**
+ * @param score
+ * the score to set
+ */
+ public void setScore(double score)
+ {
+ hasScore = true;
+ this.score = score;
+ }
+
+ /**
+ *
+ * @return true if annotation has an associated score
+ */
+ public boolean hasScore()
+ {
+ return hasScore || !Double.isNaN(score);
+ }
+
+ /**
+ * Score only annotation
+ *
+ * @param label
+ * @param description
+ * @param score
+ */
+ public AlignmentAnnotation(String label, String description, double score)
+ {
+ this(label, description, null);
+ setScore(score);
+ }
+
+ /**
+ * copy constructor with edit based on the hidden columns marked in colSel
+ *
+ * @param alignmentAnnotation
+ * @param colSel
+ */
+ public AlignmentAnnotation(AlignmentAnnotation alignmentAnnotation,
+ HiddenColumns hidden)
+ {
+ this(alignmentAnnotation);
+ if (annotations == null)
+ {
+ return;
+ }
+ hidden.makeVisibleAnnotation(this);
+ }