Package picard.util

Class AlleleSubsettingUtils


  • public final class AlleleSubsettingUtils
    extends Object
    Utilities class containing methods for restricting VariantContext and GenotypesContext objects to a reduced set of alleles, as well as for choosing the best set of alleles to keep and for cleaning up annotations and genotypes after subsetting.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static htsjdk.variant.variantcontext.GenotypesContext subsetAlleles​(htsjdk.variant.variantcontext.GenotypesContext originalGs, List<htsjdk.variant.variantcontext.Allele> originalAlleles, List<htsjdk.variant.variantcontext.Allele> allelesToKeep)
      Create the new GenotypesContext with the subsetted PLs and ADs Expects allelesToKeep to be in the same order in which they are in originalAlleles.
      static htsjdk.variant.variantcontext.VariantContext subsetAlleles​(htsjdk.variant.variantcontext.VariantContext originalVc, List<htsjdk.variant.variantcontext.Allele> allelesToKeep)  
      static int[] subsettedPLIndices​(List<htsjdk.variant.variantcontext.Allele> originalAlleles, List<htsjdk.variant.variantcontext.Allele> newAlleles)
      Given a list of original alleles and a subset of new alleles to retain, find the array of old PL indices that correspond to new PL indices i.e.
      static htsjdk.variant.variantcontext.VariantContext subsetVCToMatchSnp​(htsjdk.variant.variantcontext.VariantContext ctx, Snp snp)
      Method to subset the alleles in the VariantContext to those in the input snp.
      static htsjdk.variant.variantcontext.VariantContext swapAlleles​(htsjdk.variant.variantcontext.VariantContext originalVc, htsjdk.variant.variantcontext.Allele oldAllele, htsjdk.variant.variantcontext.Allele newAllele)
      Swaps one of the alleles in a VC (and its genotypes) with another.
    • Constructor Detail

      • AlleleSubsettingUtils

        public AlleleSubsettingUtils()
    • Method Detail

      • subsetVCToMatchSnp

        public static htsjdk.variant.variantcontext.VariantContext subsetVCToMatchSnp​(htsjdk.variant.variantcontext.VariantContext ctx,
                                                                                      Snp snp)
        Method to subset the alleles in the VariantContext to those in the input snp. Will also subset appropriately the AD and PL fields in all the genotypes, and in the case of a monomorphic variant with a NON_REF allele, will replace the NON_REF allele with the non-reference allele from snp.

        returns null if it is not possible to subset ctx to the alleles in snp.

        Parameters:
        ctx - The VariantContext to subset.
        snp - Snp whose alleles are used for subsetting ctx.
        Returns:
        a VariantContext subsetted to the alleles in snp, or null if unable.
      • subsetAlleles

        public static htsjdk.variant.variantcontext.VariantContext subsetAlleles​(htsjdk.variant.variantcontext.VariantContext originalVc,
                                                                                 List<htsjdk.variant.variantcontext.Allele> allelesToKeep)
      • swapAlleles

        public static htsjdk.variant.variantcontext.VariantContext swapAlleles​(htsjdk.variant.variantcontext.VariantContext originalVc,
                                                                               htsjdk.variant.variantcontext.Allele oldAllele,
                                                                               htsjdk.variant.variantcontext.Allele newAllele)
                                                                        throws IllegalArgumentException
        Swaps one of the alleles in a VC (and its genotypes) with another.
        Parameters:
        originalVc - The VariantContext whose oldAllele will be swapped for newAllele.
        oldAllele - The Allele in originalVc that needs to be replaced.
        newAllele - The new Allele to use instead of oldAllele.
        Returns:
        A new VariantContext with newAllele swapped in for oldAllele.
        Throws:
        IllegalArgumentException - if originalVc doesn't contain oldAllele.
      • subsetAlleles

        public static htsjdk.variant.variantcontext.GenotypesContext subsetAlleles​(htsjdk.variant.variantcontext.GenotypesContext originalGs,
                                                                                   List<htsjdk.variant.variantcontext.Allele> originalAlleles,
                                                                                   List<htsjdk.variant.variantcontext.Allele> allelesToKeep)
        Create the new GenotypesContext with the subsetted PLs and ADs Expects allelesToKeep to be in the same order in which they are in originalAlleles.

        Parameters:
        originalGs - the original GenotypesContext
        originalAlleles - the original alleles
        allelesToKeep - the subset of alleles to use with the new Genotypes
        Returns:
        a new non-null GenotypesContext
      • subsettedPLIndices

        public static int[] subsettedPLIndices​(List<htsjdk.variant.variantcontext.Allele> originalAlleles,
                                               List<htsjdk.variant.variantcontext.Allele> newAlleles)
        Given a list of original alleles and a subset of new alleles to retain, find the array of old PL indices that correspond to new PL indices i.e. result[7] = old PL index of genotype containing same alleles as the new genotype with PL index 7.

        This method is written in terms f indices rather than subsetting PLs directly in order to produce output that can be recycled from sample to sample, provided that the ploidy is the same.

        Parameters:
        originalAlleles - List of original alleles
        newAlleles - New alleles -- must be a subset of originalAlleles
        Returns:
        old PL indices of new genotypes