Search in sources :

Example 1 with Main

use of org.broadinstitute.hellbender.Main in project gatk by broadinstitute.

the class Mutect2IntegrationTest method testPon.

// make a pon with a tumor and then use this pon to call somatic variants on the same tumor
// if the pon is doing its job all calls should be filtered by this pon
@Test(dataProvider = "dreamSyntheticDataSample1")
public void testPon(final File tumorBam, final String tumorSample, final File normalBam, final String normalSample) throws Exception {
    Utils.resetRandomGenerator();
    final File ponVcf = createTempFile("pon", ".vcf");
    final String[] createPonArgs = { "-I", tumorBam.getAbsolutePath(), "-tumor", tumorSample, "-I", normalBam.getAbsolutePath(), "-normal", normalSample, "-R", b37_reference_20_21, "-L", "20", "-O", ponVcf.getAbsolutePath() };
    runCommandLine(createPonArgs);
    final File unfilteredVcf = createTempFile("unfiltered", ".vcf");
    final File filteredVcf = createTempFile("filtered", ".vcf");
    final String[] callWithPonArgs = { "-I", tumorBam.getAbsolutePath(), "-tumor", tumorSample, "-I", normalBam.getAbsolutePath(), "-normal", normalSample, "-normal_panel", ponVcf.getAbsolutePath(), "-R", b37_reference_20_21, "-L", "20", "-O", unfilteredVcf.getAbsolutePath() };
    runCommandLine(callWithPonArgs);
    // run FilterMutectCalls
    new Main().instanceMain(makeCommandLineArgs(Arrays.asList("-V", unfilteredVcf.getAbsolutePath(), "-O", filteredVcf.getAbsolutePath()), "FilterMutectCalls"));
    final long numVariants = StreamSupport.stream(new FeatureDataSource<VariantContext>(filteredVcf).spliterator(), false).filter(vc -> vc.getFilters().isEmpty()).count();
    Assert.assertEquals(numVariants, 0);
}
Also used : Arrays(java.util.Arrays) ConcordanceSummaryRecord(org.broadinstitute.hellbender.tools.walkers.validation.ConcordanceSummaryRecord) DataProvider(org.testng.annotations.DataProvider) Set(java.util.Set) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) File(java.io.File) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) Assert(org.testng.Assert) Main(org.broadinstitute.hellbender.Main) FeatureDataSource(org.broadinstitute.hellbender.engine.FeatureDataSource) VariantContext(htsjdk.variant.variantcontext.VariantContext) Utils(org.broadinstitute.hellbender.utils.Utils) StreamSupport(java.util.stream.StreamSupport) File(java.io.File) Main(org.broadinstitute.hellbender.Main) FeatureDataSource(org.broadinstitute.hellbender.engine.FeatureDataSource) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 2 with Main

use of org.broadinstitute.hellbender.Main in project gatk by broadinstitute.

the class Mutect2IntegrationTest method testTumorOnly.

// run tumor-only using our mini gnomAD on NA12878, which is not a tumor
// we're just making sure nothing blows up
@Test
public void testTumorOnly() throws Exception {
    Utils.resetRandomGenerator();
    final File unfilteredVcf = createTempFile("unfiltered", ".vcf");
    final File filteredVcf = createTempFile("filtered", ".vcf");
    final String[] args = { "-I", NA12878_20_21_WGS_bam, "-tumor", "NA12878", "-R", b37_reference_20_21, "-L", "20:10000000-10010000", "-germline_resource", GNOMAD.getAbsolutePath(), "-O", unfilteredVcf.getAbsolutePath() };
    runCommandLine(args);
    // run FilterMutectCalls
    new Main().instanceMain(makeCommandLineArgs(Arrays.asList("-V", unfilteredVcf.getAbsolutePath(), "-O", filteredVcf.getAbsolutePath()), "FilterMutectCalls"));
    final long numVariantsBeforeFiltering = StreamSupport.stream(new FeatureDataSource<VariantContext>(filteredVcf).spliterator(), false).count();
    final long numVariantsPassingFilters = StreamSupport.stream(new FeatureDataSource<VariantContext>(filteredVcf).spliterator(), false).filter(vc -> vc.getFilters().isEmpty()).count();
    // just a sanity check that this bam has some germline variants on this interval so that our test doesn't pass trivially!
    Assert.assertTrue(numVariantsBeforeFiltering > 50);
    // every variant on this interval in this sample is in gnomAD
    Assert.assertTrue(numVariantsPassingFilters < 2);
}
Also used : Arrays(java.util.Arrays) ConcordanceSummaryRecord(org.broadinstitute.hellbender.tools.walkers.validation.ConcordanceSummaryRecord) DataProvider(org.testng.annotations.DataProvider) Set(java.util.Set) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) File(java.io.File) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) Assert(org.testng.Assert) Main(org.broadinstitute.hellbender.Main) FeatureDataSource(org.broadinstitute.hellbender.engine.FeatureDataSource) VariantContext(htsjdk.variant.variantcontext.VariantContext) Utils(org.broadinstitute.hellbender.utils.Utils) StreamSupport(java.util.stream.StreamSupport) VariantContext(htsjdk.variant.variantcontext.VariantContext) File(java.io.File) Main(org.broadinstitute.hellbender.Main) FeatureDataSource(org.broadinstitute.hellbender.engine.FeatureDataSource) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 3 with Main

use of org.broadinstitute.hellbender.Main in project gatk-protected by broadinstitute.

the class Mutect2IntegrationTest method testDreamTumorNormal.

/**
     * Several DREAM challenge bams with synthetic truth data.  In order to keep file sizes manageable, bams are restricted
     * to chromosome 20, leaving ~100-200 variants, and then further restricted to 400-bp intervals centered around
     * these variants.
     *
     * Because this truth data is synthetic, ideal performance is perfect concordance with the truth vcfs.
     *
     * The characteristics of the data are as follows (note that we removed structural variants from the original
     * DREAM challenge vcfs):
     *
     * Sample 1: pure monoclonal sample, SNVs only
     * Sample2: 80% pure monoclonal sample, SNVs only
     * Sample3: pure triclonal sample, subclone minor allele frequencies are 1/2, 1/3, and 1/5, SNVs and indels
     * Sample 4: 80% biclonal sample, subclone minor allele fractions are 50% and 35%, SNVs and indels
     *
     * @throws Exception
     */
@Test(dataProvider = "dreamSyntheticData")
public void testDreamTumorNormal(final File tumorBam, final String tumorSample, final File normalBam, final String normalSample, final File truthVcf, final File mask, final double requiredSensitivity) throws Exception {
    Utils.resetRandomGenerator();
    final File unfilteredVcf = createTempFile("unfiltered", ".vcf");
    final File filteredVcf = createTempFile("filtered", ".vcf");
    final String[] args = { "-I", tumorBam.getAbsolutePath(), "-tumor", tumorSample, "-I", normalBam.getAbsolutePath(), "-normal", normalSample, "-R", b37_reference_20_21, "-L", "20", "-germline_resource", GNOMAD.getAbsolutePath(), "-XL", mask.getAbsolutePath(), "-O", unfilteredVcf.getAbsolutePath() };
    runCommandLine(args);
    // run FilterMutectCalls
    new Main().instanceMain(makeCommandLineArgs(Arrays.asList("-V", unfilteredVcf.getAbsolutePath(), "-O", filteredVcf.getAbsolutePath()), "FilterMutectCalls"));
    // run Concordance
    final File concordanceSummary = createTempFile("concordance", ".txt");
    new Main().instanceMain(makeCommandLineArgs(Arrays.asList("-truth", truthVcf.getAbsolutePath(), "-eval", unfilteredVcf.getAbsolutePath(), "-L", "20", "-XL", mask.getAbsolutePath(), "-summary", concordanceSummary.getAbsolutePath()), "Concordance"));
    final List<ConcordanceSummaryRecord> summaryRecords = new ConcordanceSummaryRecord.Reader(concordanceSummary).toList();
    summaryRecords.forEach(rec -> {
        if (rec.getTruePositives() + rec.getFalseNegatives() > 0) {
            Assert.assertTrue(rec.getSensitivity() > requiredSensitivity);
            Assert.assertTrue(rec.getPrecision() > 0.5);
        }
    });
}
Also used : File(java.io.File) Main(org.broadinstitute.hellbender.Main) ConcordanceSummaryRecord(org.broadinstitute.hellbender.tools.walkers.validation.ConcordanceSummaryRecord) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 4 with Main

use of org.broadinstitute.hellbender.Main in project gatk by broadinstitute.

the class BothStepsOfBQSRIntegrationTest method testIndelRemoval.

//Tests that BQSR with and without indel recalibration produces the same bam file
@Test
public void testIndelRemoval() throws Exception {
    //Note; using a small 27M file for speed
    final File bamIn = new File(NA12878_20_21_WGS_bam);
    final String interval = "20";
    final File recalOutWithIndels = baseRecalibrator(bamIn, interval, false);
    final File bamOutWithIndels = applyBQSR(bamIn, interval, recalOutWithIndels, false);
    final File recalOutWithoutIndels = baseRecalibrator(bamIn, interval, true);
    final File bamOutWithoutIndels = applyBQSR(bamIn, interval, recalOutWithoutIndels, true);
    final ArgumentsBuilder args1 = new ArgumentsBuilder();
    args1.addArgument("VALIDATION_STRINGENCY", ValidationStringency.SILENT.name());
    args1.addPositionalArgument(bamOutWithIndels.getAbsolutePath());
    args1.addPositionalArgument(bamOutWithoutIndels.getAbsolutePath());
    final Object result = new Main().instanceMain(makeCommandLineArgs(args1.getArgsList(), CompareBaseQualities.class.getSimpleName()));
    Assert.assertEquals(result, 0);
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Main(org.broadinstitute.hellbender.Main) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 5 with Main

use of org.broadinstitute.hellbender.Main in project gatk by broadinstitute.

the class BothStepsOfBQSRIntegrationTest method applyBQSR.

private File applyBQSR(final File bamIn, final String interval, final File recalOut, final boolean skipIndels) {
    final File bamOut = BaseTest.createTempFile("applyBQSR." + skipIndels, ".bam");
    final ArgumentsBuilder args1 = new ArgumentsBuilder();
    args1.addInput(bamIn);
    args1.addFileArgument("bqsr", recalOut);
    args1.addArgument("L", interval);
    args1.addOutput(bamOut);
    new Main().instanceMain(makeCommandLineArgs(args1.getArgsList(), ApplyBQSR.class.getSimpleName()));
    return bamOut;
}
Also used : ArgumentsBuilder(org.broadinstitute.hellbender.utils.test.ArgumentsBuilder) File(java.io.File) Main(org.broadinstitute.hellbender.Main)

Aggregations

File (java.io.File)9 Main (org.broadinstitute.hellbender.Main)9 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)7 Test (org.testng.annotations.Test)7 ConcordanceSummaryRecord (org.broadinstitute.hellbender.tools.walkers.validation.ConcordanceSummaryRecord)6 VariantContext (htsjdk.variant.variantcontext.VariantContext)4 Arrays (java.util.Arrays)4 List (java.util.List)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 StreamSupport (java.util.stream.StreamSupport)4 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)4 Pair (org.apache.commons.lang3.tuple.Pair)4 FeatureDataSource (org.broadinstitute.hellbender.engine.FeatureDataSource)4 Utils (org.broadinstitute.hellbender.utils.Utils)4 DataProvider (org.testng.annotations.DataProvider)4 ArgumentsBuilder (org.broadinstitute.hellbender.utils.test.ArgumentsBuilder)3 Assert (junit.framework.Assert)2 Assert (org.testng.Assert)2 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1