Search in sources :

Example 41 with GATKRead

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

the class ReadFilterLibraryUnitTest method testNotSupplementaryAlignmentReadFilter.

@Test
public void testNotSupplementaryAlignmentReadFilter() {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead read = simpleGoodRead(header);
    read.setIsSupplementaryAlignment(false);
    Assert.assertTrue(NOT_SUPPLEMENTARY_ALIGNMENT.test(read), "NOT_SUPPLEMENTARY_ALIGNMENT " + read.toString());
    read.setIsSupplementaryAlignment(true);
    Assert.assertFalse(NOT_SUPPLEMENTARY_ALIGNMENT.test(read), "NOT_SUPPLEMENTARY_ALIGNMENT " + read.toString());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Test(org.testng.annotations.Test)

Example 42 with GATKRead

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

the class ReadFilterLibraryUnitTest method mateOnSameContigOrNoMappedMateTestData.

@DataProvider(name = "MateOnSameContigOrNoMappedMateTestData")
public Object[][] mateOnSameContigOrNoMappedMateTestData() {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead unpairedRead = simpleGoodRead(header);
    unpairedRead.setIsPaired(false);
    final GATKRead pairedReadWithUnmappedMate = simpleGoodRead(header);
    pairedReadWithUnmappedMate.setIsPaired(true);
    pairedReadWithUnmappedMate.setMateIsUnmapped();
    final GATKRead pairedReadWithMappedMateDifferentContig = simpleGoodRead(header);
    pairedReadWithMappedMateDifferentContig.setIsPaired(true);
    pairedReadWithMappedMateDifferentContig.setMatePosition("2", 1);
    pairedReadWithMappedMateDifferentContig.setPosition("1", 1);
    final GATKRead pairedReadWithMappedMateSameContig = simpleGoodRead(header);
    pairedReadWithMappedMateSameContig.setIsPaired(true);
    pairedReadWithMappedMateSameContig.setMatePosition("1", 100);
    pairedReadWithMappedMateSameContig.setPosition("1", 1);
    final GATKRead unmappedReadWithMappedMate = simpleGoodRead(header);
    unmappedReadWithMappedMate.setIsUnmapped();
    unmappedReadWithMappedMate.setIsPaired(true);
    unmappedReadWithMappedMate.setMatePosition("1", 100);
    final GATKRead unmappedReadWithUnmappedMate = simpleGoodRead(header);
    unmappedReadWithUnmappedMate.setIsUnmapped();
    unmappedReadWithUnmappedMate.setIsPaired(true);
    unmappedReadWithUnmappedMate.setMateIsUnmapped();
    final GATKRead unmappedUnpairedRead = simpleGoodRead(header);
    unmappedUnpairedRead.setIsUnmapped();
    unmappedUnpairedRead.setIsPaired(false);
    return new Object[][] { { unpairedRead, true }, { pairedReadWithUnmappedMate, true }, { pairedReadWithMappedMateDifferentContig, false }, { pairedReadWithMappedMateSameContig, true }, { unmappedReadWithMappedMate, false }, { unmappedReadWithUnmappedMate, true }, { unmappedUnpairedRead, true } };
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) DataProvider(org.testng.annotations.DataProvider)

Example 43 with GATKRead

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

the class ReadFilterLibraryUnitTest method failsSEQ_IS_STORED.

@Test
public void failsSEQ_IS_STORED() {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead read = simpleGoodRead(header);
    read.setBases(new byte[0]);
    Assert.assertFalse(SEQ_IS_STORED.test(read), read.toString());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Test(org.testng.annotations.Test)

Example 44 with GATKRead

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

the class SampleCollectionUnitTest method testSampleIndexByReadWithReadGroupWithoutSample.

@Test(dataProvider = "samFileHeaderData", dependsOnMethods = "testCreation")
public void testSampleIndexByReadWithReadGroupWithoutSample(final SAMFileHeader header) {
    final String readGroup = header.getReadGroups().stream().filter(rg -> rg.getSample() == null).map(SAMReadGroupRecord::getId).findFirst().orElse(null);
    if (readGroup == null)
        return;
    final SampleCollection sampleCollection = new SampleCollection(header);
    final GATKRead read = ArtificialReadUtils.createRandomRead(header, 100);
    if (sampleCollection.sampleCount() > 0) {
        read.setReadGroup(readGroup);
        Assert.assertEquals(sampleCollection.sampleIndexByRead(read), -1);
    }
}
Also used : java.util(java.util) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) ArtificialReadUtils(org.broadinstitute.hellbender.utils.read.ArtificialReadUtils) Assert(org.testng.Assert) DataProvider(org.testng.annotations.DataProvider) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) BeforeClass(org.testng.annotations.BeforeClass) Test(org.testng.annotations.Test) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) Collectors(java.util.stream.Collectors) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMReadGroupRecord(htsjdk.samtools.SAMReadGroupRecord) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 45 with GATKRead

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

the class SampleCollectionUnitTest method testSampleIndexByReadWithNonExistentReadGroup.

@Test(dataProvider = "samFileHeaderData", dependsOnMethods = "testCreation", expectedExceptions = IllegalArgumentException.class)
public void testSampleIndexByReadWithNonExistentReadGroup(final SAMFileHeader header) {
    final SampleCollection sampleCollection = new SampleCollection(header);
    final GATKRead read = ArtificialReadUtils.createRandomRead(header, 100);
    read.setReadGroup("NON_EXISTENT");
    Assert.assertEquals(sampleCollection.sampleIndexByRead(read), -1);
}
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