+ annotations = temp;
+ }
+
+ /**
+ * remove any null entries in annotation row and return the number of non-null
+ * annotation elements.
+ *
+ * @return
+ */
+ public int compactAnnotationArray()
+ {
+ int i = 0, iSize = annotations.length;
+ while (i < iSize)
+ {
+ if (annotations[i] == null)
+ {
+ if (i + 1 < iSize)
+ System.arraycopy(annotations, i + 1, annotations, i, iSize - i
+ - 1);
+ iSize--;
+ }
+ else
+ {
+ i++;
+ }
+ }
+ Annotation[] ann = annotations;
+ annotations = new Annotation[i];
+ System.arraycopy(ann, 0, annotations, 0, i);
+ ann = null;
+ return iSize;
+ }
+
+ /**
+ * Associate this annotion 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)
+ {
+ if (sequenceRef != sequenceI
+ && !sequenceRef.equals(sequenceI)
+ && sequenceRef.getDatasetSequence() != sequenceI
+ .getDatasetSequence())
+ {
+ // if sequenceRef isn't intersecting with sequenceI
+ // throw away old mapping and reconstruct.
+ sequenceRef = null;
+ if (sequenceMapping != null)