JAL-3748 additional asserts to verify start/end after reconstructing sequence from...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 22 Sep 2020 13:30:23 +0000 (14:30 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 22 Sep 2020 13:30:23 +0000 (14:30 +0100)
test/jalview/datamodel/SeqCigarTest.java

index 89169d6..7ec06aa 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.datamodel;
 
+import static org.testng.Assert.assertTrue;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
 
@@ -94,13 +95,13 @@ public class SeqCigarTest
     assertEquals("Failed parseCigar", ex_cs_gapped,
             gen_sgapped.getCigarstring());
 
-    testSeqRecovery(gen_sgapped, s_gapped);
+    assertTrue(testSeqRecovery(gen_sgapped, s_gapped,true));
 
     /*
      * Test dataset resolution
      */
     SeqCigar sub_gapped = new SeqCigar(s_subsequence_gapped);
-    testSeqRecovery(sub_gapped, s_subsequence_gapped);
+    assertTrue(testSeqRecovery(sub_gapped, s_subsequence_gapped,true));
 
     /*
      * Test width functions
@@ -187,7 +188,7 @@ public class SeqCigarTest
     assertEquals("Failed getCigarstring", ex_cs_gapped, cs_gapped);
   }
 
-  protected void testSeqRecovery(SeqCigar gen_sgapped, SequenceI s_gapped)
+  protected boolean testSeqRecovery(SeqCigar gen_sgapped, SequenceI s_gapped,boolean startEndCheck)
   {
     // this is non-rigorous - start and end recovery is not tested.
     SequenceI gen_sgapped_s = gen_sgapped.getSeq('-');
@@ -201,7 +202,14 @@ public class SeqCigarTest
       System.err.println("Couldn't reconstruct sequence.\n"
               + gen_sgapped_s.getSequenceAsString() + "\n"
               + s_gapped.getSequenceAsString());
+      return false;
     }
+    if (startEndCheck)
+    {
+      assertEquals("Start not conserved in reconstructed sequence",s_gapped.getStart(),gen_sgapped_s.getStart());
+      assertEquals("End not conserved in reconstructed sequence",s_gapped.getEnd(),gen_sgapped_s.getEnd());
+    }
+    return true;
   }
 
 }