Class Genotype

    • Field Detail

      • PRIMARY_KEYS

        public static final Collection<String> 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
    • Constructor Detail

      • Genotype

        protected Genotype​(String sampleName,
                           String filters)
    • Method Detail

      • getAlleles

        public abstract List<Allele> getAlleles()
        Returns:
        the alleles for this genotype. Cannot be null. May be empty
      • countAllele

        public int countAllele​(Allele allele)
        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

        public abstract Allele getAllele​(int i)
        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

        public String 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

        public GenotypeType getType()
        Returns:
        the high-level type of this sample's genotype
      • determineType

        protected GenotypeType 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

        public String 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

        public GenotypeLikelihoods 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

        public String 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

        public String getGenotypeString​(boolean ignoreRefState)
        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

        protected List<String> getAlleleStrings()
        Utility that returns a list of allele strings corresponding to the alleles in this sample
        Returns:
      • toBriefString

        public String toBriefString()
      • compareTo

        public int compareTo​(Genotype genotype)
        comparable genotypes -> compareTo on the sample names
        Specified by:
        compareTo in interface Comparable<Genotype>
        Parameters:
        genotype -
        Returns:
      • sameGenotype

        public boolean sameGenotype​(Genotype other)
      • sameGenotype

        public boolean sameGenotype​(Genotype other,
                                    boolean ignorePhase)
      • getExtendedAttributes

        public abstract Map<String,​Object> getExtendedAttributes()
        Returns the extended attributes for this object
        Returns:
        is never null, but is often isEmpty()
      • hasExtendedAttribute

        public 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
        Parameters:
        key - a non-null string key to check for an association
        Returns:
        true if key has a value in the extendedAttributes
      • getExtendedAttribute

        public Object getExtendedAttribute​(String key,
                                           Object defaultValue)
        Get the extended attribute value associated with key, if possible
        Parameters:
        key - a non-null string key to fetch a value for
        defaultValue - 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

        public Object getExtendedAttribute​(String key)
        Same as #getExtendedAttribute with a null default
        Parameters:
        key -
        Returns:
      • getFilters

        public final String 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
        public boolean hasLog10PError()
        Deprecated.
      • getLog10PError

        @Deprecated
        public double getLog10PError()
        Deprecated.
      • getPhredScaledQual

        @Deprecated
        public int getPhredScaledQual()
        Deprecated.
      • getAttributeAsInt

        @Deprecated
        public int getAttributeAsInt​(String key,
                                     int defaultValue)
        Deprecated.
      • getAttributeAsDouble

        @Deprecated
        public double getAttributeAsDouble​(String key,
                                           double defaultValue)
        Deprecated.
      • getAnyAttribute

        public Object getAnyAttribute​(String key)
        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, all int[] are converted inline into List<Integer> for convenience.
        Parameters:
        key -
        Returns:
      • hasAnyAttribute

        public boolean hasAnyAttribute​(String key)
      • sortedString

        protected static <T extends Comparable<T>,​V> String sortedString​(Map<T,​V> c)
        a utility method for generating sorted strings from a map key set.
        Type Parameters:
        T - the key type
        V - the value type
        Parameters:
        c - the map
        Returns:
        a sting, enclosed in {}, with comma seperated key value pairs in order of the keys
      • toStringIfExists

        protected static final String toStringIfExists​(String name,
                                                       int v)
        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

        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. 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

        protected static final String toStringIfExists​(String name,
                                                       int[] vs)
        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

        protected 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?
        Parameters:
        attributes - the extended attributes key
        Returns:
      • isForbiddenKey

        protected static final boolean isForbiddenKey​(String key)