public abstract class Genotype extends Object implements Comparable<Genotype>, Serializable
Modifier and Type | Field and Description |
---|---|
static String |
PHASED_ALLELE_SEPARATOR |
static Collection<String> |
PRIMARY_KEYS
A list of genotype field keys corresponding to values we
manage inline in the Genotype object.
|
static long |
serialVersionUID |
static String |
UNPHASED_ALLELE_SEPARATOR |
Modifier | Constructor and Description |
---|---|
protected |
Genotype(String sampleName,
String filters) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Genotype genotype)
comparable genotypes -> compareTo on the sample names
|
int |
countAllele(Allele allele)
Returns how many times allele appears in this genotype object?
|
protected GenotypeType |
determineType()
Internal code to determine the type of the genotype from the alleles vector
|
abstract int[] |
getAD() |
abstract Allele |
getAllele(int i)
Get the ith allele in this genotype
|
abstract List<Allele> |
getAlleles() |
protected List<String> |
getAlleleStrings()
Utility that returns a list of allele strings corresponding to the alleles in this sample
|
Object |
getAnyAttribute(String key)
A totally generic getter, that allows you to 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.
|
String |
getAttributeAsString(String key,
String defaultValue)
Deprecated.
|
abstract int |
getDP() |
Object |
getExtendedAttribute(String key)
Same as #getExtendedAttribute with a null default
|
Object |
getExtendedAttribute(String key,
Object defaultValue)
Get the extended attribute value associated with key, if possible
|
abstract Map<String,Object> |
getExtendedAttributes()
Returns the extended attributes for this object
|
String |
getFilters()
Returns the filter string associated with this Genotype.
|
String |
getGenotypeString()
Return a VCF-like string representation for the alleles of this genotype.
|
String |
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 available
|
GenotypeLikelihoods |
getLikelihoods()
Returns the GenotypesLikelihoods data associated with this Genotype, or null if missing
|
String |
getLikelihoodsString()
Convenience function that returns a string representation of the PL field of this
genotype, or .
|
double |
getLog10PError()
Deprecated.
|
int |
getPhredScaledQual()
Deprecated.
|
abstract int[] |
getPL()
Unsafe low-level accessor the PL field itself, may be null.
|
int |
getPloidy()
What is the ploidy of this sample?
|
String |
getSampleName()
Returns the name associated with this sample.
|
GenotypeType |
getType() |
boolean |
hasAD()
Does the AD field have a value?
|
boolean |
hasAnyAttribute(String key) |
boolean |
hasDP()
Does the DP field have a value?
|
boolean |
hasExtendedAttribute(String key)
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
|
protected static 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 |
hasLikelihoods() |
boolean |
hasLog10PError()
Deprecated.
|
boolean |
hasPL()
Does the PL field have a value?
|
boolean |
isAvailable() |
boolean |
isCalled() |
boolean |
isFiltered()
Is this genotype filtered or not?
|
protected static boolean |
isForbiddenKey(String key) |
boolean |
isHet() |
boolean |
isHetNonRef() |
boolean |
isHom() |
boolean |
isHomRef() |
boolean |
isHomVar() |
boolean |
isMixed() |
boolean |
isNoCall() |
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
|
abstract 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> |
sortedString(Map<T,V> c)
a utility method for generating sorted strings from a map key set.
|
String |
toBriefString() |
String |
toString() |
protected static String |
toStringIfExists(String name,
int v)
Returns a display name for field name with value v if this isn't -1.
|
protected static String |
toStringIfExists(String name,
int[] vs)
Returns a display name for field name with values vs if this isn't null.
|
protected static String |
toStringIfExists(String name,
String v)
Returns a display name for field name with String value v if this isn't null.
|
public static final long serialVersionUID
public static final Collection<String> PRIMARY_KEYS
public static final String PHASED_ALLELE_SEPARATOR
public static final String UNPHASED_ALLELE_SEPARATOR
public abstract List<Allele> getAlleles()
public int countAllele(Allele allele)
allele
- public abstract Allele getAllele(int i)
i
- the ith allele, must be < the ploidy, starting with 0public abstract boolean isPhased()
public int getPloidy()
public abstract int getDP()
public abstract int[] getAD()
public String getSampleName()
public abstract int getGQ()
public boolean hasPL()
public boolean hasAD()
public boolean hasGQ()
public boolean hasDP()
public GenotypeType getType()
protected GenotypeType determineType()
public boolean isHom()
public boolean isHomRef()
public boolean isHomVar()
public boolean isHet()
public boolean isHetNonRef()
public boolean isNoCall()
public boolean isCalled()
public boolean isMixed()
public boolean isAvailable()
public boolean hasLikelihoods()
public String getLikelihoodsString()
public GenotypeLikelihoods getLikelihoods()
public boolean isNonInformative()
public abstract int[] getPL()
public String getGenotypeString()
public String getGenotypeString(boolean ignoreRefState)
protected List<String> getAlleleStrings()
public String toBriefString()
public int compareTo(Genotype genotype)
compareTo
in interface Comparable<Genotype>
genotype
- public boolean sameGenotype(Genotype other)
public boolean sameGenotype(Genotype other, boolean ignorePhase)
public abstract Map<String,Object> getExtendedAttributes()
public boolean hasExtendedAttribute(String key)
key
- a non-null string key to check for an associationpublic Object getExtendedAttribute(String key, Object defaultValue)
key
- a non-null string key to fetch a value fordefaultValue
- the value to return if key isn't in the extended attributespublic Object getExtendedAttribute(String key)
key
- public final String getFilters()
public final boolean isFiltered()
@Deprecated public boolean hasLog10PError()
@Deprecated public double getLog10PError()
@Deprecated public int getPhredScaledQual()
@Deprecated public String getAttributeAsString(String key, String defaultValue)
@Deprecated public int getAttributeAsInt(String key, int defaultValue)
@Deprecated public double getAttributeAsDouble(String key, double defaultValue)
public Object getAnyAttribute(String key)
int[]
are converted inline into List<Integer>
for convenience.key
- public boolean hasAnyAttribute(String key)
protected static <T extends Comparable<T>,V> String sortedString(Map<T,V> c)
T
- the key typeV
- the value typec
- the mapprotected static final String toStringIfExists(String name, int v)
name
- of the field ("AD")v
- the value of the field, or -1 if missingprotected static final String toStringIfExists(String name, String v)
name
- of the field ("FT")v
- the value of the field, or null if missingprotected static final String toStringIfExists(String name, int[] vs)
name
- of the field ("AD")vs
- the value of the field, or null if missingprotected static final boolean hasForbiddenKey(Map<String,Object> attributes)
attributes
- the extended attributes keyprotected static final boolean isForbiddenKey(String key)