Class VcfGenotype


  • public class VcfGenotype
    extends java.lang.Object
    A VCF genotype field There is one genotype per sample in each VCF entry
    Author:
    pablocingolani
    • Constructor Summary

      Constructors 
      Constructor Description
      VcfGenotype​(VcfEntry vcfEntry, java.lang.String format, java.lang.String values)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String name, java.lang.String value)
      Add a name=value pair WARNING: This method does NOT change the FORMAT field.
      int depth()
      Depth of coverage
      java.lang.String get​(java.lang.String fieldName)
      Get a genotype field
      int[] getGenotype()
      Get genotype numbers as an array E.g.
      java.lang.String getGenotype​(int idx)
      Get genotype string by index WARNING: If the genotype is missing, it returns an empty string.
      int getGenotypeCode()
      Return as a genotype SNP code: -1: if missing data of more than one ALT 0: if aa (0/0) 1: if Aa (0/1 or 1/0) 2: if AA (1/1) WARNING: In multi-allelic case, any non-ref is treated as ALT
      int getGenotypeCodeIgnoreMissing()
      Return as a genotype SNP code: 0: if aa (0/0) or any missing value 1: if Aa (0/1 or 1/0) 2: if AA (1/1)
      java.lang.String getGenotypeStr()
      Return genotypes as string (e.g.
      VcfEntry getVcfEntry()  
      boolean isHeterozygous()
      Is the most likely genotype heterozygous?
      boolean isHomozygous()
      Is this genotype homozygous? (either REF or ALT)
      boolean isHomozygousAlt()
      Is this genotype homozygous ALT?
      boolean isMissing()
      Is genotpye missing (e.g.
      boolean isPhased()  
      boolean isRef()
      Is any genotype different than REF? Note: This is calculated for the most likely genotype (GT field)
      boolean isVariant()
      Is any genotype different than REF? Note: This is calculated for the most likely genotype (GT field)
      int plodity()
      Genotype plodity (i.e.
      void set​(java.lang.String gtFieldName, java.lang.String gtValue)
      Set a genotype field value
      void setGenotype​(java.lang.String gtValue)
      Set genotype value
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • GT_FIELD_DEPTH_OF_COVERAGE

        public static final java.lang.String GT_FIELD_DEPTH_OF_COVERAGE
        See Also:
        Constant Field Values
      • GT_FIELD_ALLELIC_DEPTH_OF_COVERAGE

        public static final java.lang.String GT_FIELD_ALLELIC_DEPTH_OF_COVERAGE
        See Also:
        Constant Field Values
    • Constructor Detail

      • VcfGenotype

        public VcfGenotype​(VcfEntry vcfEntry,
                           java.lang.String format,
                           java.lang.String values)
    • Method Detail

      • add

        public void add​(java.lang.String name,
                        java.lang.String value)
        Add a name=value pair WARNING: This method does NOT change the FORMAT field. Use VcfEntry.addFormat() method
      • depth

        public int depth()
        Depth of coverage
        Returns:
        -1 if not found
      • get

        public java.lang.String get​(java.lang.String fieldName)
        Get a genotype field
      • getGenotype

        public int[] getGenotype()
        Get genotype numbers as an array E.g. '0/1' -> {0, 1} WARNING: If the genotype is missing, the numeric value is '-1'. E.g.: './.' -> {-1, -1}
        Returns:
      • getGenotype

        public java.lang.String getGenotype​(int idx)
        Get genotype string by index WARNING: If the genotype is missing, it returns an empty string. E.g.: './.' -> getGenotype(0) = ""
        Returns:
      • getGenotypeCode

        public int getGenotypeCode()
        Return as a genotype SNP code: -1: if missing data of more than one ALT 0: if aa (0/0) 1: if Aa (0/1 or 1/0) 2: if AA (1/1) WARNING: In multi-allelic case, any non-ref is treated as ALT
        Returns:
      • getGenotypeCodeIgnoreMissing

        public int getGenotypeCodeIgnoreMissing()
        Return as a genotype SNP code: 0: if aa (0/0) or any missing value 1: if Aa (0/1 or 1/0) 2: if AA (1/1)
        Returns:
      • getGenotypeStr

        public java.lang.String getGenotypeStr()
        Return genotypes as string (e.g. "A/C")
        Returns:
      • getVcfEntry

        public VcfEntry getVcfEntry()
      • isHeterozygous

        public boolean isHeterozygous()
        Is the most likely genotype heterozygous?
        Returns:
      • isHomozygous

        public boolean isHomozygous()
        Is this genotype homozygous? (either REF or ALT)
      • isHomozygousAlt

        public boolean isHomozygousAlt()
        Is this genotype homozygous ALT?
      • isMissing

        public boolean isMissing()
        Is genotpye missing (e.g. "GT=./.")
        Returns:
      • isPhased

        public boolean isPhased()
      • isRef

        public boolean isRef()
        Is any genotype different than REF? Note: This is calculated for the most likely genotype (GT field)
      • isVariant

        public boolean isVariant()
        Is any genotype different than REF? Note: This is calculated for the most likely genotype (GT field)
      • plodity

        public int plodity()
        Genotype plodity (i.e. how many copies of the chromosome does it have)
      • set

        public void set​(java.lang.String gtFieldName,
                        java.lang.String gtValue)
        Set a genotype field value
      • setGenotype

        public void setGenotype​(java.lang.String gtValue)
        Set genotype value
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object