use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class ReadsContextUnitTest method getValidReadsContextData.
@DataProvider(name = "ReadsContextFilteringDataProvider")
public Object[][] getValidReadsContextData() {
// Default-constructed ReadsContexts and ReadsContexts constructed from null ReadsDataSources/intervals
// should behave as empty context objects.
ReadNameReadFilter readNameFilter = new ReadNameReadFilter();
readNameFilter.readName = "d";
return new Object[][] { { new ReadsContext(new ReadsDataSource(IOUtils.getPath(publicTestDir + "org/broadinstitute/hellbender/engine/reads_data_source_test1.bam")), // query over small interval, with no read filter
new SimpleInterval("1", 200, 210), ReadFilterLibrary.ALLOW_ALL_READS), new String[] { "a", "b", "c" } }, { new ReadsContext(new ReadsDataSource(IOUtils.getPath(publicTestDir + "org/broadinstitute/hellbender/engine/reads_data_source_test1.bam")), // query over larger interval with readNameFilter on "d"
new SimpleInterval("1", 200, 1000), readNameFilter), new String[] { "d" } } };
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class ReadsDataSourceUnitTest method testHandleUnindexedFileQuery.
@Test(expectedExceptions = UserException.class)
public void testHandleUnindexedFileQuery() {
// Construction should succeed, since we don't pass in any intervals, but the query should throw.
final Path unindexed = IOUtils.getPath(READS_DATA_SOURCE_TEST_DIRECTORY + "unindexed.bam");
Assert.assertNull(SamFiles.findIndex(unindexed), "Expected file to have no index, but found an index file" + unindexed.toAbsolutePath());
ReadsDataSource readsSource = new ReadsDataSource(unindexed);
readsSource.query(new SimpleInterval("1", 1, 5));
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class ReadsDataSourceUnitTest method traversalWithUnmappedReadsTestData.
@DataProvider(name = "TraversalWithUnmappedReadsTestData")
public Object[][] traversalWithUnmappedReadsTestData() {
// This bam has only mapped reads
final Path mappedBam = IOUtils.getPath(publicTestDir + "org/broadinstitute/hellbender/engine/reads_data_source_test1.bam");
// This bam has mapped reads from various contigs, plus a few unmapped reads with no mapped mate
final Path unmappedBam = IOUtils.getPath(publicTestDir + "org/broadinstitute/hellbender/engine/reads_data_source_test1_with_unmapped.bam");
// This is a snippet of the CEUTrio.HiSeq.WGS.b37.NA12878 bam from large, with mapped reads
// from chromosome 20 (with one mapped read having an unmapped mate), plus several unmapped
// reads with no mapped mate.
final Path ceuSnippet = IOUtils.getPath(publicTestDir + "org/broadinstitute/hellbender/engine/CEUTrio.HiSeq.WGS.b37.NA12878.snippet_with_unmapped.bam");
return new Object[][] { // One interval, no unmapped
{ unmappedBam, Arrays.asList(new SimpleInterval("1", 200, 1000)), false, Arrays.asList("a", "b", "c", "d") }, // One interval, with unmapped
{ unmappedBam, Arrays.asList(new SimpleInterval("1", 200, 1000)), true, Arrays.asList("a", "b", "c", "d", "u1", "u2", "u3", "u4", "u5") }, // Multiple intervals, no unmapped
{ unmappedBam, Arrays.asList(new SimpleInterval("1", 200, 1000), new SimpleInterval("2", 500, 700), new SimpleInterval("4", 700, 701)), false, Arrays.asList("a", "b", "c", "d", "f", "g", "h", "k") }, // Multiple intervals, with unmapped
{ unmappedBam, Arrays.asList(new SimpleInterval("1", 200, 1000), new SimpleInterval("2", 500, 700), new SimpleInterval("4", 700, 701)), true, Arrays.asList("a", "b", "c", "d", "f", "g", "h", "k", "u1", "u2", "u3", "u4", "u5") }, // Interval with no overlapping reads, no unmapped
{ unmappedBam, Arrays.asList(new SimpleInterval("1", 3000, 4000)), false, Collections.<String>emptyList() }, // Interval with no overlapping reads, with unmapped
{ unmappedBam, Arrays.asList(new SimpleInterval("1", 3000, 4000)), true, Arrays.asList("u1", "u2", "u3", "u4", "u5") }, // Interval with no overlapping reads, with unmapped, but no unmapped reads in bam
{ mappedBam, Arrays.asList(new SimpleInterval("1", 3000, 4000)), true, Collections.<String>emptyList() }, // Interval with overlapping reads, with unmapped, but no unmapped reads in bam
{ mappedBam, Arrays.asList(new SimpleInterval("1", 200, 1000)), true, Arrays.asList("a", "b", "c", "d") }, // Null intervals, with unmapped
{ unmappedBam, null, true, Arrays.asList("u1", "u2", "u3", "u4", "u5") }, // Empty intervals, with unmapped
{ unmappedBam, Collections.<SimpleInterval>emptyList(), true, Arrays.asList("u1", "u2", "u3", "u4", "u5") }, // Null intervals, with unmapped, but no unmapped reads in bam
{ mappedBam, null, true, Collections.<String>emptyList() }, // Empty intervals, with unmapped, but no unmapped reads in bam
{ mappedBam, Collections.<SimpleInterval>emptyList(), true, Collections.<String>emptyList() }, // Null intervals, no unmapped (an unbounded traversal, so we expect all the reads)
{ unmappedBam, null, false, Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "u1", "u2", "u3", "u4", "u5") }, // Empty intervals, no unmapped (an unbounded traversal, so we expect all the reads)
{ unmappedBam, Collections.<SimpleInterval>emptyList(), false, Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "u1", "u2", "u3", "u4", "u5") }, // Interval containing mapped read with unmapped mate, no unmapped
{ ceuSnippet, Arrays.asList(new SimpleInterval("20", 10000011, 10000013)), false, Arrays.asList("a", "b", "c", "d", "e", "f", "f") }, // Interval containing mapped read with unmapped mate, with unmapped
{ ceuSnippet, Arrays.asList(new SimpleInterval("20", 10000011, 10000013)), true, Arrays.asList("a", "b", "c", "d", "e", "f", "f", "g", "h", "h", "i", "i") }, // Interval not containing mapped read with unmapped mate, no unmapped
{ ceuSnippet, Arrays.asList(new SimpleInterval("20", 10000009, 10000011)), false, Arrays.asList("a", "b", "c", "d", "e") }, // Interval not containing mapped read with unmapped mate, with unmapped
{ ceuSnippet, Arrays.asList(new SimpleInterval("20", 10000009, 10000011)), true, Arrays.asList("a", "b", "c", "d", "e", "g", "h", "h", "i", "i") } };
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class ReadsDataSourceUnitTest method testHandleUnindexedFileWithIntervals.
@Test(expectedExceptions = UserException.class)
public void testHandleUnindexedFileWithIntervals() {
// Cannot initialize a reads source with intervals unless all files are indexed
final Path unindexed = IOUtils.getPath(READS_DATA_SOURCE_TEST_DIRECTORY + "unindexed.bam");
Assert.assertNull(SamFiles.findIndex(unindexed), "Expected file to have no index, but found an index file. " + unindexed.toAbsolutePath());
ReadsDataSource readsSource = new ReadsDataSource(unindexed);
readsSource.setTraversalBounds(Arrays.asList(new SimpleInterval("1", 1, 5)));
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class ReadsDataSourceUnitTest method testManuallySpecifiedIndicesWithCustomReaderFactoryAndNullWrappers.
@Test(dataProvider = "manuallySpecifiedIndexTestData")
public void testManuallySpecifiedIndicesWithCustomReaderFactoryAndNullWrappers(final List<Path> bams, final List<Path> indices) {
final SamReaderFactory customFactory = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.STRICT);
// ReadsDataSource should not be using the wrapper since the files are not on the Google cloud.
// So we pass this invalid wrapper: if the code tries to use it, it'll blow up.
Function<SeekableByteChannel, SeekableByteChannel> nullWrapper = (SeekableByteChannel) -> null;
try (final ReadsDataSource readsSource = new ReadsDataSource(bams, indices, customFactory, nullWrapper, nullWrapper)) {
Assert.assertTrue(readsSource.indicesAvailable(), "Explicitly-provided indices not detected for bams: " + bams);
final Iterator<GATKRead> queryReads = readsSource.query(new SimpleInterval("1", 1, 300));
int queryCount = 0;
while (queryReads.hasNext()) {
++queryCount;
queryReads.next();
}
Assert.assertEquals(queryCount, 5, "Wrong number of reads returned in query");
}
}
Aggregations