Search in sources :

Example 31 with VariantContext

use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.

the class MappingQualityZeroUnitTest method testAllNull.

@Test(expectedExceptions = IllegalArgumentException.class)
public void testAllNull() throws Exception {
    final VariantContext vc = null;
    final ReferenceContext referenceContext = null;
    final InfoFieldAnnotation cov = new MappingQualityZero();
    //vc can't be null
    final Map<String, Object> annotate = cov.annotate(referenceContext, vc, null);
}
Also used : ReferenceContext(org.broadinstitute.hellbender.engine.ReferenceContext) VariantContext(htsjdk.variant.variantcontext.VariantContext) Test(org.testng.annotations.Test)

Example 32 with VariantContext

use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.

the class CreateSomaticPanelOfNormalsIntegrationTest method test.

/**
     * In the following test, we have sample1.vcf:
     * 20	577548	.	C	G	100	PASS	SOMATIC;VAF=0.48275862069;DPR=29.0	GT	0/1
     * 20	1838610	.	T	A	100	PASS	SOMATIC;VAF=0.5;DPR=35.3333333333	GT	0/1
     * 20	2916255	.	G	C	100	PASS	SOMATIC;VAF=0.5;DPR=20.0	GT	0/1
     * 20	5270544	.	C	A	100	PASS	SOMATIC;VAF=0.5;DPR=38.0	GT	0/1
     * 20	5758517	.	G	T	100	PASS	SOMATIC;VAF=0.478260869565;DPR=25.0	GT	0/1
     * 20	6947936	.	A	G	100	PASS	SOMATIC;VAF=0.5;DPR=32.0	GT	0/1
     * 20	7492891	.	G	A	100	PASS	SOMATIC;VAF=0.481481481481;DPR=28.3333333333	GT	0/1
     * 20	8957515	.	T	C	100	PASS	SOMATIC;VAF=0.5;DPR=27.6666666667	GT	0/1
     *
     * and sample2.vcf:
     * 20	577548	.	C	G	100	PASS	SOMATIC;VAF=0.48275862069;DPR=29.0	GT	0/1
     * 20	1838610	.	T	A	100	PASS	SOMATIC;VAF=0.5;DPR=35.3333333333	GT	0/1
     * 20	2916255	.	G	C	100	PASS	SOMATIC;VAF=0.5;DPR=20.0	GT	0/1
     * 20	7492891	.	G	A	100	PASS	SOMATIC;VAF=0.481481481481;DPR=28.3333333333	GT	0/1
     * 20	8957515	.	T	C	100	PASS	SOMATIC;VAF=0.5;DPR=27.6666666667	GT	0/1
     * 20	9080929	.	C	A	100	PASS	SOMATIC;VAF=0.487179487179;DPR=42.3333333333	GT	0/1
     * with overlap:
     * 20	577548	.	C	G
     * 20	1838610	.	T	A
     * 20	2916255	.	G	C
     * 20	7492891	.	G	A
     * 20	8957515	.	T	C

     * @throws IOException
     */
@Test
public void test() throws IOException {
    final File vcf1 = new File(PON_VCFS_DIR, "sample1.vcf");
    final File vcf2 = new File(PON_VCFS_DIR, "sample2.vcf");
    final File vcfInputFile = createTempFile("vcfs", ".list");
    FileUtils.writeLines(vcfInputFile, Arrays.asList(vcf1.getAbsolutePath(), vcf2.getAbsolutePath()));
    final File outputVcf = createTempFile("pon", ".vcf");
    final String[] args = { "-" + CreateSomaticPanelOfNormals.INPUT_VCFS_LIST_SHORT_NAME, vcfInputFile.getAbsolutePath(), "-O", outputVcf.getAbsolutePath() };
    runCommandLine(args);
    final List<VariantContext> ponVariants = StreamSupport.stream(new FeatureDataSource<VariantContext>(outputVcf).spliterator(), false).collect(Collectors.toList());
    Assert.assertEquals(ponVariants.size(), 5);
    final VariantContext vc1 = ponVariants.get(0);
    final VariantContext vc5 = ponVariants.get(4);
    Assert.assertEquals(vc1.getStart(), 577548);
    Assert.assertEquals(vc1.getNAlleles(), 2);
    Assert.assertTrue(vc1.getAlternateAllele(0).basesMatch("G"));
    Assert.assertEquals(vc5.getStart(), 8957515);
    Assert.assertEquals(vc5.getNAlleles(), 2);
    Assert.assertTrue(vc5.getAlternateAllele(0).basesMatch("C"));
}
Also used : VariantContext(htsjdk.variant.variantcontext.VariantContext) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 33 with VariantContext

use of htsjdk.variant.variantcontext.VariantContext in project gatk by broadinstitute.

the class Mutect2IntegrationTest method testTumorNormal.

// run tumor-only using the original DREAM synthetic sample 1 tumor and normal restricted to
// 1/3 of our dbSNP interval, in which there is only one true positive.
// we want to see that the number of false positives is small
@Test
public void testTumorNormal() throws Exception {
    Utils.resetRandomGenerator();
    final File outputVcf = createTempFile("output", ".vcf");
    final File tumorBam = new File(DREAM_BAMS_DIR, "tumor.bam");
    final String tumorName = "synthetic.challenge.set1.tumor";
    final File normalBam = new File(DREAM_BAMS_DIR, "normal.bam");
    final String normalName = "synthetic.challenge.set1.normal";
    final String[] args = { "-I", tumorBam.getAbsolutePath(), "-tumor", tumorName, "-I", normalBam.getAbsolutePath(), "-normal", normalName, "-R", b37_reference_20_21, // this is 1/3 of the chr 20 interval of our mini-dbSNP
    "-L", // this is 1/3 of the chr 20 interval of our mini-dbSNP
    "20:10000000-10100000", "-O", outputVcf.getAbsolutePath() };
    runCommandLine(args);
    final long numVariants = StreamSupport.stream(new FeatureDataSource<VariantContext>(outputVcf).spliterator(), false).count();
    Assert.assertTrue(numVariants < 4);
}
Also used : VariantContext(htsjdk.variant.variantcontext.VariantContext) File(java.io.File) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 34 with VariantContext

use of htsjdk.variant.variantcontext.VariantContext 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 35 with VariantContext

use of htsjdk.variant.variantcontext.VariantContext 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)

Aggregations

VariantContext (htsjdk.variant.variantcontext.VariantContext)237 Test (org.testng.annotations.Test)119 File (java.io.File)98 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)68 Allele (htsjdk.variant.variantcontext.Allele)55 Genotype (htsjdk.variant.variantcontext.Genotype)49 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)43 Collectors (java.util.stream.Collectors)43 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)43 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)41 FeatureDataSource (org.broadinstitute.hellbender.engine.FeatureDataSource)36 StandardArgumentDefinitions (org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions)35 java.util (java.util)33 IOException (java.io.IOException)25 Assert (org.testng.Assert)25 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)24 VCFFileReader (htsjdk.variant.vcf.VCFFileReader)22 UserException (org.broadinstitute.hellbender.exceptions.UserException)22 Target (org.broadinstitute.hellbender.tools.exome.Target)22 DataProvider (org.testng.annotations.DataProvider)22