public static Genotype create(final String sampleName, final List<Allele> alleles, final Map<String, Object> attributes) { return new GenotypeBuilder(sampleName, alleles).attributes(attributes).make(); }
public static Genotype create(final String sampleName, final List<Allele> alleles, final Map<String, Object> attributes) { return new GenotypeBuilder(sampleName, alleles).attributes(attributes).make(); }
public static Genotype create(final String sampleName, final List<Allele> alleles, final Map<String, Object> attributes) { return new GenotypeBuilder(sampleName, alleles).attributes(attributes).make(); }
public static VariantContext purgeUnallowedGenotypeAttributes(VariantContext vc, Set<String> allowedAttributes) { if ( allowedAttributes == null ) return vc; final GenotypesContext newGenotypes = GenotypesContext.create(vc.getNSamples()); for ( final Genotype genotype : vc.getGenotypes() ) { final Map<String, Object> attrs = new HashMap<>(); for ( final Map.Entry<String, Object> attr : genotype.getExtendedAttributes().entrySet() ) { if ( allowedAttributes.contains(attr.getKey()) ) attrs.put(attr.getKey(), attr.getValue()); } newGenotypes.add(new GenotypeBuilder(genotype).attributes(attrs).make()); } return new VariantContextBuilder(vc).genotypes(newGenotypes).make(); }
private final Genotype fullyDecodeGenotypes(final Genotype g, final VCFHeader header) { final Map<String, Object> map = fullyDecodeAttributes(g.getExtendedAttributes(), header, true); return new GenotypeBuilder(g).attributes(map).make(); }
private final Genotype fullyDecodeGenotypes(final Genotype g, final VCFHeader header) { final Map<String, Object> map = fullyDecodeAttributes(g.getExtendedAttributes(), header, true); return new GenotypeBuilder(g).attributes(map).make(); }
private final Genotype fullyDecodeGenotypes(final Genotype g, final VCFHeader header) { final Map<String, Object> map = fullyDecodeAttributes(g.getExtendedAttributes(), header, true); return new GenotypeBuilder(g).attributes(map).make(); }
builder.noAttributes(); } else { builder.attributes(attributes);
private Genotype getUpdatedGenotype(final VariantContext vc, final Genotype genotype, final double jointLikelihood, final double jointPosteriorProb, final double[] log10Posteriors){ //Don't update null, missing or unavailable genotypes if(genotype == null || !hasCalledGT(genotype.getType())) return genotype; int phredScaledJL = -1; int phredScaledJP = -1; if(jointLikelihood != NO_JOINT_VALUE){ double dphredScaledJL = QualityUtils.phredScaleLog10ErrorRate(Math.log10(1-jointLikelihood)); phredScaledJL = dphredScaledJL < Byte.MAX_VALUE ? (byte)dphredScaledJL : Byte.MAX_VALUE; } if(jointPosteriorProb != NO_JOINT_VALUE){ double dphredScaledJP = QualityUtils.phredScaleLog10ErrorRate(Math.log10(1-jointPosteriorProb)); phredScaledJP = dphredScaledJP < Byte.MAX_VALUE ? (byte)dphredScaledJP : Byte.MAX_VALUE; } //Add the joint trio calculations final Map<String, Object> genotypeAttributes = new HashMap<>(); genotypeAttributes.putAll(genotype.getExtendedAttributes()); genotypeAttributes.put(GATKVCFConstants.JOINT_LIKELIHOOD_TAG_NAME, phredScaledJL); genotypeAttributes.put(GATKVCFConstants.JOINT_POSTERIOR_TAG_NAME, phredScaledJP); final GenotypeBuilder builder = new GenotypeBuilder(genotype); //final double[] log10Posteriors = MathUtils.toLog10(normalizedPosteriors); //update genotype types based on posteriors GATKVariantContextUtils.updateGenotypeAfterSubsetting(vc.getAlleles(), genotype.getPloidy(), builder, GATKVariantContextUtils.GenotypeAssignmentMethod.USE_PLS_TO_ASSIGN, log10Posteriors, vc.getAlleles()); builder.attribute(GATKVCFConstants.PHRED_SCALED_POSTERIORS_KEY, Utils.listFromPrimitives(GenotypeLikelihoods.fromLog10Likelihoods(log10Posteriors).getAsPLs())); builder.attributes(genotypeAttributes); return builder.make(); }
.attributes(genotypeAttributes) .phased(phasedGenotype.isPhased()).make();
recoveredGs.add(builder.noAttributes().attributes(attrs).make());
final Genotype mergedGt = new GenotypeBuilder(gt1.getSampleName(), mergedAllelesForSample).log10PError(mergedGQ).attributes(mergedGtAttribs).phased(isPhased).make(); mergedGenotypes.add(mergedGt);
@Test public void TestMergeIntoMNP(){ final AlwaysTrueMergeRule alleleMergeRule = new AlwaysTrueMergeRule(); final VariantContext vc = PhasingUtils.mergeIntoMNP(genomeLocParser, vc1, vc2, referenceFile, alleleMergeRule); final List<Allele> alleleList = Arrays.asList(Allele.create("TG", true), Allele.create("TA", false), Allele.create("CG", false)); final Map<String,Object> attributes = new HashMap<String,Object>(){{ put("AC", new ArrayList<Integer>(Arrays.asList(1, 1))); put("AF", new ArrayList<Double>(Arrays.asList(0.5, 0.5))); put("AN", 2); }}; final Map<String, Object> extendedAttributes = new HashMap<String, Object>(){{ put("PQ", 100.0); put("HP", new String[]{"10-1", "10-2"}); }}; final List<Allele> alleleListMeged = Arrays.asList(Allele.create("TA"), Allele.create("CG")); final Genotype genotype = new GenotypeBuilder().name("sample").attributes(extendedAttributes).alleles(alleleListMeged).make(); final VariantContext vcExpected = new VariantContextBuilder().chr(contig).id("id1;id2").source("TC_GA").start(start).stop(start+1).alleles(alleleList).genotypes(genotype).attributes(attributes).make(); Assert.assertTrue(genotype.sameGenotype(vcExpected.getGenotypes().get("sample"))); Assert.assertTrue(vcExpected.hasSameAllelesAs(vc)); Assert.assertEquals(vcExpected.getChr(), vc.getChr()); Assert.assertEquals(vcExpected.getStart(), vc.getStart()); Assert.assertEquals(vcExpected.getEnd(), vc.getEnd()); Assert.assertEquals(vcExpected.getID(), vc.getID()); Assert.assertEquals(vcExpected.getSource(), vc.getSource()); Assert.assertEquals(vcExpected.isFiltered(), vc.isFiltered()); Assert.assertEquals(vcExpected.getPhredScaledQual(), vc.getPhredScaledQual()); Assert.assertEquals(vcExpected.getAttribute("PQ"), vc.getAttribute("PQ")); Assert.assertEquals(vcExpected.getAttribute("HP"), vc.getAttribute("HP")); }
@Test public void TestReallyMergeIntoMNP( ){ final VariantContext vc = PhasingUtils.reallyMergeIntoMNP(vc1, vc2, referenceFile); final List<Allele> alleleList = Arrays.asList(Allele.create("TG", true), Allele.create("TA", false), Allele.create("CG", false)); final Map<String,Object> attributes = new HashMap<String,Object>(){{ put("AC", new ArrayList<Integer>(Arrays.asList(1, 1))); put("AF", new ArrayList<Double>(Arrays.asList(0.5, 0.5))); put("AN", 2); }}; final Map<String, Object> extendedAttributes = new HashMap<String, Object>(){{ put("PQ", 100.0); put("HP", new String[]{"10-1", "10-2"}); }}; final List<Allele> alleleListMeged = Arrays.asList(Allele.create("TA"), Allele.create("CG")); final Genotype genotype = new GenotypeBuilder().name("sample").attributes(extendedAttributes).alleles(alleleListMeged).make(); final VariantContext vcExpected = new VariantContextBuilder().chr(contig).id("id1;id2").source("TC_GA").start(start).stop(start+1).alleles(alleleList).genotypes(genotype).attributes(attributes).make(); Assert.assertTrue(genotype.sameGenotype(vcExpected.getGenotypes().get("sample"))); Assert.assertTrue(vcExpected.hasSameAllelesAs(vc)); Assert.assertEquals(vcExpected.getChr(), vc.getChr()); Assert.assertEquals(vcExpected.getStart(), vc.getStart()); Assert.assertEquals(vcExpected.getEnd(), vc.getEnd()); Assert.assertEquals(vcExpected.getID(), vc.getID()); Assert.assertEquals(vcExpected.getSource(), vc.getSource()); Assert.assertEquals(vcExpected.isFiltered(), vc.isFiltered()); Assert.assertEquals(vcExpected.getPhredScaledQual(), vc.getPhredScaledQual()); Assert.assertEquals(vcExpected.getAttribute("PQ"), vc.getAttribute("PQ")); Assert.assertEquals(vcExpected.getAttribute("HP"), vc.getAttribute("HP")); }
/** * Copy all of the values for this builder from Genotype g * @param g * @return */ public GenotypeBuilder copy(final Genotype g) { name(g.getSampleName()); alleles(g.getAlleles()); phased(g.isPhased()); GQ(g.getGQ()); DP(g.getDP()); AD(g.getAD()); PL(g.getPL()); filter(g.getFilters()); attributes(g.getExtendedAttributes()); return this; }
/** * Copy all of the values for this builder from Genotype g * @param g * @return */ public GenotypeBuilder copy(final Genotype g) { name(g.getSampleName()); alleles(g.getAlleles()); phased(g.isPhased()); GQ(g.getGQ()); DP(g.getDP()); AD(g.getAD()); PL(g.getPL()); filter(g.getFilters()); attributes(g.getExtendedAttributes()); return this; }
/** * Copy all of the values for this builder from Genotype g * @param g * @return */ public GenotypeBuilder copy(final Genotype g) { name(g.getSampleName()); alleles(g.getAlleles()); phased(g.isPhased()); GQ(g.getGQ()); DP(g.getDP()); AD(g.getAD()); PL(g.getPL()); filter(g.getFilters()); attributes(g.getExtendedAttributes()); return this; }