use of org.broadinstitute.hellbender.utils.SimpleInterval 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.utils.SimpleInterval in project gatk by broadinstitute.
the class VariantOverlapAnnotatorUnitTest method testRsIDFeatureContextWithNoDBSnP.
@Test(dataProvider = "AnnotateRsIDData")
public void testRsIDFeatureContextWithNoDBSnP(final VariantContext toAnnotate, final List<VariantContext> dbSNPRecords, final String expectedID, final boolean expectOverlap) throws Exception {
final File file = new File(publicTestDir + "Homo_sapiens_assembly19.dbsnp135.chr1_1M.exome_intervals.vcf");
final FeatureContext ctx = new FeatureContext(new FeatureManager(new ArtificialFeatureContainingCommandLineProgram_ForVariantOverlap(file)), new SimpleInterval(toAnnotate));
final VariantOverlapAnnotator annotator = makeAnnotator(file, null, "binding");
final VariantContext annotated = annotator.annotateRsID(ctx, toAnnotate);
Assert.assertNotNull(annotated);
//nothing at given position
Assert.assertEquals(annotated, toAnnotate);
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class FragmentCollectionUnitTest method createFromMultiSamplePileup.
@Test
public void createFromMultiSamplePileup() throws Exception {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeader();
final GATKRead read1 = ArtificialReadUtils.createArtificialRead(header, "10M");
final GATKRead read2 = ArtificialReadUtils.createArtificialRead(header, "10M");
read1.setPosition(new SimpleInterval("22", 200, 210));
read2.setPosition(new SimpleInterval("22", 208, 218));
read1.setMatePosition(read2);
read2.setMatePosition(read1);
final Locatable loc = new SimpleInterval("22", 208, 208);
final Map<String, ReadPileup> stratified = new LinkedHashMap<>();
stratified.put("sample1", new ReadPileup(loc, Arrays.asList(read2), 0));
stratified.put("sample2", new ReadPileup(loc, Arrays.asList(read1), 9));
final ReadPileup combined = new ReadPileup(loc, stratified);
final FragmentCollection<PileupElement> elements = FragmentCollection.create(combined);
Assert.assertTrue(elements.getSingletonReads().isEmpty());
Assert.assertEquals(elements.getOverlappingPairs().size(), 1);
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class IntervalsSkipListOneContigUnitTest method testEmptyInput.
@Test
public void testEmptyInput() throws Exception {
List<Locatable> empty = new ArrayList<>();
final IntervalsSkipListOneContig<Locatable> l = new IntervalsSkipListOneContig<>(empty);
//try to fool it by using empty contig
Assert.assertTrue(l.getOverlapping(new SimpleInterval("", 10, 100)).isEmpty());
Assert.assertTrue(l.getOverlapping(new SimpleInterval("1", 10, 100)).isEmpty());
}
use of org.broadinstitute.hellbender.utils.SimpleInterval in project gatk by broadinstitute.
the class IntervalsSkipListOneContigUnitTest method intervals.
@DataProvider(name = "intervals")
public Object[][] intervals() {
ArrayList<Locatable> input = Lists.newArrayList(new SimpleInterval("1", 10, 100));
ArrayList<Locatable> empty = new ArrayList<>();
ArrayList<Locatable> manyOverlapping = Lists.newArrayList(new SimpleInterval("1", 10, 100), // special case: multiple intervals starting at the same place
new SimpleInterval("1", 20, 50), new SimpleInterval("1", 20, 50), new SimpleInterval("1", 20, 50));
ArrayList<Locatable> mixInput = Lists.newArrayList(// ends before query interval
new SimpleInterval("1", 10, 20), // ends in query interval
new SimpleInterval("1", 10, 60), // equal to query interval
new SimpleInterval("1", 30, 50), // covered by query interval
new SimpleInterval("1", 40, 42), // ends after query interval
new SimpleInterval("1", 45, 60), // starts after query interval
new SimpleInterval("1", 60, 100));
ArrayList<Locatable> mixExpected = Lists.newArrayList(// ends in query interval
new SimpleInterval("1", 10, 60), // equal to query interval
new SimpleInterval("1", 30, 50), // covered by query interval
new SimpleInterval("1", 40, 42), // ends after query interval
new SimpleInterval("1", 45, 60));
// returns input single SimpleInterval, query range, expected SimpleInterval
return new Object[][] { // single-point boundary cases
new Object[] { input, new SimpleInterval("1", 10, 10), input }, new Object[] { input, new SimpleInterval("1", 100, 100), input }, new Object[] { input, new SimpleInterval("1", 9, 9), empty }, new Object[] { input, new SimpleInterval("1", 11, 11), input }, new Object[] { input, new SimpleInterval("1", 99, 99), input }, new Object[] { input, new SimpleInterval("1", 101, 101), empty }, // empty list boundary case
new Object[] { empty, new SimpleInterval("1", 101, 101), empty }, // different contig
new Object[] { empty, new SimpleInterval("2", 101, 101), empty }, // input exactly matches the query interval
new Object[] { input, new SimpleInterval("1", 10, 100), input }, // multiple intervals in the same place (potential edge case for indexing)
new Object[] { manyOverlapping, new SimpleInterval("1", 20, 20), manyOverlapping }, // input with multiple intervals
new Object[] { mixInput, new SimpleInterval("1", 30, 50), mixExpected } };
}
Aggregations