x.put("QUAL", new AttributeGetter() { public Object get(VariantContext vc) { return -10 * vc.getLog10PError(); }}); x.put("ALLELES", new AttributeGetter() { public Object get(VariantContext vc) { return vc.getAlleles(); }});
protected void printVerboseData(final String pos, final VariantContext vc, final GenotypeLikelihoodsCalculationModel.Model model) { Allele refAllele = null, altAllele = null; for ( Allele allele : vc.getAlleles() ) { if ( allele.isReference() ) refAllele = allele; else altAllele = allele; } for (int i = 0; i <= numberOfGenomes; i++) { StringBuilder AFline = new StringBuilder("AFINFO\t"); AFline.append(pos); AFline.append('\t'); AFline.append(refAllele); AFline.append('\t'); if ( altAllele != null ) AFline.append(altAllele); else AFline.append("N/A"); AFline.append('\t'); AFline.append(i).append('/').append(numberOfGenomes).append('\t'); AFline.append(String.format("%.2f\t", ((float) i) / numberOfGenomes)); AFline.append(String.format("%.8f\t", getAlleleFrequencyPriors(vc,configuration.genotypeArgs.samplePloidy,model)[i])); verboseWriter.println(AFline.toString()); } verboseWriter.println("Qscore = " + vc.getLog10PError()); verboseWriter.println(); }
public enum GenotypeAssignmentMethod { /** * set all of the genotype GT values to NO_CALL */ SET_TO_NO_CALL, /** * set all of the genotype GT values to NO_CALL and remove annotations */ SET_TO_NO_CALL_NO_ANNOTATIONS, /** * Use the subsetted PLs to greedily assigned genotypes */ USE_PLS_TO_ASSIGN, /** * Try to match the original GT calls, if at all possible * * Suppose I have 3 alleles: A/B/C and the following samples: * * original_GT best_match to A/B best_match to A/C * S1 => A/A A/A A/A * S2 => A/B A/B A/A * S3 => B/B B/B A/A * S4 => B/C A/B A/C * S5 => C/C A/A C/C * * Basically, all alleles not in the subset map to ref. It means that het-alt genotypes
@Override public Map<String, Object> annotate(final RefMetaDataTracker tracker, final AnnotatorCompatible walker, final ReferenceContext ref, final Map<String, AlignmentContext> stratifiedContexts, final VariantContext vc, final Map<String, PerReadAlleleLikelihoodMap> perReadAlleleLikelihoodMap ) { if ( !vc.hasLog10PError() ) return null; final GenotypesContext genotypes = vc.getGenotypes(); if ( genotypes == null || genotypes.size() == 0 ) return null; final int standardDepth = getDepth(genotypes, stratifiedContexts, perReadAlleleLikelihoodMap); if ( standardDepth == 0 ) return null; final double altAlleleLength = GATKVariantContextUtils.getMeanAltAlleleLength(vc); // Hack: UnifiedGenotyper (but not HaplotypeCaller or GenotypeGVCFs) over-estimates the quality of long indels // Penalize the QD calculation for UG indels to compensate for this double QD = -10.0 * vc.getLog10PError() / ((double)standardDepth * indelNormalizationFactor(altAlleleLength, walker instanceof UnifiedGenotyper)); // Hack: see note in the fixTooHighQD method below QD = fixTooHighQD(QD); final Map<String, Object> map = new HashMap<>(); map.put(getKeyNames().get(0), String.format("%.2f", QD)); return map; }
public UnfinishedVariantContext(VariantContext vc) { this.name = vc.getSource(); this.id = vc.getID(); this.contig = vc.getChr(); this.start = vc.getStart(); this.stop = vc.getEnd(); this.alleles = vc.getAlleles(); this.genotypes = new HashMap<String, Genotype>(); for ( final Genotype g : vc.getGenotypes() ) { this.genotypes.put(g.getSampleName(), g); } this.log10PError = vc.getLog10PError(); this.filters = vc.filtersWereApplied() ? vc.getFilters() : null; this.attributes = new HashMap<String, Object>(vc.getAttributes()); }
/** * Returns a new builder based on parent -- the new VC will have all fields initialized * to their corresponding values in parent. This is the best way to create a derived VariantContext * * @param parent Cannot be null */ public VariantContextBuilder(VariantContext parent) { if ( parent == null ) throw new IllegalArgumentException("BUG: VariantContextBuilder parent argument cannot be null in VariantContextBuilder"); this.alleles = parent.alleles; this.attributes = parent.getAttributes(); this.attributesCanBeModified = false; this.contig = parent.contig; this.filters = parent.getFiltersMaybeNull(); this.genotypes = parent.genotypes; this.ID = parent.getID(); this.log10PError = parent.getLog10PError(); this.source = parent.getSource(); this.start = parent.getStart(); this.stop = parent.getEnd(); this.fullyDecoded = parent.isFullyDecoded(); }
builder = new VariantContextBuilder(initialContext.getSource(), initialContext.getContig(), initialContext.getStart(), initialContext.getEnd(), siteAlleles); builder.computeEndFromAlleles(allAlleles, initialContext.getStart()); builder.log10PError(initialContext.getLog10PError());
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getContig(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }
builder = new VariantContextBuilder(initialContext.getSource(), initialContext.getContig(), initialContext.getStart(), initialContext.getEnd(), siteAlleles); builder.computeEndFromAlleles(allAlleles, initialContext.getStart()); builder.log10PError(initialContext.getLog10PError());
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getContig(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getChr(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }
/** * Returns a new builder based on parent -- the new VC will have all fields initialized * to their corresponding values in parent. This is the best way to create a derived VariantContext * * @param parent Cannot be null */ public VariantContextBuilder(final VariantContext parent) { if ( parent == null ) throw new IllegalArgumentException("BUG: VariantContextBuilder parent argument cannot be null in VariantContextBuilder"); this.alleles = parent.getAlleles(); this.attributes = parent.getAttributes(); this.attributesCanBeModified = false; this.contig = parent.getContig(); this.filters = parent.getFiltersMaybeNull(); this.genotypes = parent.getGenotypes(); this.ID = parent.getID(); this.log10PError = parent.getLog10PError(); this.source = parent.getSource(); this.start = parent.getStart(); this.stop = parent.getEnd(); this.fullyDecoded = parent.isFullyDecoded(); }
/** * Returns a new builder based on parent -- the new VC will have all fields initialized * to their corresponding values in parent. This is the best way to create a derived VariantContext * * @param parent Cannot be null */ public VariantContextBuilder(final VariantContext parent) { if ( parent == null ) throw new IllegalArgumentException("BUG: VariantContextBuilder parent argument cannot be null in VariantContextBuilder"); this.alleles = parent.getAlleles(); this.attributes = parent.getAttributes(); this.attributesCanBeModified = false; this.contig = parent.getContig(); this.filters = parent.getFiltersMaybeNull(); this.genotypes = parent.getGenotypes(); this.ID = parent.getID(); this.log10PError = parent.getLog10PError(); this.source = parent.getSource(); this.start = parent.getStart(); this.stop = parent.getEnd(); this.fullyDecoded = parent.isFullyDecoded(); }
Assert.assertEquals(sub.getStart(), vc.getStart()); Assert.assertEquals(sub.getEnd(), vc.getEnd()); Assert.assertEquals(sub.getLog10PError(), vc.getLog10PError()); Assert.assertEquals(sub.getFilters(), vc.getFilters()); Assert.assertEquals(sub.getID(), vc.getID());
final double mergedLog10PError = Math.min(vc1.getLog10PError(), vc2.getLog10PError()); final Set<String> mergedFilters = new HashSet<String>(); // Since vc1 and vc2 were unfiltered, the merged record remains unfiltered final Map<String, Object> mergedAttribs = mergeVariantContextAttributes(vc1, vc2);
vcRoot.add("REF", vc.getReference()); vcRoot.add("ALT", vc.getAlternateAlleles()); vcRoot.add("QUAL", vc.hasLog10PError() ? vc.getLog10PError() * -10 : VCFConstants.MISSING_VALUE_v4); vcRoot.add("FILTER", ! vc.filtersWereApplied() // needs null to differentiate between PASS and . ? VCFConstants.MISSING_VALUE_v4
Assert.assertEquals(cfg.vc.getID(), cfg.copy.getID()); Assert.assertEquals(cfg.vc.getGenotypes(), cfg.copy.getGenotypes()); Assert.assertEquals(cfg.vc.getLog10PError(), cfg.copy.getLog10PError()); Assert.assertEquals(cfg.vc.getFilters(), cfg.copy.getFilters());
Assert.assertEquals("comparing Log10PError",ctx.getLog10PError(),vc.getLog10PError(),0.01); Assert.assertArrayEquals("comparing Filters",ctx.getFilters().toArray(),vc.getFilters().toArray()); Assert.assertEquals("comparing Attributes",ctx.getAttributes(),vc.getAttributes());
builder.log10PError(source.getLog10PError()); builder.attributes(source.getAttributes());
builder.log10PError(source.getLog10PError()); builder.attributes(source.getAttributes());