Search in sources :

Example 31 with GATKRead

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

the class ReadFilterLibraryUnitTest method testSingleReadGroupFilter.

@Test
public void testSingleReadGroupFilter() {
    final SAMFileHeader header = createHeaderWithReadGroups();
    final GATKRead read = simpleGoodRead(header);
    final String fred = "fred";
    ReadGroupReadFilter f = new ReadGroupReadFilter();
    f.readGroup = "";
    read.setReadGroup(fred);
    //fail
    Assert.assertFalse(f.test(read), read.toString());
    f.readGroup = fred;
    //pass
    Assert.assertTrue(f.test(read), read.toString());
    f.readGroup = fred;
    read.setReadGroup(fred + "suffix");
    //fail - exact matching
    Assert.assertFalse(f.test(read), read.toString());
    f.readGroup = fred;
    read.setReadGroup(fred.toUpperCase());
    //fail - case sensitive matching
    Assert.assertFalse(f.test(read), read.toString());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Test(org.testng.annotations.Test)

Example 32 with GATKRead

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

the class MetricsReadFilterUnitTest method canRestrictToAlignedReadsOnly.

@Test
public void canRestrictToAlignedReadsOnly() {
    final GATKRead alignedRead = when(mock(GATKRead.class).isUnmapped()).thenReturn(false).getMock();
    final GATKRead unalignedRead = when(mock(GATKRead.class).isUnmapped()).thenReturn(true).getMock();
    assertTrue(this.alignedOnlyFilter.test(alignedRead), this.alignedOnlyFilter.toString());
    assertFalse(this.alignedOnlyFilter.test(unalignedRead), this.alignedOnlyFilter.toString());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Test(org.testng.annotations.Test)

Example 33 with GATKRead

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

the class MetricsReadFilterUnitTest method blocksSupplementaryAlignmentReads.

@Test
public void blocksSupplementaryAlignmentReads() {
    final GATKRead supplementaryAlignedRead = when(mock(GATKRead.class).isSupplementaryAlignment()).thenReturn(true).getMock();
    this.alwaysBlocks(supplementaryAlignedRead);
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Test(org.testng.annotations.Test)

Example 34 with GATKRead

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

the class MetricsReadFilterUnitTest method canRestrictToBothAlignedAndPfReads.

@Test
public void canRestrictToBothAlignedAndPfReads() {
    final GATKRead alignedAndPfRead = mock(GATKRead.class);
    when(alignedAndPfRead.isUnmapped()).thenReturn(false);
    when(alignedAndPfRead.failsVendorQualityCheck()).thenReturn(false);
    assertTrue(this.pfAndAlignedOnlyFilter.test(alignedAndPfRead));
    final GATKRead alignedButNotPfRead = mock(GATKRead.class);
    when(alignedButNotPfRead.isUnmapped()).thenReturn(false);
    when(alignedButNotPfRead.failsVendorQualityCheck()).thenReturn(true);
    assertFalse(this.pfAndAlignedOnlyFilter.test(alignedButNotPfRead));
    final GATKRead pfButUnalignedRead = mock(GATKRead.class);
    when(pfButUnalignedRead.failsVendorQualityCheck()).thenReturn(false);
    when(pfButUnalignedRead.isUnmapped()).thenReturn(true);
    assertFalse(this.pfAndAlignedOnlyFilter.test(pfButUnalignedRead));
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) Test(org.testng.annotations.Test)

Example 35 with GATKRead

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

the class MetricsReadFilterUnitTest method canRestrictToPfReadsOnly.

@Test
public void canRestrictToPfReadsOnly() {
    final GATKRead pfRead = when(mock(GATKRead.class).failsVendorQualityCheck()).thenReturn(false).getMock();
    final GATKRead nonPfRead = when(mock(GATKRead.class).failsVendorQualityCheck()).thenReturn(true).getMock();
    assertTrue(this.pfOnlyFilter.test(pfRead), this.pfOnlyFilter.toString());
    assertFalse(this.pfOnlyFilter.test(nonPfRead), this.pfOnlyFilter.toString());
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) 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