Search in sources :

Example 66 with SimpleInterval

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

the class HashedListTargetCollectionUnitTest method testRandomLookupTargetByLocation.

@Test
public void testRandomLookupTargetByLocation() {
    final Object[][] lookups = targetLookUpData();
    final Random rdn = new Random(11132331);
    for (int i = 0; i < 1000; i++) {
        final Object[] params = lookups[rdn.nextInt(lookups.length)];
        @SuppressWarnings("unchecked") final SimpleInterval query = (SimpleInterval) params[0];
        @SuppressWarnings("unchecked") final SimpleInterval expected = (SimpleInterval) params[1];
        final SimpleInterval observed = targetDB.target(query);
        Assert.assertEquals(observed, expected);
    }
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 67 with SimpleInterval

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

the class HashedListTargetCollectionUnitTest method trimmedIntervalData.

@DataProvider(name = "trimmedIntervalData")
public Object[][] trimmedIntervalData() {
    //alias to reduce clutter
    final List<SimpleInterval> intervals = nonOverlappingTargetIntervals;
    final String contig = intervals.get(0).getContig();
    //find the last index of the first contig
    int j = 0;
    while (j < intervals.size() && intervals.get(j).getContig().equals(contig)) {
        j++;
    }
    j--;
    //shift of untrimmed interval ends
    final int offset = minimumTargetIntergapSize / 2;
    // Each data row is {untrimmed interval, epected trimmed interval
    final int firstTargetStart = intervals.get(0).getStart();
    final int firstTargetEnd = intervals.get(0).getEnd();
    final int lastTargetEnd = intervals.get(j).getEnd();
    return new Object[][] { //bracket a single target
    { new SimpleInterval(contig, firstTargetStart - offset, firstTargetEnd + offset), new SimpleInterval(contig, firstTargetStart, firstTargetEnd) }, //within a single target
    { new SimpleInterval(contig, firstTargetEnd - 1, firstTargetEnd + offset), new SimpleInterval(contig, firstTargetStart, firstTargetEnd) }, //a lot of targets
    { new SimpleInterval(contig, firstTargetStart - offset, lastTargetEnd + offset), new SimpleInterval(contig, firstTargetStart, lastTargetEnd) }, //past the last target
    { new SimpleInterval(contig, lastTargetEnd + 1, lastTargetEnd + 2), new SimpleInterval(contig, lastTargetEnd + 1, lastTargetEnd + 1) }, //a non-existant contig
    { new SimpleInterval("non-existant contig", 1, 10), new SimpleInterval("non-existant contig", 1, 1) } };
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) DataProvider(org.testng.annotations.DataProvider)

Example 68 with SimpleInterval

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

the class HashedListTargetCollectionUnitTest method targetLookUpData.

@DataProvider(name = "targetLookUpData")
public Object[][] targetLookUpData() {
    final List<Object[]> result = new ArrayList<>();
    for (int i = 0; i < nonOverlappingTargetIntervals.size(); i++) {
        result.add(new Object[] { nonOverlappingTargetIntervals.get(i), nonOverlappingTargetIntervals.get(i), i });
    }
    for (int i = 0; i < nonOverlappingTargetIntervals.size(); i++) {
        final SimpleInterval interval = nonOverlappingTargetIntervals.get(i);
        result.add(new Object[] { new SimpleInterval(interval.getContig(), interval.getStart(), interval.getStart()), interval, i });
    }
    for (int i = 0; i < nonOverlappingTargetIntervals.size(); i++) {
        final SimpleInterval interval = nonOverlappingTargetIntervals.get(i);
        result.add(new Object[] { new SimpleInterval(interval.getContig(), interval.getEnd(), interval.getEnd()), interval, i });
    }
    for (int i = 1; i < nonOverlappingTargetIntervals.size(); i++) {
        final SimpleInterval previous = nonOverlappingTargetIntervals.get(i - 1);
        final SimpleInterval next = nonOverlappingTargetIntervals.get(i);
        final SimpleInterval query = previous.getContig().equals(next.getContig()) ? TargetsToolsTestUtils.createInterval(previous.getContig(), previous.getEnd() + 1, next.getStart() - 1) : TargetsToolsTestUtils.createInterval(next.getContig(), 1, next.getStart() - 1);
        result.add(new Object[] { query, null, -i - 1 });
    }
    return result.toArray(new Object[result.size()][]);
}
Also used : SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) DataProvider(org.testng.annotations.DataProvider)

Example 69 with SimpleInterval

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

the class GetBayesianHetCoverageIntegrationTest method testMatchedNormalTumorJob.

@Test
public void testMatchedNormalTumorJob() {
    final File normalOutputFile = createTempFile("normal-test", ".tsv");
    final File tumorOutputFile = createTempFile("tumor-test", ".tsv");
    Pulldown tumorHetPulldownExpected, tumorHetPulldownResult;
    Pulldown normalHetPulldownExpected, normalHetPulldownResult;
    final String[] arguments = { "-" + StandardArgumentDefinitions.REFERENCE_SHORT_NAME, REF_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.SNP_FILE_SHORT_NAME, SNP_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.NORMAL_BAM_FILE_SHORT_NAME, NORMAL_BAM_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.NORMAL_ALLELIC_COUNTS_FILE_SHORT_NAME, normalOutputFile.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_BAM_FILE_SHORT_NAME, TUMOR_BAM_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_ALLELIC_COUNTS_FILE_SHORT_NAME, tumorOutputFile.getAbsolutePath(), "-" + GetBayesianHetCoverage.READ_DEPTH_THRESHOLD_SHORT_NAME, Integer.toString(10), "-" + GetBayesianHetCoverage.HET_CALLING_STRINGENCY_SHORT_NAME, Double.toString(10.0) };
    runCommandLine(arguments);
    normalHetPulldownResult = new Pulldown(normalOutputFile, normalHeader);
    tumorHetPulldownResult = new Pulldown(tumorOutputFile, tumorHeader);
    normalHetPulldownExpected = new Pulldown(normalHeader);
    normalHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6, Nucleotide.G, Nucleotide.T, 14, 29.29));
    normalHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8, Nucleotide.T, Nucleotide.G, 17, 39.98));
    normalHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9, Nucleotide.T, Nucleotide.G, 15, 28.60));
    normalHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14982, 14982), 6, 5, Nucleotide.G, Nucleotide.C, 11, 24.99));
    tumorHetPulldownExpected = new Pulldown(tumorHeader);
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6, Nucleotide.G, Nucleotide.T, 14));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8, Nucleotide.T, Nucleotide.G, 17));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9, Nucleotide.T, Nucleotide.G, 15));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14982, 14982), 6, 5, Nucleotide.G, Nucleotide.C, 11));
    Assert.assertEquals(normalHetPulldownExpected, normalHetPulldownResult);
    Assert.assertEquals(tumorHetPulldownExpected, tumorHetPulldownResult);
}
Also used : Pulldown(org.broadinstitute.hellbender.tools.exome.pulldown.Pulldown) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) File(java.io.File) AllelicCount(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 70 with SimpleInterval

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

the class GetBayesianHetCoverageIntegrationTest method testTumorJob.

@Test
public void testTumorJob() {
    final File tumorOutputFile = createTempFile("tumor-test", ".tsv");
    Pulldown tumorHetPulldownExpected, tumorHetPulldownResult;
    /* test 1: tight calling stringency */
    final String[] args_1 = { "-" + StandardArgumentDefinitions.REFERENCE_SHORT_NAME, REF_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.SNP_FILE_SHORT_NAME, SNP_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_BAM_FILE_SHORT_NAME, TUMOR_BAM_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_ALLELIC_COUNTS_FILE_SHORT_NAME, tumorOutputFile.getAbsolutePath(), "-" + GetBayesianHetCoverage.READ_DEPTH_THRESHOLD_SHORT_NAME, Integer.toString(10), "-" + GetBayesianHetCoverage.HET_CALLING_STRINGENCY_SHORT_NAME, Double.toString(10.0) };
    runCommandLine(args_1);
    tumorHetPulldownExpected = new Pulldown(tumorHeader);
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6, Nucleotide.G, Nucleotide.T, 14, 24.85));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8, Nucleotide.T, Nucleotide.G, 17, 34.03));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9, Nucleotide.T, Nucleotide.G, 15, 24.23));
    tumorHetPulldownResult = new Pulldown(tumorOutputFile, tumorHeader);
    Assert.assertEquals(tumorHetPulldownExpected, tumorHetPulldownResult);
    /* test 2: tight calling stringency */
    final String[] args_2 = { "-" + StandardArgumentDefinitions.REFERENCE_SHORT_NAME, REF_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.SNP_FILE_SHORT_NAME, SNP_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_BAM_FILE_SHORT_NAME, TUMOR_BAM_FILE.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_ALLELIC_COUNTS_FILE_SHORT_NAME, tumorOutputFile.getAbsolutePath(), "-" + GetBayesianHetCoverage.READ_DEPTH_THRESHOLD_SHORT_NAME, Integer.toString(10), "-" + GetBayesianHetCoverage.HET_CALLING_STRINGENCY_SHORT_NAME, Double.toString(5.0) };
    runCommandLine(args_2);
    tumorHetPulldownExpected = new Pulldown(tumorHeader);
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 11522, 11522), 7, 4, Nucleotide.G, Nucleotide.A, 11, 15.72));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 12098, 12098), 8, 6, Nucleotide.G, Nucleotide.T, 14, 24.85));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("1", 14630, 14630), 9, 8, Nucleotide.T, Nucleotide.G, 17, 34.03));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14689, 14689), 6, 9, Nucleotide.T, Nucleotide.G, 15, 24.23));
    tumorHetPulldownExpected.add(new AllelicCount(new SimpleInterval("2", 14982, 14982), 6, 5, Nucleotide.G, Nucleotide.C, 11, 21.23));
    tumorHetPulldownResult = new Pulldown(tumorOutputFile, tumorHeader);
    Assert.assertEquals(tumorHetPulldownExpected, tumorHetPulldownResult);
}
Also used : Pulldown(org.broadinstitute.hellbender.tools.exome.pulldown.Pulldown) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) File(java.io.File) AllelicCount(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

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