/** * Update the attributes of the attributes map given the VariantContext to reflect the * proper chromosome-based VCF tags * * @param vc the VariantContext * @param attributes the attributes map to populate; must not be null; may contain old values * @param removeStaleValues should we remove stale values from the mapping? * @return the attributes map provided as input, returned for programming convenience */ public static Map<String, Object> calculateChromosomeCounts(VariantContext vc, Map<String, Object> attributes, boolean removeStaleValues) { return calculateChromosomeCounts(vc, attributes, removeStaleValues, new HashSet<String>(0)); }
/** * Update the attributes of the attributes map given the VariantContext to reflect the * proper chromosome-based VCF tags * * @param vc the VariantContext * @param attributes the attributes map to populate; must not be null; may contain old values * @param removeStaleValues should we remove stale values from the mapping? * @return the attributes map provided as input, returned for programming convenience */ public static Map<String, Object> calculateChromosomeCounts(VariantContext vc, Map<String, Object> attributes, boolean removeStaleValues) { return calculateChromosomeCounts(vc, attributes, removeStaleValues, new HashSet<String>(0)); }
/** * Update the attributes of the attributes map given the VariantContext to reflect the * proper chromosome-based VCF tags * * @param vc the VariantContext * @param attributes the attributes map to populate; must not be null; may contain old values * @param removeStaleValues should we remove stale values from the mapping? * @return the attributes map provided as input, returned for programming convenience */ public static Map<String, Object> calculateChromosomeCounts(VariantContext vc, Map<String, Object> attributes, boolean removeStaleValues) { return calculateChromosomeCounts(vc, attributes, removeStaleValues, new HashSet<String>(0)); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, new HashSet<>(0))); }
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.hasGenotypes() ) return null; //if none of the "founders" are in the vc samples, assume we uniquified the samples upstream and they are all founders if (!didUniquifiedSampleNameCheck) { checkSampleNames(vc); didUniquifiedSampleNameCheck = true; } return VariantContextUtils.calculateChromosomeCounts(vc, new HashMap<String, Object>(), true,founderIds); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<String, Object>(vc.getAttributes()), removeStaleValues, new HashSet<String>(0))); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, new HashSet<>(0))); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param founderIds - Set of founders to take into account. AF and FC will be calculated over the founders only. * If empty or null, counts are generated for all samples as unrelated individuals * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues, final Set<String> founderIds) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, founderIds)); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param founderIds - Set of founders to take into account. AF and FC will be calculated over the founders only. * If empty or null, counts are generated for all samples as unrelated individuals * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues, final Set<String> founderIds) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<String, Object>(vc.getAttributes()), removeStaleValues, founderIds)); }
/** * Update the attributes of the attributes map in the VariantContextBuilder to reflect the proper * chromosome-based VCF tags based on the current VC produced by builder.make() * * @param builder the VariantContextBuilder we are updating * @param founderIds - Set of founders to take into account. AF and FC will be calculated over the founders only. * If empty or null, counts are generated for all samples as unrelated individuals * @param removeStaleValues should we remove stale values from the mapping? */ public static void calculateChromosomeCounts(VariantContextBuilder builder, boolean removeStaleValues, final Set<String> founderIds) { VariantContext vc = builder.make(); builder.attributes(calculateChromosomeCounts(vc, new HashMap<>(vc.getAttributes()), removeStaleValues, founderIds)); }
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
VariantContextUtils.calculateChromosomeCounts(vc, attributes, false);
public void logCurrentSiteData(VariantContext vc, boolean selectedInTargetSamples, boolean IGNORE_GENOTYPES, boolean IGNORE_POLYMORPHIC) { HashMap<String, Object> attributes = new HashMap<String, Object>(); if (vc.hasGenotypes() && !IGNORE_GENOTYPES) { // recompute AF,AC,AN based on genotypes: VariantContextUtils.calculateChromosomeCounts(vc, attributes, false); if (! selectedInTargetSamples && !IGNORE_POLYMORPHIC) return; } else { if (!IGNORE_POLYMORPHIC) { if (vc.getAttributes().containsKey(VCFConstants.ALLELE_COUNT_KEY)) { int ac = vc.getAttributeAsInt(VCFConstants.ALLELE_COUNT_KEY, 0); if (ac == 0) return; // site not polymorphic } else // no allele count field in VC return; } } // create bare-bones event and log in corresponding bin // attributes contains AC,AF,AN pulled from original vc, and we keep them here and log in output file for bookkeeping purposes GenomeEvent event = new GenomeEvent(parser, vc.getChr(), vc.getStart(), vc.getEnd(),vc.getAlleles(), attributes); binnedEventArray.add(event); }
VariantContextUtils.calculateChromosomeCounts(builder, false); VariantContext newvc = builder.make();
VariantContextUtils.calculateChromosomeCounts(builder, true);
public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if ( tracker == null || context == null || ref == null ) { return 0; } final Collection<VariantContext> vcs = tracker.getValues(variantCollection.variants, ref.getLocus()); final Collection<VariantContext> otherVCs = tracker.getValues(supportVariants, context.getLocation()); final int missing = supportVariants.size() - otherVCs.size(); for ( final VariantContext vc : vcs ) { VariantContext vc_familyPriors,vc_bothPriors; //do family priors first (if applicable) final VariantContextBuilder builder = new VariantContextBuilder(vc); //only compute family priors for biallelelic sites if (!skipFamilyPriors && vc.isBiallelic()){ GenotypesContext gc = famUtils.calculatePosteriorGLs(vc); builder.genotypes(gc); } VariantContextUtils.calculateChromosomeCounts(builder, false); vc_familyPriors = builder.make(); if (!skipPopulationPriors) vc_bothPriors = PosteriorLikelihoodsUtils.calculatePosteriorGLs(vc_familyPriors, otherVCs, missing * numRefIfMissing, globalPrior, !ignoreInputSamples, defaultToAC, useACoff); else { final VariantContextBuilder builder2 = new VariantContextBuilder(vc_familyPriors); VariantContextUtils.calculateChromosomeCounts(builder, false); vc_bothPriors = builder2.make(); } vcfWriter.add(vc_bothPriors); } return 1; }
/** * Subset VC record if necessary and emit the modified record (provided it satisfies criteria for printing) * * @param tracker the ROD tracker * @param ref reference information * @param context alignment info * @return 1 if the record was printed to the output file, 0 if otherwise */ @Override public Integer map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { if ( tracker == null ) return 0; Collection<VariantContext> vcs = tracker.getValues(variantCollection.variants, context.getLocation()); if ( vcs == null || vcs.size() == 0) { return 0; } for (VariantContext vc : vcs) { if ( vc.isPolymorphicInSamples() && hasPLs(vc) ) { synchronized (UG_engine) { final VariantContextBuilder builder = new VariantContextBuilder(UG_engine.calculateGenotypes(vc)).filters(vc.getFiltersMaybeNull()); VariantContextUtils.calculateChromosomeCounts(builder, false); vc = builder.make(); } } vcfWriter.add(vc); } return 1; }
VariantContextUtils.calculateChromosomeCounts(builder, false);
public VariantContext ensureAnnotations(final VariantContext vc, final VariantContext vcsub) { final int originalAlleleCount = vc.getHetCount() + 2 * vc.getHomVarCount(); final int newAlleleCount = vcsub.getHetCount() + 2 * vcsub.getHomVarCount(); final boolean isSingleton = originalAlleleCount == newAlleleCount && newAlleleCount == 1; final boolean hasChrCountAnnotations = vcsub.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) && vcsub.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) && vcsub.hasAttribute(VCFConstants.ALLELE_NUMBER_KEY); if ( ! isSingleton && hasChrCountAnnotations ) { // nothing to update return vcsub; } else { // have to do the work VariantContextBuilder builder = new VariantContextBuilder(vcsub); if ( isSingleton ) builder.attribute(VariantEval.IS_SINGLETON_KEY, true); if ( ! hasChrCountAnnotations ) VariantContextUtils.calculateChromosomeCounts(builder, true); return builder.make(); } }
VariantContextUtils.calculateChromosomeCounts(vc,ats,true);