use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class MappingQualityZeroUnitTest method testLikelihoods.
@Test
public void testLikelihoods() {
final Allele REF = Allele.create("T", true);
final Allele ALT = Allele.create("A");
final int refDepth = 5;
final int altDepth = 3;
final int refMQ = 10;
final int altMQ = 0;
final List<GATKRead> refReads = IntStream.range(0, refDepth).mapToObj(i -> makeRead(refMQ)).collect(Collectors.toList());
final List<GATKRead> altReads = IntStream.range(0, altDepth).mapToObj(i -> makeRead(altMQ)).collect(Collectors.toList());
final ReadLikelihoods<Allele> likelihoods = AnnotationArtificialData.makeLikelihoods("sample1", refReads, altReads, -1.0, -1.0, REF, ALT);
final VariantContext vc = makeVC();
final ReferenceContext referenceContext = null;
final Map<String, Object> annotate = new MappingQualityZero().annotate(referenceContext, vc, likelihoods);
Assert.assertEquals(annotate.size(), 1, "size");
Assert.assertEquals(annotate.keySet(), Collections.singleton(VCFConstants.MAPPING_QUALITY_ZERO_KEY), "annots");
Assert.assertEquals(annotate.get(VCFConstants.MAPPING_QUALITY_ZERO_KEY), String.valueOf(altDepth));
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class RMSMappingQualityUnitTest method testAllNull.
@Test(expectedExceptions = IllegalArgumentException.class)
public void testAllNull() throws Exception {
final VariantContext vc = null;
final ReferenceContext referenceContext = null;
final InfoFieldAnnotation cov = new RMSMappingQuality();
//vc can't be null
cov.annotate(referenceContext, vc, null);
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk-protected by broadinstitute.
the class HaplotypeCallerGenotypingEngine method makeAnnotatedCall.
protected VariantContext makeAnnotatedCall(byte[] ref, SimpleInterval refLoc, FeatureContext tracker, SAMFileHeader header, VariantContext mergedVC, ReadLikelihoods<Allele> readAlleleLikelihoods, VariantContext call) {
final SimpleInterval locus = new SimpleInterval(mergedVC.getContig(), mergedVC.getStart(), mergedVC.getEnd());
final SimpleInterval refLocInterval = new SimpleInterval(refLoc);
final ReferenceDataSource refData = new ReferenceMemorySource(new ReferenceBases(ref, refLocInterval), header.getSequenceDictionary());
final ReferenceContext referenceContext = new ReferenceContext(refData, locus, refLocInterval);
final VariantContext untrimmedResult = annotationEngine.annotateContext(call, tracker, referenceContext, readAlleleLikelihoods, a -> true);
return call.getAlleles().size() == mergedVC.getAlleles().size() ? untrimmedResult : GATKVariantContextUtils.reverseTrimAlleles(untrimmedResult);
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class AnnotateVcfWithExpectedAlleleFraction method apply.
@Override
public void apply(final VariantContext vc, final ReadsContext readsContext, final ReferenceContext refContext, final FeatureContext fc) {
final double[] weights = vc.getGenotypes().stream().mapToDouble(g -> weight(g)).toArray();
final double expectedAlleleFraction = MathUtils.sum(MathArrays.ebeMultiply(weights, mixingFractionsInSampleOrder));
vcfWriter.add(new VariantContextBuilder(vc).attribute(EXPECTED_ALLELE_FRACTION_NAME, expectedAlleleFraction).make());
}
use of org.broadinstitute.hellbender.engine.ReferenceContext in project gatk by broadinstitute.
the class TandemRepeatUnitTest method testUsingVC.
@Test
public void testUsingVC() {
// - [ref] / ATC from 20-20
final String insLoc = "chr1";
final int insLocStart = 2;
final int insLocStop = 2;
final byte[] refBytes = "GTATCATCATCGGA".getBytes();
final Allele nullR = Allele.create("A", true);
final Allele atc = Allele.create("AATC", false);
// A*,ATC, context = ATC ATC ATC : (ATC)3 -> (ATC)4
final VariantContext vc = new VariantContextBuilder("foo", insLoc, insLocStart, insLocStop, Arrays.asList(nullR, atc)).make();
// we test that the interval from which the ReferenceContext is constructed does not need to exactly overlap
// the VariantContext. The annotation should be able to handle this.
final SimpleInterval interval = new SimpleInterval(insLoc, insLocStart + 3, insLocStop + 4);
final SimpleInterval interval1 = new SimpleInterval(insLoc, 1, refBytes.length);
final ReferenceBases ref1 = new ReferenceBases(refBytes, interval1);
final SAMSequenceDictionary dict = new SAMSequenceDictionary(Arrays.asList(new SAMSequenceRecord(insLoc, refBytes.length)));
final ReferenceContext ref = new ReferenceContext(ReferenceDataSource.of(ref1, dict), interval, 20, 20);
final InfoFieldAnnotation ann = new TandemRepeat();
final Map<String, Object> a = ann.annotate(ref, vc, null);
Assert.assertEquals(a.size(), 3);
Assert.assertEquals(a.get(GATKVCFConstants.STR_PRESENT_KEY), true);
Assert.assertEquals(a.get(GATKVCFConstants.REPEAT_UNIT_KEY), "ATC");
//3 repeats in the reference, 4 in the variant
Assert.assertEquals(a.get(GATKVCFConstants.REPEATS_PER_ALLELE_KEY), Arrays.asList(3, 4));
}
Aggregations