private void annotateInfoSnp(VariantContext vc, String infix, HashMap<Integer, AnnotatingRecord<CosmicRecord>> records, VariantContextBuilder builder) { if (records.isEmpty()) return; CosmicRecord first = records.values().iterator().next().getRecord(); if (first.isSnp()) builder.attribute(options.getVCFIdentifierPrefix() + infix + "SNP", true); }
private void annotateChromosomeCounts(VariantContext vc, String infix, HashMap<Integer, AnnotatingRecord<UK10KRecord>> records, VariantContextBuilder builder) { if (records.isEmpty()) return; UK10KRecord first = records.values().iterator().next().getRecord(); builder.attribute(options.getVCFIdentifierPrefix() + infix + "AN", first.getChromCount()); }
private void annotateChromosomeCounts(VariantContext vc, String infix, HashMap<Integer, AnnotatingRecord<ExacRecord>> records, VariantContextBuilder builder) { if (records.isEmpty()) return; ExacRecord first = records.values().iterator().next().getRecord(); for (ExacPopulation pop : ExacPopulation.values()) builder.attribute(options.getVCFIdentifierPrefix() + infix + "AN_" + pop, first.getChromCount(pop)); }
private void annotateChromosomeCounts(VariantContext vc, String infix, HashMap<Integer, AnnotatingRecord<GnomadRecord>> records, VariantContextBuilder builder, boolean isMatch) { if (records.isEmpty()) return; GnomadRecord first = records.values().iterator().next().getRecord(); for (GnomadPopulation pop : GnomadPopulation.values()) builder.attribute(options.getVCFIdentifierPrefix() + infix + "AN_" + pop, first.getChromCount(pop)); }
protected IdsvVariantContextBuilder create(BreakpointSummary bp, String event) { IdsvVariantContextBuilder builder = new IdsvVariantContextBuilder(context); builder.breakpoint(bp, "") .id(event + (bp.isLowBreakend() ? "o" : "h")) .attribute(VcfSvConstants.BREAKEND_EVENT_ID_KEY, event) .attribute(VcfSvConstants.PARTNER_BREAKEND_ID_KEY, event + (bp.isLowBreakend() ? "h" : "o")) .attribute(VcfSvConstants.MATE_BREAKEND_ID_KEY, event + (bp.isLowBreakend() ? "h" : "o")); return builder; } }
public IdsvVariantContextBuilder attribute(final String key, final Object value) { if (!gridss.Defaults.WRITE_ZERO_OR_EMTPY_VCF_FIELDS && VcfInfoAttributes.getAttributefromKey(key) != null && isNullEmpty(value)) { // we can omit zero/empty GRIDSS properties to reduce output file size if configured to do so rmAttribute(key); } else { super.attribute(key, value); } return this; } /**
@Test public void testSetAttribute() { VariantContextBuilder builder = new VariantContextBuilder(); builder.attribute("Test", "value"); }
/** * @return Variant context indicating error */ private VariantContext buildErrorVariantContext(String origString, String message) { Allele alleleRef = Allele.create("N", true); Allele alleleAlt = Allele.create("<ERROR>", false); return new VariantContextBuilder().loc("1", 1, 1).alleles(Lists.newArrayList(alleleRef, alleleAlt)) .filter("PARSE_ERROR").attribute("ORIG_VAR", urlEncode(origString)) .attribute("ERROR_MESSAGE", urlEncode(message)).make(); }
@Test() public void testAttributeResettingWorks() { final VariantContextBuilder root1 = new VariantContextBuilder(snpSource, snpLoc, snpLocStart, snpLocStop, Arrays.asList(Aref, C)); final VariantContextBuilder root2 = new VariantContextBuilder(snpSource, snpLoc, snpLocStart, snpLocStop, Arrays.asList(Aref, C)); final VariantContext result1 = root1.attribute("AC", 1).make(); //this is a red-herring and should not change anything. final VariantContext ignored = root1.attribute("AC", 2).make(); final VariantContext result2 = root2.attribute("AC", 1).make(); Assert.assertEquals(result1.getAttribute("AC"), result2.getAttribute("AC")); } }
@Test(dataProvider = "referenceBlockData") public void testReferenceBlock(List<Allele> alleles, boolean addEndAttribute, boolean isRefBlock) { // create a context builder/context based on inputs provided final VariantContextBuilder builder = new VariantContextBuilder("test", snpLoc,snpLocStart, snpLocStop, alleles); if (addEndAttribute) { builder.attribute("END", 10); } Assert.assertEquals(builder.make().isReferenceBlock(), isRefBlock); }
@Test private void testMultipleACvalues() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,20,0), makeG("s2",Aref,T,18,0,24), makeG("s3",Aref,T,22,0,12)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T,C))).attribute(VCFConstants.ALLELE_COUNT_KEY,Arrays.asList(5,4)).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); }
@Test private void testMultipleMLEACvalues() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,20,0), makeG("s2",Aref,T,18,0,24), makeG("s3",Aref,T,22,0,12)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T,C))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,Arrays.asList(5,4)).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); }
@Test private void testMLEACgreaterThanAN() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,20,0), makeG("s2",Aref,T,18,0,24), makeG("s3",Aref,T,22,0,12)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,11).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); }
@Test (expectedExceptions = {UserException.class}) private void testWrongNumberACvalues() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,20,0), makeG("s2",Aref,T,18,0,24), makeG("s3",Aref,T,22,0,12)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T,C))).attribute(VCFConstants.ALLELE_COUNT_KEY,5).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); }
@Test (expectedExceptions = {UserException.class}) private void testWrongNumberMLEACvalues() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,20,0), makeG("s2",Aref,T,18,0,24), makeG("s3",Aref,T,22,0,12)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T,C))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,5).attribute(VCFConstants.ALLELE_NUMBER_KEY,10).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); }
@Test private void testCalculatePosteriorHETtoHOM_VAR() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,0,1)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,900).attribute(VCFConstants.ALLELE_NUMBER_KEY,1000).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); int[] GP = _mleparse( (List<Integer>)test1result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY)); Assert.assertTrue(GP[2] < GP[1]); }
@Test private void testCalculatePosteriorHETtoHOM_REF() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,1,0,40)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,100).attribute(VCFConstants.ALLELE_NUMBER_KEY,1000).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); int[] GP = _mleparse( (List<Integer>)test1result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY)); Assert.assertTrue(GP[0] < GP[1]); }
@Test private void testCalculatePosteriorHOM_VARtoHET() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,40,1,0)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,500).attribute(VCFConstants.ALLELE_NUMBER_KEY,1000).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); int[] GP = _mleparse( (List<Integer>)test1result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY)); Assert.assertTrue(GP[2] > GP[1]); }
@Test private void testCalculatePosteriorHOM_REFtoHET() { VariantContext testOverlappingBase = makeVC("1", Arrays.asList(Aref,T), makeG("s1",T,T,0,1,40)); List<VariantContext> supplTest1 = new ArrayList<>(1); supplTest1.add(new VariantContextBuilder(makeVC("2",Arrays.asList(Aref,T))).attribute(GATKVCFConstants.MLE_ALLELE_COUNT_KEY,500).attribute(VCFConstants.ALLELE_NUMBER_KEY,1000).make()); VariantContext test1result = PosteriorLikelihoodsUtils.calculatePosteriorGLs(testOverlappingBase,supplTest1,0,0.001,true,false,false); int[] GP = _mleparse( (List<Integer>)test1result.getGenotype(0).getAnyAttribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY)); Assert.assertTrue(GP[0] > GP[1]); }
private static void addSymbolicAlleleTests() { // two tests to ensure that the end is computed correctly when there's (and not) an END field present add(builder().alleles("N", "<VQSR>").start(10).stop(11).attribute("END", 11)); add(builder().alleles("N", "<VQSR>").start(10).stop(10)); }