use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk by broadinstitute.
the class VariantAnnotatorEngineUnitTest method testCoverageAnnotationOnDbSnpSite.
@Test
public void testCoverageAnnotationOnDbSnpSite() throws Exception {
final List<String> annotationGroupsToUse = Collections.emptyList();
//good one
final List<String> annotationsToUse = Arrays.asList(Coverage.class.getSimpleName());
final List<String> annotationsToExclude = Collections.emptyList();
final String path = publicTestDir + "Homo_sapiens_assembly19.dbsnp135.chr1_1M.exome_intervals.vcf";
final FeatureInput<VariantContext> dbSNPBinding = new FeatureInput<>(path, "dbsnp", Collections.emptyMap());
final List<FeatureInput<VariantContext>> features = Collections.emptyList();
final VariantAnnotatorEngine vae = VariantAnnotatorEngine.ofSelectedMinusExcluded(annotationGroupsToUse, annotationsToUse, annotationsToExclude, dbSNPBinding, features);
final Set<VCFHeaderLine> vcfAnnotationDescriptions = vae.getVCFAnnotationDescriptions();
Assert.assertTrue(vcfAnnotationDescriptions.contains(VCFStandardHeaderLines.getInfoLine(VCFConstants.DBSNP_KEY)));
final int alt = 5;
final int ref = 3;
final SimpleInterval loc = new SimpleInterval("1", 69428, 69428);
final VariantContext vcRS = new FeatureDataSource<VariantContext>(path, null, 0, VariantContext.class).query(loc).next();
final Allele refAllele = vcRS.getReference();
final Allele altAllele = vcRS.getAlternateAllele(0);
final VariantContext vcToAnnotate = makeVC(refAllele, altAllele, loc);
final ReadLikelihoods<Allele> likelihoods = makeReadLikelihoods(ref, alt, refAllele, altAllele, loc.getContig(), loc.getStart() - 5);
final FeatureContext featureContext = when(mock(FeatureContext.class).getValues(dbSNPBinding, loc.getStart())).thenReturn(Arrays.<VariantContext>asList(vcRS)).getMock();
final VariantContext resultVC = vae.annotateContext(vcToAnnotate, featureContext, null, likelihoods, a -> true);
Assert.assertEquals(resultVC.getCommonInfo().getAttribute(VCFConstants.DEPTH_KEY), String.valueOf(ref + alt));
Assert.assertEquals(resultVC.getID(), vcRS.getID());
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk by broadinstitute.
the class VariantAnnotatorEngineUnitTest method testCoverageAnnotationOnOverlapSite.
@Test
public void testCoverageAnnotationOnOverlapSite() throws Exception {
final List<String> annotationGroupsToUse = Collections.emptyList();
//good one
final List<String> annotationsToUse = Arrays.asList(Coverage.class.getSimpleName());
final List<String> annotationsToExclude = Collections.emptyList();
final String path = publicTestDir + "Homo_sapiens_assembly19.dbsnp135.chr1_1M.exome_intervals.vcf";
final FeatureInput<VariantContext> dbSNPBinding = null;
final String featureSourceName = "fred";
//we'll just reuse the DBSnp file under a different name
final FeatureInput<VariantContext> fredInput = new FeatureInput<>(path, featureSourceName, Collections.emptyMap());
final List<FeatureInput<VariantContext>> features = Arrays.asList(fredInput);
final VariantAnnotatorEngine vae = VariantAnnotatorEngine.ofSelectedMinusExcluded(annotationGroupsToUse, annotationsToUse, annotationsToExclude, dbSNPBinding, features);
final Set<VCFHeaderLine> vcfAnnotationDescriptions = vae.getVCFAnnotationDescriptions();
Assert.assertFalse(vcfAnnotationDescriptions.contains(VCFStandardHeaderLines.getInfoLine(VCFConstants.DBSNP_KEY)));
final VCFInfoHeaderLine fredHeaderLine = new VCFInfoHeaderLine(featureSourceName, 0, VCFHeaderLineType.Flag, featureSourceName + " Membership");
Assert.assertTrue(vcfAnnotationDescriptions.contains(fredHeaderLine));
final int alt = 5;
final int ref = 3;
final SimpleInterval loc = new SimpleInterval("1", 69428, 69428);
final VariantContext vcRS = new FeatureDataSource<VariantContext>(path, null, 0, VariantContext.class).query(loc).next();
final Allele refAllele = vcRS.getReference();
final Allele altAllele = vcRS.getAlternateAllele(0);
final VariantContext vcToAnnotate = makeVC(refAllele, altAllele, loc);
final ReadLikelihoods<Allele> likelihoods = makeReadLikelihoods(ref, alt, refAllele, altAllele, loc.getContig(), loc.getStart() - 5);
final FeatureContext featureContext = when(mock(FeatureContext.class).getValues(fredInput, loc.getStart())).thenReturn(Arrays.<VariantContext>asList(vcRS)).getMock();
final VariantContext resultVC = vae.annotateContext(vcToAnnotate, featureContext, null, likelihoods, a -> true);
Assert.assertEquals(resultVC.getCommonInfo().getAttribute(VCFConstants.DEPTH_KEY), String.valueOf(ref + alt));
Assert.assertEquals(resultVC.getID(), VCFConstants.EMPTY_ID_FIELD);
Assert.assertTrue((boolean) resultVC.getCommonInfo().getAttribute(featureSourceName));
Assert.assertNull(resultVC.getCommonInfo().getAttribute("does not exist"));
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk by broadinstitute.
the class VariantContextVariantAdapterTest method testVariantAdapter.
@Test(dataProvider = "VariantDataProvider")
public void testVariantAdapter(final List<GATKVariant> expectedVariantList) {
// The test suite for reading in VCF files is FeatureDataSourceUnitTest.
try (FeatureDataSource<VariantContext> featureSource = new FeatureDataSource<>(QUERY_TEST_VCF)) {
List<GATKVariant> variantList = new ArrayList<>();
for (VariantContext feature : featureSource) {
VariantContextVariantAdapter va = new VariantContextVariantAdapter(feature);
variantList.add(va);
}
// Now, test to see that every variant is in in the expected set.
Assert.assertEquals(variantList.size(), expectedVariantList.size());
for (GATKVariant v : variantList) {
boolean matchFound = false;
for (GATKVariant vv : expectedVariantList) {
if (VariantUtils.variantsAreEqual(v, vv)) {
matchFound = true;
}
}
Assert.assertTrue(matchFound, v.toString());
}
}
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource in project gatk by broadinstitute.
the class FilterByOrientationBiasIntegrationTest method testHighPloidyRun.
@Test
public void testHighPloidyRun() throws IOException {
final File outputFile = File.createTempFile("ob_high_ploidy", ".vcf");
final List<String> arguments = new ArrayList<>();
arguments.add("-" + FilterByOrientationBias.PRE_ADAPTER_METRICS_DETAIL_FILE_SHORT_NAME);
arguments.add(preAdapterQFile);
arguments.add("-" + StandardArgumentDefinitions.VARIANT_SHORT_NAME);
arguments.add(smallHighDiploid);
arguments.add("-" + StandardArgumentDefinitions.OUTPUT_SHORT_NAME);
arguments.add(outputFile.getAbsolutePath());
runCommandLine(arguments);
Assert.assertTrue(outputFile.exists());
final List<VariantContext> variantContexts = new ArrayList<>();
final FeatureDataSource<VariantContext> featureDataSource = new FeatureDataSource<>(outputFile);
for (final VariantContext vc : featureDataSource) {
variantContexts.add(vc);
}
Assert.assertEquals(variantContexts.size(), 1);
}
use of org.broadinstitute.hellbender.engine.FeatureDataSource 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);
}
Aggregations