+ /**
+ * test that creating a copy of an existing sequence with dataset sequence and
+ * associated contact matrix yields annotation associated with the same
+ * contact matrix in the copy
+ */
+ @Test(groups = { "Functional" })
+ public void testCopyPasteStyleDerivesequence_withcontactMatrixAnn()
+ {
+ SequenceI seq1 = new Sequence("seq1", "ACDACDACD");
+ seq1.createDatasetSequence();
+ ContactMatrixI cm = new SeqDistanceContactMatrix(seq1.getLength());
+ // addContactList needs to return annotation addable to the sequence
+ // reference it was called from
+ AlignmentAnnotation aann = seq1.addContactList(cm);
+ assertTrue(aann.sequenceRef == seq1);
+ assertEquals(1, seq1.getAnnotation().length);
+ assertNotNull(seq1.getContactListFor(seq1.getAnnotation()[0], 1));
+
+ SequenceI seq_derived = seq1.deriveSequence();
+ assertEquals(1, seq_derived.getAnnotation().length);
+ assertTrue(cm == seq_derived
+ .getContactMatrixFor(seq_derived.getAnnotation()[0]));
+ assertNotNull(seq_derived
+ .getContactListFor(seq_derived.getAnnotation()[0], 1));
+
+ // copy paste actually uses the copy constructor .. so
+
+ SequenceI seq_copied = new Sequence((Sequence) seq_derived);
+ assertEquals(1, seq_copied.getAnnotation().length);
+ assertTrue(cm == seq_copied
+ .getContactMatrixFor(seq_copied.getAnnotation()[0]));
+ assertNotNull(
+ seq_copied.getContactListFor(seq_copied.getAnnotation()[0], 1));
+
+ }
+