JAL-3748 simple test for SeqCigar preservation of start/end and name for different...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 22 Sep 2020 13:45:11 +0000 (14:45 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 22 Sep 2020 14:06:52 +0000 (15:06 +0100)
test/jalview/datamodel/SeqCigarTest.java

index 7ec06aa..761835d 100644 (file)
@@ -67,6 +67,29 @@ public class SeqCigarTest
     }
   }
 
+  @Test(groups= {"Functional"})
+  public void testReconstructSeq()
+  {
+    String o_seq = "asdfktryasdtqwrtsaslldddptyipqqwaslchvhttt";
+    SequenceI s = new Sequence("MySeq", o_seq, 39, 80);
+    String orig_gapped = "----asdf------ktryas---dtqwrtsasll----dddptyipqqwa----slchvhttt";
+    // name of sequence in a particular alignment should be recovered
+    SequenceI s_gapped = new Sequence("MySeqAlign", orig_gapped, 39, 80);
+    s_gapped.setDatasetSequence(s);
+    SeqCigar cg_sgapped = new SeqCigar(s_gapped);
+    assertTrue(testSeqRecovery(cg_sgapped,s_gapped,true));
+    SequenceI subseq_gapped = s_gapped.getSubSequence(44, 60);
+    SeqCigar subseq_cg_range=new SeqCigar(s_gapped,44,59);
+    assertTrue(testSeqRecovery(subseq_cg_range, subseq_gapped, true),"SeqCigar created on range of sequence failed");
+
+    // test another way of reconstructing a sequence from seqCigar
+    SequenceI[] sqs=SeqCigar.createAlignmentSequences(new SeqCigar[] {subseq_cg_range}, '-', new HiddenColumns(), null);
+    assertTrue(testSeqRecovery(subseq_cg_range, sqs[0], true),"createAlignmentSequences didn't reconstruct same sequence as for SeqCigar created on range of sequence failed (used by AlignmentView for selections)");
+
+    subseq_gapped.setName("SubSeqMySeqAlign"); // name of sequence in a particular alignment should be recovered
+    SeqCigar subseq_cg = new SeqCigar(subseq_gapped);
+    assertTrue(testSeqRecovery(subseq_cg,subseq_gapped,true));
+  }
   /*
    * refactored 'as is' from main method
    *