@Test(groups = "Functional")
public final void testGetSequenceProxy() throws Exception
{
- String pathname = "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);
sq = db.getSequenceProxy("PPL_06716");
assertNotNull(sq);
assertEquals(sq.getLength(), 602);
-
+
// dict = db.getDictionary(f, truncate))
}
expectedExceptions = java.lang.IllegalArgumentException.class)
public final void testGetSequenceProxy_indexed()
{
- String pathname = "test/jalview/ext/htsjdk/pgmb.fasta.fai";
+ String pathname = "test/jalview/ext/htsjdk/pgmB.fasta.fai";
new HtsContigDb("ADB", new File(pathname));
fail("Expected exception opening .fai file");
}
+ /**
+ * Tests that exercise
+ * <ul>
+ * <li>opening an unindexed fasta file</li>
+ * <li>creating a .fai index</li>
+ * <li>opening the fasta file, now using the index</li>
+ * <li>error on creating index if overwrite not allowed</li>
+ * </ul>
+ *
+ * @throws IOException
+ */
@Test(groups = "Functional")
public void testCreateFastaSequenceIndex() throws IOException
{
- File fasta = new File("test/jalview/ext/htsjdk/pgmb.fasta");
-
+ File fasta = new File("test/jalview/ext/htsjdk/pgmB.fasta");
+
/*
* create .fai with no overwrite fails if it exists
*/
- try {
+ try
+ {
HtsContigDb.createFastaSequenceIndex(fasta.toPath(), false);
fail("Expected exception");
} catch (IOException e)
{
- // expected
+ // we expect an IO Exception because the pgmB.fasta.fai exists, since it
+ // was checked it in.
}
/*
assertTrue(db.isIndexed());
db.close();
}
+
+ /**
+ * A convenience 'test' that may be run to create a .fai file for any given
+ * fasta file
+ *
+ * @throws IOException
+ */
+ @Test(enabled = false)
+ public void testCreateIndex() throws IOException
+ {
+
+ File fasta = new File("test/jalview/io/vcf/contigs.fasta");
+ HtsContigDb.createFastaSequenceIndex(fasta.toPath(), true);
+ }
}