Class VcfGenotype

java.lang.Object
org.pharmgkb.parser.vcf.model.genotype.VcfGenotype

@Immutable public class VcfGenotype extends Object
A diploid (or haploid; see below) genotype matching the VCF 4.2 specification.

For example:

  • A/A (an unphased homozygous genotype)
  • A|ATG (an phased heterozygous 2bp insertion of TG)
This class can also handle haploid genotypes (e.g. A), but note that:

     Genotype.fromString("A").toString(); // prints A|A
 
 
Always use equals(Object) to compare genotypes, not toString().equals.
  • Constructor Details

    • VcfGenotype

      public VcfGenotype(@Nullable VcfAllele allele1, @Nullable VcfAllele allele2, boolean isPhased)
      Note:
      
         VcfGenotype homozygous = new VcfGenotype("A", "A", false);
         homogyzgous.isPhased(); // false
       
       
      The same logic applies with haploid genotypes.
  • Method Details

    • fromString

      @Nonnull public static VcfGenotype fromString(@Nonnull String genotype)
      Parameters:
      genotype - A string like A/TT
    • fromVcf

      @Nullable public static VcfGenotype fromVcf(@Nonnull VcfPosition position, @Nonnull VcfSample sample)
      Returns:
      The genotype, or null if GT is null
    • fromNumberString

      public static VcfGenotype fromNumberString(@Nonnull VcfPosition position, @Nonnull String genotype)
      Parameters:
      genotype - A string like 0/1
      Returns:
      The genotype, or null if GT is null
    • makeGt

      @Nonnull public String makeGt(@Nonnull VcfPosition position)
    • isPhased

      public boolean isPhased()
      Returns:
      True if the genotype is effectively phased.: returns true for haploid genotypes and homozygous genotypes
    • isHomozygous

      public boolean isHomozygous()
    • isNoCall

      public boolean isNoCall()
    • getAllele1

      @Nullable public VcfAllele getAllele1()
    • getAllele2

      @Nullable public VcfAllele getAllele2()
    • getAlleleSet

      @Nonnull public Set<VcfAllele> getAlleleSet()
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      For example, A|ATGC or A/C
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object