Class VariantContextGetters
java.lang.Object
org.broadinstitute.hellbender.utils.variant.VariantContextGetters
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattributeToList
(Object attribute) static double
getAttributeAsDouble
(htsjdk.variant.variantcontext.Genotype genotype, String key, double defaultValue) Returns an attribute as a double.static double[]
getAttributeAsDoubleArray
(htsjdk.variant.variantcontext.Genotype genotype, String key, Supplier<double[]> defaultValue, double missingValue) Composes the double array from a genotype annotation.static double[]
getAttributeAsDoubleArray
(htsjdk.variant.variantcontext.VariantContext variantContext, String attribute) Composes the double array from a genotype annotation.static double[]
getAttributeAsDoubleArray
(htsjdk.variant.variantcontext.VariantContext variantContext, String key, Supplier<double[]> defaultValue, double missingValue) Composes the double array from a genotype annotation.static int
getAttributeAsInt
(htsjdk.variant.variantcontext.Genotype genotype, String key, int defaultValue) Returns an attribute as an integer.static int[]
getAttributeAsIntArray
(htsjdk.variant.variantcontext.Genotype genotype, String key, Supplier<int[]> defaultValue, int missingValue) Composes the double array from a genotype annotation.static int[]
getAttributeAsIntArray
(htsjdk.variant.variantcontext.VariantContext variantContext, String key, Supplier<int[]> defaultValue, int missingValue) Composes the int array from an INFO annotation.static Long
getAttributeAsLong
(htsjdk.variant.variantcontext.VariantContext variantContext, String attribute, Long defaultValue) Get Long attribute from a variant context.getAttributeAsLongList
(htsjdk.variant.variantcontext.VariantContext variantContext, String attribute, Long defaultValue) Composes the Long List from a variant context.static String
getAttributeAsString
(htsjdk.variant.variantcontext.Genotype genotype, String key, String defaultValue) Returns an attribute as a string.
-
Constructor Details
-
VariantContextGetters
public VariantContextGetters()
-
-
Method Details
-
getAttributeAsInt
public static int getAttributeAsInt(htsjdk.variant.variantcontext.Genotype genotype, String key, int defaultValue) Returns an attribute as an integer.- Parameters:
genotype
- the source genotype.key
- the attribute key.defaultValue
- default value to return in case the attribute does not have a value defined.- Returns:
- the string version of the attribute value.
- Throws:
IllegalArgumentException
- ifgenotype
orkey
isnull
.NumberFormatException
- if the annotation exists, and its string transformation cannot be convert into an integer.
-
getAttributeAsIntArray
public static int[] getAttributeAsIntArray(htsjdk.variant.variantcontext.VariantContext variantContext, String key, Supplier<int[]> defaultValue, int missingValue) Composes the int array from an INFO annotation.- Parameters:
variantContext
- the target variant-context.key
- the name of the attribute containing the double array.defaultValue
- the double array to return in case there is no such an annotation.missingValue
- value to use to fill up positions with a missing value (e.g. '.').- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsIntArray
public static int[] getAttributeAsIntArray(htsjdk.variant.variantcontext.Genotype genotype, String key, Supplier<int[]> defaultValue, int missingValue) Composes the double array from a genotype annotation.- Parameters:
genotype
- the target variant-context.key
- the name of the attribute containing the double array.defaultValue
- the double array to return in case there is no such an annotation.missingValue
- value to use to fill up positions with a missing value (e.g. '.').- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsDouble
public static double getAttributeAsDouble(htsjdk.variant.variantcontext.Genotype genotype, String key, double defaultValue) Returns an attribute as a double.- Parameters:
genotype
- the source genotype.key
- the attribute key.defaultValue
- default value to return in case the attribute does not have a value defined.- Returns:
- the string version of the attribute value.
- Throws:
IllegalArgumentException
- ifgenotype
orkey
isnull
.NumberFormatException
- if the annotation exists, and its string transformation cannot be convert into a double.
-
getAttributeAsDoubleArray
public static double[] getAttributeAsDoubleArray(htsjdk.variant.variantcontext.VariantContext variantContext, String key, Supplier<double[]> defaultValue, double missingValue) Composes the double array from a genotype annotation.- Parameters:
variantContext
- the target variant-context.key
- the name of the attribute containing the double array.defaultValue
- the double array to return in case there is no such an annotation.missingValue
- value to use to fill up positions with a missing value (e.g. '.').- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsDoubleArray
public static double[] getAttributeAsDoubleArray(htsjdk.variant.variantcontext.VariantContext variantContext, String attribute) Composes the double array from a genotype annotation. Provides default and missing values.- Parameters:
variantContext
- the target variant-context.attribute
- the name of the attribute containing the double array.- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsDoubleArray
public static double[] getAttributeAsDoubleArray(htsjdk.variant.variantcontext.Genotype genotype, String key, Supplier<double[]> defaultValue, double missingValue) Composes the double array from a genotype annotation.- Parameters:
genotype
- the target variant-context.key
- the name of the attribute containing the double array.defaultValue
- the double array to return in case there is no such an annotation.missingValue
- value to use to fill up positions with a missing value (e.g. '.').- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsLong
public static Long getAttributeAsLong(htsjdk.variant.variantcontext.VariantContext variantContext, String attribute, Long defaultValue) Get Long attribute from a variant context.- Parameters:
variantContext
- the target variant-context.attribute
- the name of the attribute containing the Long value.- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsLongList
public static List<Long> getAttributeAsLongList(htsjdk.variant.variantcontext.VariantContext variantContext, String attribute, Long defaultValue) Composes the Long List from a variant context.- Parameters:
variantContext
- the target variant-context.attribute
- the name of the attribute containing the Long list.- Returns:
- never
null
. - Throws:
IllegalArgumentException
- ifvariantContext
isnull
orkey
isnull
.
-
getAttributeAsString
public static String getAttributeAsString(htsjdk.variant.variantcontext.Genotype genotype, String key, String defaultValue) Returns an attribute as a string.- Parameters:
genotype
- the source genotype.key
- the attribute key.defaultValue
- default value to return in case the attribute does not have a value defined.- Returns:
- the string version of the attribute value.
- Throws:
IllegalArgumentException
- ifgenotype
orkey
isnull
.
-
attributeToList
-