Search in sources :

Example 1 with Index

use of htsjdk.tribble.index.Index in project gatk by broadinstitute.

the class IndexFeatureFileIntegrationTest method testVCFIndex.

@Test
public void testVCFIndex() {
    final File ORIG_FILE = getTestFile("test_variants_for_index.vcf");
    final File outName = createTempFile("test_variants_for_index.vcf", ".idx");
    final String[] args = { "--feature_file", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() };
    final Object res = this.runCommandLine(args);
    Assert.assertEquals(res, outName.getAbsolutePath());
    final Index index = IndexFactory.loadIndex(res.toString());
    Assert.assertTrue(index instanceof LinearIndex);
    Assert.assertEquals(index.getSequenceNames(), Arrays.asList("1", "2", "3", "4"));
    checkIndex(index, Arrays.asList("1", "2", "3", "4"));
}
Also used : LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Index(htsjdk.tribble.index.Index) TabixIndex(htsjdk.tribble.index.tabix.TabixIndex) File(java.io.File) LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 2 with Index

use of htsjdk.tribble.index.Index in project gatk by broadinstitute.

the class IndexFeatureFileIntegrationTest method testGVCFIndex.

@Test
public void testGVCFIndex() {
    final File ORIG_FILE = getTestFile("test_variants_for_index.g.vcf");
    final File outName = createTempFile("test_variants_for_index.g.vcf.", ".idx");
    final String[] args = { "--feature_file", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() };
    final Object res = this.runCommandLine(args);
    Assert.assertEquals(res, outName.getAbsolutePath());
    final Index index = IndexFactory.loadIndex(res.toString());
    Assert.assertTrue(index instanceof LinearIndex);
    Assert.assertEquals(index.getSequenceNames(), Arrays.asList("1"));
    checkIndex(index, Arrays.asList("1"));
}
Also used : LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Index(htsjdk.tribble.index.Index) TabixIndex(htsjdk.tribble.index.tabix.TabixIndex) File(java.io.File) LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 3 with Index

use of htsjdk.tribble.index.Index in project gatk by broadinstitute.

the class IndexFeatureFileIntegrationTest method testBCFIndex.

@Test
public void testBCFIndex() {
    final File ORIG_FILE = getTestFile("test_variants_for_index.bcf");
    final File outName = createTempFile("test_variants_for_index.bcf.", ".idx");
    final String[] args = { "--feature_file", ORIG_FILE.getAbsolutePath(), "-O", outName.getAbsolutePath() };
    final Object res = this.runCommandLine(args);
    Assert.assertEquals(res, outName.getAbsolutePath());
    final Index index = IndexFactory.loadIndex(res.toString());
    Assert.assertTrue(index instanceof LinearIndex);
    Assert.assertEquals(index.getSequenceNames(), Arrays.asList("1"));
    checkIndex(index, Arrays.asList("1"));
}
Also used : LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Index(htsjdk.tribble.index.Index) TabixIndex(htsjdk.tribble.index.tabix.TabixIndex) File(java.io.File) LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 4 with Index

use of htsjdk.tribble.index.Index in project gatk by broadinstitute.

the class IndexFeatureFileIntegrationTest method testVCFGZIndex_inferredName.

@Test
public void testVCFGZIndex_inferredName() {
    //made by bgzip
    final File ORIG_FILE = getTestFile("test_variants_for_index.vcf.blockgz.gz");
    final String[] args = { "--feature_file", ORIG_FILE.getAbsolutePath() };
    final Object res = this.runCommandLine(args);
    final File tabixIndex = new File(ORIG_FILE.getAbsolutePath() + TabixUtils.STANDARD_INDEX_EXTENSION);
    Assert.assertEquals(res, tabixIndex.getAbsolutePath());
    tabixIndex.deleteOnExit();
    Assert.assertTrue(tabixIndex.exists(), tabixIndex + " does not exists");
    final Index index = IndexFactory.loadIndex(tabixIndex.toString());
    Assert.assertTrue(index instanceof TabixIndex);
    Assert.assertEquals(index.getSequenceNames(), Arrays.asList("1", "2", "3", "4"));
    checkIndex(index, Arrays.asList("1", "2", "3", "4"));
}
Also used : TabixIndex(htsjdk.tribble.index.tabix.TabixIndex) LinearIndex(htsjdk.tribble.index.linear.LinearIndex) Index(htsjdk.tribble.index.Index) TabixIndex(htsjdk.tribble.index.tabix.TabixIndex) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 5 with Index

use of htsjdk.tribble.index.Index in project gatk by broadinstitute.

the class IndexUtilsUnitTest method testFailLoadTribbleIndex.

@Test(dataProvider = "failTribbleIndexFiles")
public void testFailLoadTribbleIndex(final File featureFile) throws Exception {
    final Index index = IndexUtils.loadTribbleIndex(featureFile);
    Assert.assertNull(index);
}
Also used : Index(htsjdk.tribble.index.Index) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

Index (htsjdk.tribble.index.Index)29 File (java.io.File)20 Test (org.testng.annotations.Test)15 TabixIndex (htsjdk.tribble.index.tabix.TabixIndex)12 LinearIndex (htsjdk.tribble.index.linear.LinearIndex)9 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)8 IOException (java.io.IOException)7 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)7 BlockCompressedOutputStream (htsjdk.samtools.util.BlockCompressedOutputStream)3 TabixIndexCreator (htsjdk.tribble.index.tabix.TabixIndexCreator)3 VCFCodec (htsjdk.variant.vcf.VCFCodec)3 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)2 LineIterator (htsjdk.tribble.readers.LineIterator)2 LittleEndianOutputStream (htsjdk.tribble.util.LittleEndianOutputStream)2 IndexFeatureFile (org.broadinstitute.hellbender.tools.IndexFeatureFile)2 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)2 TargetCodec (org.broadinstitute.hellbender.utils.codecs.TargetCodec)2 BeforeClass (org.testng.annotations.BeforeClass)2 LocationAwareOutputStream (com.github.lindenb.jvarkit.io.LocationAwareOutputStream)1 BedLine (com.github.lindenb.jvarkit.util.bio.bed.BedLine)1