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);
}
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"));
}
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);
}
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);
}
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);
}
Aggregations