Search in sources :

Example 86 with GATKRead

use of org.broadinstitute.hellbender.utils.read.GATKRead 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");
    }
}
Also used : java.util(java.util) DataProvider(org.testng.annotations.DataProvider) IOUtils(org.broadinstitute.hellbender.utils.io.IOUtils) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) XorWrapper(org.broadinstitute.hellbender.utils.test.XorWrapper) SAMRecordToGATKReadAdapter(org.broadinstitute.hellbender.utils.read.SAMRecordToGATKReadAdapter) Test(org.testng.annotations.Test) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Function(java.util.function.Function) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) File(java.io.File) ReadUtils(org.broadinstitute.hellbender.utils.read.ReadUtils) SeekableByteChannel(java.nio.channels.SeekableByteChannel) UserException(org.broadinstitute.hellbender.exceptions.UserException) Assert(org.testng.Assert) SAMFileGATKReadWriter(org.broadinstitute.hellbender.utils.read.SAMFileGATKReadWriter) htsjdk.samtools(htsjdk.samtools) Path(java.nio.file.Path) SeekableByteChannel(java.nio.channels.SeekableByteChannel) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 87 with GATKRead

use of org.broadinstitute.hellbender.utils.read.GATKRead in project gatk by broadinstitute.

the class LocalReadShardUnitTest method testShardIteration.

@Test(dataProvider = "ShardIterationTestData")
public void testShardIteration(final Shard<GATKRead> shard, final List<String> expectedReadNames) {
    final List<String> actualReadNames = new ArrayList<>();
    for (final GATKRead read : shard) {
        actualReadNames.add(read.getName());
    }
    Assert.assertEquals(actualReadNames.size(), expectedReadNames.size(), "Wrong number of reads returned");
    Assert.assertEquals(actualReadNames, expectedReadNames, "Wrong reads returned");
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ArrayList(java.util.ArrayList) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 88 with GATKRead

use of org.broadinstitute.hellbender.utils.read.GATKRead in project gatk by broadinstitute.

the class LocalReadShardUnitTest method testShardLoadReads.

@Test(dataProvider = "ShardIterationTestData")
public void testShardLoadReads(final LocalReadShard shard, final List<String> expectedReadNames) {
    final List<String> actualReadNames = new ArrayList<>();
    for (final GATKRead read : shard.loadAllReads()) {
        actualReadNames.add(read.getName());
    }
    Assert.assertEquals(actualReadNames.size(), expectedReadNames.size(), "Wrong number of reads returned");
    Assert.assertEquals(actualReadNames, expectedReadNames, "Wrong reads returned");
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) ArrayList(java.util.ArrayList) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 89 with GATKRead

use of org.broadinstitute.hellbender.utils.read.GATKRead in project gatk by broadinstitute.

the class LikelihoodRankSumTestUnitTest method makeRead.

private GATKRead makeRead() {
    final GATKRead read = ArtificialReadUtils.createArtificialRead(TextCigarCodec.decode("10M"));
    read.setMappingQuality(30);
    read.setPosition(CONTIG, 1);
    return read;
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead)

Example 90 with GATKRead

use of org.broadinstitute.hellbender.utils.read.GATKRead in project gatk by broadinstitute.

the class LikelihoodRankSumTestUnitTest method testBlowupOnCallWithoutAllele.

@Test(expectedExceptions = IllegalStateException.class)
public void testBlowupOnCallWithoutAllele() {
    final LikelihoodRankSumTest ann = new LikelihoodRankSumTest();
    final GATKRead read1 = makeRead();
    ann.getElementForRead(read1, read1.getStart());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)457 Test (org.testng.annotations.Test)286 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)163 SAMFileHeader (htsjdk.samtools.SAMFileHeader)87 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)59 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)40 ArrayList (java.util.ArrayList)34 Collectors (java.util.stream.Collectors)34 List (java.util.List)30 Cigar (htsjdk.samtools.Cigar)29 File (java.io.File)28 java.util (java.util)28 DataProvider (org.testng.annotations.DataProvider)28 JavaRDD (org.apache.spark.api.java.JavaRDD)26 Haplotype (org.broadinstitute.hellbender.utils.haplotype.Haplotype)26 Assert (org.testng.Assert)25 ReadPileup (org.broadinstitute.hellbender.utils.pileup.ReadPileup)24 SAMReadGroupRecord (htsjdk.samtools.SAMReadGroupRecord)22 Argument (org.broadinstitute.barclay.argparser.Argument)18 UserException (org.broadinstitute.hellbender.exceptions.UserException)18