Package htsjdk.variant.variantcontext
Class Genotype
java.lang.Object
htsjdk.variant.variantcontext.Genotype
- All Implemented Interfaces:
Serializable
,Comparable<Genotype>
- Direct Known Subclasses:
FastGenotype
This class encompasses all the basic information about a genotype. It is immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final Collection
<String> A list of genotype field keys corresponding to values we manage inline in the Genotype object.static final long
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
comparable genotypes -> compareTo on the sample namesint
countAllele
(Allele allele) Returns how many times allele appears in this genotype object?protected GenotypeType
Internal code to determine the type of the genotype from the alleles vectorabstract int[]
getAD()
abstract Allele
getAllele
(int i) Get the ith allele in this genotypeUtility that returns a list of allele strings corresponding to the alleles in this samplegetAnyAttribute
(String key) A totally generic getter, that allows you to get specific keys that correspond to even inline values (GQ, for example).double
getAttributeAsDouble
(String key, double defaultValue) Deprecated.int
getAttributeAsInt
(String key, int defaultValue) Deprecated.getAttributeAsString
(String key, String defaultValue) Deprecated.abstract int
getDP()
Same as #getExtendedAttribute with a null defaultgetExtendedAttribute
(String key, Object defaultValue) Get the extended attribute value associated with key, if possibleReturns the extended attributes for this objectfinal String
Returns the filter string associated with this Genotype.Return a VCF-like string representation for the alleles of this genotype.getGenotypeString
(boolean ignoreRefState) Return a VCF-like string representation for the alleles of this genotype.abstract int
getGQ()
Returns a phred-scaled quality score, or -1 if none is availableReturns the GenotypesLikelihoods data associated with this Genotype, or null if missingConvenience function that returns a string representation of the PL field of this genotype, or .double
Deprecated.int
Deprecated.abstract int[]
getPL()
Unsafe low-level accessor the PL field itself, may be null.int
What is the ploidy of this sample?Returns the name associated with this sample.getType()
boolean
hasAD()
Does the AD field have a value?boolean
boolean
hasAnyAttribute
(String key) boolean
hasDP()
Does the DP field have a value?boolean
Is key associated with a value (even a null one) in the extended attributes? Note this will not return true for the inline attributes DP, GQ, AD, or PLprotected static final boolean
hasForbiddenKey
(Map<String, Object> attributes) Does the attribute map have a mapping involving a forbidden key (i.e., one that's managed inline by this Genotypes object?boolean
hasGQ()
Does the GQ field have a value?boolean
boolean
Deprecated.boolean
hasPL()
Does the PL field have a value?boolean
boolean
boolean
isCalled()
final boolean
Is this genotype filtered or not?protected static final boolean
isForbiddenKey
(String key) boolean
isHet()
boolean
boolean
isHom()
boolean
isHomRef()
boolean
isHomVar()
boolean
isMixed()
boolean
isNoCall()
boolean
Are all likelihoods for this sample non-informative? Returns true if all PLs are 0 => 0,0,0 => true 0,0,0,0,0,0 => true 0,10,100 => falseabstract boolean
isPhased()
Are the alleles phased w.r.t.boolean
sameGenotype
(Genotype other) boolean
sameGenotype
(Genotype other, boolean ignorePhase) protected static <T extends Comparable<T>,
V>
StringsortedString
(Map<T, V> c) a utility method for generating sorted strings from a map key set.toString()
protected static final String
toStringIfExists
(String name, int v) Returns a display name for field name with value v if this isn't -1.protected static final String
toStringIfExists
(String name, int[] vs) Returns a display name for field name with values vs if this isn't null.protected static final String
toStringIfExists
(String name, String v) Returns a display name for field name with String value v if this isn't null.
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
PRIMARY_KEYS
A list of genotype field keys corresponding to values we manage inline in the Genotype object. They must not appear in the extended attributes map -
PHASED_ALLELE_SEPARATOR
- See Also:
-
UNPHASED_ALLELE_SEPARATOR
- See Also:
-
-
Constructor Details
-
Genotype
-
-
Method Details
-
getAlleles
- Returns:
- the alleles for this genotype. Cannot be null. May be empty
-
hasRefAllele
public boolean hasRefAllele()- Returns:
- true if any allele is REF
-
hasAltAllele
public boolean hasAltAllele()- Returns:
- true if any allele is ALT, (NO_CALL are ignored)
-
countAllele
Returns how many times allele appears in this genotype object?- Parameters:
allele
-- Returns:
- a value >= 0 indicating how many times the allele occurred in this sample's genotype
-
getAllele
Get the ith allele in this genotype- Parameters:
i
- the ith allele, must be < the ploidy, starting with 0- Returns:
- the allele at position i, which cannot be null
-
isPhased
public abstract boolean isPhased()Are the alleles phased w.r.t. the global phasing system?- Returns:
- true if yes
-
getPloidy
public int getPloidy()What is the ploidy of this sample?- Returns:
- the ploidy of this genotype. 0 if the site is no-called.
-
getDP
public abstract int getDP()- Returns:
- the sequencing depth of this sample, or -1 if this value is missing
-
getAD
public abstract int[] getAD()- Returns:
- the count of reads, one for each allele in the surrounding Variant context, matching the corresponding allele, or null if this value is missing. MUST NOT BE MODIFIED!
-
getSampleName
Returns the name associated with this sample.- Returns:
- a non-null String
-
getGQ
public abstract int getGQ()Returns a phred-scaled quality score, or -1 if none is available- Returns:
-
hasPL
public boolean hasPL()Does the PL field have a value?- Returns:
- true if there's a PL field value
-
hasAD
public boolean hasAD()Does the AD field have a value?- Returns:
- true if there's a AD field value
-
hasGQ
public boolean hasGQ()Does the GQ field have a value?- Returns:
- true if there's a GQ field value
-
hasDP
public boolean hasDP()Does the DP field have a value?- Returns:
- true if there's a DP field value
-
getType
- Returns:
- the high-level type of this sample's genotype
-
determineType
Internal code to determine the type of the genotype from the alleles vector- Returns:
- the type
-
isHom
public boolean isHom()- Returns:
- true if all observed alleles are the same (regardless of whether they are ref or alt); if any alleles are no-calls, this method will return false.
-
isHomRef
public boolean isHomRef()- Returns:
- true if all observed alleles are ref; if any alleles are no-calls, this method will return false.
-
isHomVar
public boolean isHomVar()- Returns:
- true if all observed alleles are alt; if any alleles are no-calls, this method will return false.
-
isHet
public boolean isHet()- Returns:
- true if we're het (observed alleles differ); if the ploidy is less than 2 or if any alleles are no-calls, this method will return false.
-
isHetNonRef
public boolean isHetNonRef()- Returns:
- true if we're het (observed alleles differ) and neither allele is reference; if the ploidy is less than 2 or if any alleles are no-calls, this method will return false.
-
isNoCall
public boolean isNoCall()- Returns:
- true if this genotype is not actually a genotype but a "no call" (e.g. './.' in VCF); if any alleles are not no-calls (even if some are), this method will return false.
-
isCalled
public boolean isCalled()- Returns:
- true if this genotype is comprised of any alleles that are not no-calls (even if some are).
-
isMixed
public boolean isMixed()- Returns:
- true if this genotype is comprised of both calls and no-calls.
-
isAvailable
public boolean isAvailable()- Returns:
- true if the type of this genotype is set.
-
hasLikelihoods
public boolean hasLikelihoods()- Returns:
- Returns true if this Genotype has PL field values
-
getLikelihoodsString
Convenience function that returns a string representation of the PL field of this genotype, or . if none is available.- Returns:
- a non-null String representation for the PL of this sample
-
getLikelihoods
Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing- Returns:
- null or a GenotypesLikelihood object for this sample's PL field
-
isNonInformative
public boolean isNonInformative()Are all likelihoods for this sample non-informative? Returns true if all PLs are 0 => 0,0,0 => true 0,0,0,0,0,0 => true 0,10,100 => false- Returns:
- true if all samples PLs are equal and == 0
-
getPL
public abstract int[] getPL()Unsafe low-level accessor the PL field itself, may be null.- Returns:
- a pointer to the underlying PL data. MUST NOT BE MODIFIED!
-
getGenotypeString
Return a VCF-like string representation for the alleles of this genotype. Does not append the reference * marker on the alleles.- Returns:
- a string representing the genotypes, or null if the type is unavailable.
-
getGenotypeString
Return a VCF-like string representation for the alleles of this genotype. If ignoreRefState is true, will not append the reference * marker on the alleles.- Returns:
- a string representing the genotypes, or null if the type is unavailable.
-
getAlleleStrings
Utility that returns a list of allele strings corresponding to the alleles in this sample- Returns:
-
toString
-
toBriefString
-
compareTo
comparable genotypes -> compareTo on the sample names- Specified by:
compareTo
in interfaceComparable<Genotype>
- Parameters:
genotype
-- Returns:
-
sameGenotype
-
sameGenotype
-
getExtendedAttributes
Returns the extended attributes for this object- Returns:
- is never null, but is often isEmpty()
-
hasExtendedAttribute
Is key associated with a value (even a null one) in the extended attributes? Note this will not return true for the inline attributes DP, GQ, AD, or PL- Parameters:
key
- a non-null string key to check for an association- Returns:
- true if key has a value in the extendedAttributes
-
getExtendedAttribute
Get the extended attribute value associated with key, if possible- Parameters:
key
- a non-null string key to fetch a value fordefaultValue
- the value to return if key isn't in the extended attributes- Returns:
- a value (potentially) null associated with key, or defaultValue if no association exists
-
getExtendedAttribute
Same as #getExtendedAttribute with a null default- Parameters:
key
-- Returns:
-
getFilters
Returns the filter string associated with this Genotype.- Returns:
- If this result == null, then the genotype is considered PASSing filters If the result != null, then the genotype has failed filtering for the reason(s) specified in result. To be reference compliant multiple filter field string values can be encoded with a ; separator.
-
isFiltered
public final boolean isFiltered()Is this genotype filtered or not?- Returns:
- returns false if getFilters() == null
-
hasLog10PError
Deprecated. -
getLog10PError
Deprecated. -
getPhredScaledQual
Deprecated. -
getAttributeAsString
Deprecated. -
getAttributeAsInt
Deprecated. -
getAttributeAsDouble
Deprecated. -
getAnyAttribute
A totally generic getter, that allows you to get specific keys that correspond to even inline values (GQ, for example). Can be very expensive. Additionally, allint[]
are converted inline intoList<Integer>
for convenience.- Parameters:
key
-- Returns:
-
hasAnyAttribute
-
sortedString
a utility method for generating sorted strings from a map key set.- Type Parameters:
T
- the key typeV
- the value type- Parameters:
c
- the map- Returns:
- a sting, enclosed in {}, with comma seperated key value pairs in order of the keys
-
toStringIfExists
Returns a display name for field name with value v if this isn't -1. Otherwise returns ""- Parameters:
name
- of the field ("AD")v
- the value of the field, or -1 if missing- Returns:
- a non-null string for display if the field is not missing
-
toStringIfExists
Returns a display name for field name with String value v if this isn't null. Otherwise returns ""- Parameters:
name
- of the field ("FT")v
- the value of the field, or null if missing- Returns:
- a non-null string for display if the field is not missing
-
toStringIfExists
Returns a display name for field name with values vs if this isn't null. Otherwise returns ""- Parameters:
name
- of the field ("AD")vs
- the value of the field, or null if missing- Returns:
- a non-null string for display if the field is not missing
-
hasForbiddenKey
Does the attribute map have a mapping involving a forbidden key (i.e., one that's managed inline by this Genotypes object?- Parameters:
attributes
- the extended attributes key- Returns:
-
isForbiddenKey
-