Package picard.util
Class AlleleSubsettingUtils
- java.lang.Object
-
- picard.util.AlleleSubsettingUtils
-
public final class AlleleSubsettingUtils extends Object
Utilities class containing methods for restrictingVariantContext
andGenotypesContext
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.
-
-
Constructor Summary
Constructors Constructor Description AlleleSubsettingUtils()
-
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.
-
-
-
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
- TheVariantContext
whose oldAllele will be swapped for newAllele.oldAllele
- TheAllele
in originalVc that needs to be replaced.newAllele
- The newAllele
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 GenotypesContextoriginalAlleles
- the original allelesallelesToKeep
- 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 allelesnewAlleles
- New alleles -- must be a subset oforiginalAlleles
- Returns:
- old PL indices of new genotypes
-
-