Search in sources :

Example 76 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class IntervalAlignmentContextIteratorUnitTest method testCoveredOnly.

@Test
public void testCoveredOnly() {
    // This test is good at finding places where the alignment contexts start behind the interval.
    // Totally covered
    final SimpleInterval record_20_9999910_9999913 = new SimpleInterval("20:9999910-9999913");
    final List<SimpleInterval> locusIntervals = new ArrayList<>(1);
    locusIntervals.add(record_20_9999910_9999913);
    final List<AlignmentContext> allAlignmentContexts = getAlignmentContexts(locusIntervals, BAM_FILE_NAME);
    Assert.assertEquals(allAlignmentContexts.size(), 4);
    Assert.assertTrue(allAlignmentContexts.stream().allMatch(ac -> ac != null));
}
Also used : IntStream(java.util.stream.IntStream) ReadsDataSource(org.broadinstitute.hellbender.engine.ReadsDataSource) java.util(java.util) IOUtils(org.broadinstitute.hellbender.utils.io.IOUtils) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) Test(org.testng.annotations.Test) LocusIteratorByState(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByState) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) File(java.io.File) IntervalUtils(org.broadinstitute.hellbender.utils.IntervalUtils) Stream(java.util.stream.Stream) Assert(org.testng.Assert) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) AlignmentContext(org.broadinstitute.hellbender.engine.AlignmentContext) Utils(org.broadinstitute.hellbender.utils.Utils) StreamSupport(java.util.stream.StreamSupport) ReadFilterLibrary(org.broadinstitute.hellbender.engine.filters.ReadFilterLibrary) AlignmentContext(org.broadinstitute.hellbender.engine.AlignmentContext) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 77 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class IntervalAlignmentContextIteratorUnitTest method testUnCoveredOnly.

@Test
public void testUnCoveredOnly() {
    final SimpleInterval record_20_9999900_9999901 = new SimpleInterval("20:9999900-9999901");
    final List<SimpleInterval> locusIntervals = new ArrayList<>(1);
    locusIntervals.add(record_20_9999900_9999901);
    final List<AlignmentContext> allAlignmentContexts = getAlignmentContexts(locusIntervals, BAM_FILE_NAME);
    Assert.assertEquals(allAlignmentContexts.size(), 2);
    Assert.assertTrue(allAlignmentContexts.stream().allMatch(ac -> ac != null));
    Assert.assertEquals(allAlignmentContexts.get(0).getBasePileup().getReads().size(), 0);
    Assert.assertEquals(allAlignmentContexts.get(1).getBasePileup().getReads().size(), 0);
}
Also used : IntStream(java.util.stream.IntStream) ReadsDataSource(org.broadinstitute.hellbender.engine.ReadsDataSource) java.util(java.util) IOUtils(org.broadinstitute.hellbender.utils.io.IOUtils) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) Test(org.testng.annotations.Test) LocusIteratorByState(org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByState) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) File(java.io.File) IntervalUtils(org.broadinstitute.hellbender.utils.IntervalUtils) Stream(java.util.stream.Stream) Assert(org.testng.Assert) WellformedReadFilter(org.broadinstitute.hellbender.engine.filters.WellformedReadFilter) AlignmentContext(org.broadinstitute.hellbender.engine.AlignmentContext) Utils(org.broadinstitute.hellbender.utils.Utils) StreamSupport(java.util.stream.StreamSupport) ReadFilterLibrary(org.broadinstitute.hellbender.engine.filters.ReadFilterLibrary) AlignmentContext(org.broadinstitute.hellbender.engine.AlignmentContext) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 78 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class IntervalLocusIteratorUnitTest method testSimpleSinglePoints.

@Test
public void testSimpleSinglePoints() {
    final SimpleInterval record_1_1_1 = new SimpleInterval("1:1-1");
    final SimpleInterval record_1_5_5 = new SimpleInterval("1:5-5");
    List<SimpleInterval> intervals = new ArrayList<>();
    intervals.add(record_1_1_1);
    intervals.add(record_1_5_5);
    final IntervalLocusIterator intervalLocusIterator = new IntervalLocusIterator(intervals.iterator());
    final List<SimpleInterval> newIntervals = StreamSupport.stream(Spliterators.spliteratorUnknownSize(intervalLocusIterator, Spliterator.ORDERED), false).collect(Collectors.toList());
    Assert.assertEquals(newIntervals.size(), 2);
    Assert.assertEquals(newIntervals.get(0).getStart(), 1);
    Assert.assertEquals(newIntervals.get(1).getStart(), 5);
    Assert.assertEquals(newIntervals.get(0).getEnd(), 1);
    Assert.assertEquals(newIntervals.get(1).getEnd(), 5);
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 79 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class IntervalLocusIteratorUnitTest method testSlightChallenge.

@Test
public void testSlightChallenge() {
    final SimpleInterval record_20_9999600_9999800 = new SimpleInterval("20:9999600-9999600");
    final SimpleInterval record_20_9999800_10000000 = new SimpleInterval("20:9999800-10000000");
    final SimpleInterval record_20_10000050_10000100 = new SimpleInterval("20:10000050-10000100");
    List<SimpleInterval> intervals = new ArrayList<>();
    intervals.add(record_20_9999600_9999800);
    intervals.add(record_20_9999800_10000000);
    intervals.add(record_20_10000050_10000100);
    final IntervalLocusIterator intervalLocusIterator = new IntervalLocusIterator(intervals.iterator());
    final List<SimpleInterval> newIntervals = StreamSupport.stream(Spliterators.spliteratorUnknownSize(intervalLocusIterator, Spliterator.ORDERED), false).collect(Collectors.toList());
    Assert.assertEquals(newIntervals.size(), 253);
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 80 with SimpleInterval

use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.

the class IntervalLocusIteratorUnitTest method testSimple.

@Test
public void testSimple() {
    final SimpleInterval record_1_1_100 = new SimpleInterval("1:1-100");
    final SimpleInterval record_1_500_600 = new SimpleInterval("1:500-600");
    final SimpleInterval record_1_800_800 = new SimpleInterval("1:800-800");
    List<SimpleInterval> intervals = new ArrayList<>();
    intervals.add(record_1_1_100);
    intervals.add(record_1_500_600);
    intervals.add(record_1_800_800);
    final IntervalLocusIterator intervalLocusIterator = new IntervalLocusIterator(intervals.iterator());
    final List<SimpleInterval> newIntervals = StreamSupport.stream(Spliterators.spliteratorUnknownSize(intervalLocusIterator, Spliterator.ORDERED), false).collect(Collectors.toList());
    Assert.assertEquals(newIntervals.size(), 202);
    Assert.assertEquals(newIntervals.get(0).getStart(), 1);
    Assert.assertEquals(newIntervals.get(1).getStart(), 2);
    Assert.assertEquals(newIntervals.get(99).getStart(), 100);
    Assert.assertEquals(newIntervals.get(100).getStart(), 500);
    Assert.assertEquals(newIntervals.get(200).getStart(), 600);
    Assert.assertEquals(newIntervals.get(201).getStart(), 800);
    // Make sure that start = end for all intervals coming out of the LocusIntervalIterator, since each is only 1 bp
    Assert.assertTrue(newIntervals.stream().allMatch(i -> i.getEnd() == i.getStart()));
}
Also used : java.util(java.util) Assert(org.testng.Assert) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) StreamSupport(java.util.stream.StreamSupport) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)545 Test (org.testng.annotations.Test)287 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)202 File (java.io.File)102 ArrayList (java.util.ArrayList)66 DataProvider (org.testng.annotations.DataProvider)64 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)60 Collectors (java.util.stream.Collectors)53 java.util (java.util)41 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)40 AllelicCount (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount)40 UserException (org.broadinstitute.hellbender.exceptions.UserException)39 VariantContext (htsjdk.variant.variantcontext.VariantContext)36 IntStream (java.util.stream.IntStream)34 Target (org.broadinstitute.hellbender.tools.exome.Target)34 IOException (java.io.IOException)32 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)28 Assert (org.testng.Assert)27 Locatable (htsjdk.samtools.util.Locatable)26 List (java.util.List)26