X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fext%2Fhtsjdk%2FTestHtsContigDb.java;h=28c5cf0ddaf1fe0ca052b08b819129ea1580e336;hb=05c12ef9626200844bf5067056f03e84090565b3;hp=bdc14db3c8d0c5cb14bf42e80ec1b1c40a753090;hpb=956deeb079bf76f9a0e9dc076154ff4865743e63;p=jalview.git diff --git a/test/jalview/ext/htsjdk/TestHtsContigDb.java b/test/jalview/ext/htsjdk/TestHtsContigDb.java index bdc14db..28c5cf0 100644 --- a/test/jalview/ext/htsjdk/TestHtsContigDb.java +++ b/test/jalview/ext/htsjdk/TestHtsContigDb.java @@ -20,11 +20,19 @@ */ package jalview.ext.htsjdk; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + import jalview.datamodel.SequenceI; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; -import org.testng.Assert; import org.testng.annotations.Test; /** @@ -34,16 +42,107 @@ import org.testng.annotations.Test; public class TestHtsContigDb { @Test(groups = "Functional") - public final void testHTSReferenceSequence() throws Exception + public final void testGetSequenceProxy() throws Exception { - HtsContigDb remmadb = new HtsContigDb("REEMADB", new File( - "test/jalview/ext/htsjdk/pgmb.fasta")); + String pathname = "test/jalview/ext/htsjdk/pgmb.fasta"; + HtsContigDb db = new HtsContigDb("ADB", new File(pathname)); + + assertTrue(db.isValid()); + assertTrue(db.isIndexed()); // htsjdk opens the .fai file + + SequenceI sq = db.getSequenceProxy("Deminut"); + assertNotNull(sq); + assertEquals(sq.getLength(), 606); - Assert.assertTrue(remmadb.isValid()); + /* + * read a sequence earlier in the file + */ + sq = db.getSequenceProxy("PPL_06716"); + assertNotNull(sq); + assertEquals(sq.getLength(), 602); + + // dict = db.getDictionary(f, truncate)) + } - SequenceI sq = remmadb.getSequenceProxy("Deminut"); - Assert.assertNotNull(sq); - Assert.assertNotEquals(0, sq.getLength()); + /** + * Trying to open a .fai file directly results in IllegalArgumentException - + * have to provide the unindexed file name instead + */ + @Test( + groups = "Functional", + expectedExceptions = java.lang.IllegalArgumentException.class) + public final void testGetSequenceProxy_indexed() + { + String pathname = "test/jalview/ext/htsjdk/pgmb.fasta.fai"; + new HtsContigDb("ADB", new File(pathname)); + fail("Expected exception opening .fai file"); } + /** + * Tests that exercise + *