Package vcf

Class BitSetGT

  • All Implemented Interfaces:
    IntArray, DuplicatesGTRec, GTRec, MarkerContainer

    public final class BitSetGT
    extends java.lang.Object
    implements GTRec

    Class BitSetGT represents genotype emission probabilities for a list of samples at a single marker. The genotype emission probabilities are determined by the called genotypes for the samples.

    Class BitSetGT stores alleles using java.util.BitSet objects.

    Instances of class BitSetGT are immutable.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String GT_FORMAT
      The VCF FORMAT code for genotype data: "GT".
    • Constructor Summary

      Constructors 
      Constructor Description
      BitSetGT​(VcfHeader vcfHeader, java.lang.String vcfRecord)
      Constructs a new BitSetGT instance representing the specified VCF record's GT format field data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int allele1​(int sample)
      Returns the first allele for the specified sample or -1 if the allele is missing.
      int allele2​(int sample)
      Returns the second allele for the specified sample or -1 if the allele is missing.
      int[] alleles()
      Returns an array of length this.size() whose j-th element is equal to this.allele(j}
      int get​(int hap)
      Returns the specified allele for the specified haplotype or -1 if the allele is missing.
      float gl​(int sample, int a1, int a2)
      Returns the probability of the observed data for the specified sample if the specified pair of ordered alleles is the true ordered genotype.
      boolean isGTData()
      Returns true if the value returned by this.gl() is determined by a called or missing genotype, and returns false otherwise.
      boolean isPhased()
      Returns true if every genotype for each sample is a phased, non-missing genotype, and returns false otherwise.
      boolean isPhased​(int sample)
      Returns true if the genotype for the specified sample is a phased, nonmissing genotype, and returns false otherwise.
      Marker marker()
      Returns the marker.
      int nAlleles()
      Returns the number of marker alleles.
      int nSamples()
      Returns the number of samples.
      Samples samples()
      Returns the list of samples.
      int size()
      Returns the number of haplotypes.
      java.lang.String toString()
      Returns the data represented by this as a VCF record with a GT format field.
      • Methods inherited from class java.lang.Object

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

      • GT_FORMAT

        public static final java.lang.String GT_FORMAT
        The VCF FORMAT code for genotype data: "GT".
        See Also:
        Constant Field Values
    • Constructor Detail

      • BitSetGT

        public BitSetGT​(VcfHeader vcfHeader,
                        java.lang.String vcfRecord)
        Constructs a new BitSetGT instance representing the specified VCF record's GT format field data.
        Parameters:
        vcfHeader - meta-information lines and header line for the specified VCF record.
        vcfRecord - a VCF record corresponding to the specified vcfHeader object
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in the VCF record
        java.lang.IllegalArgumentException - if rec.nSamples() == 0
        java.lang.IllegalArgumentException - if the header line or VCF record does not have a "GT" format field
        java.lang.NullPointerException - if vcfHeader == null || vcfRecord == null
    • Method Detail

      • nSamples

        public int nSamples()
        Description copied from interface: DuplicatesGTRec
        Returns the number of samples. The returned value is equal to this.size()/2.
        Specified by:
        nSamples in interface DuplicatesGTRec
        Returns:
        the number of samples
      • samples

        public Samples samples()
        Description copied from interface: GTRec
        Returns the list of samples.
        Specified by:
        samples in interface GTRec
        Returns:
        the list of samples
      • size

        public int size()
        Description copied from interface: DuplicatesGTRec
        Returns the number of haplotypes. The returned value is equal to 2*this.nSamples().
        Specified by:
        size in interface DuplicatesGTRec
        Specified by:
        size in interface IntArray
        Returns:
        the number of haplotypes
      • isPhased

        public boolean isPhased()
        Description copied from interface: DuplicatesGTRec
        Returns true if every genotype for each sample is a phased, non-missing genotype, and returns false otherwise.
        Specified by:
        isPhased in interface DuplicatesGTRec
        Returns:
        true if the genotype for each sample is a phased, non-missing genotype
      • isGTData

        public boolean isGTData()
        Description copied from interface: GTRec
        Returns true if the value returned by this.gl() is determined by a called or missing genotype, and returns false otherwise.
        Specified by:
        isGTData in interface GTRec
        Returns:
        true if the value returned by this.gl() is determined by a called or missing genotype
      • isPhased

        public boolean isPhased​(int sample)
        Description copied from interface: DuplicatesGTRec
        Returns true if the genotype for the specified sample is a phased, nonmissing genotype, and returns false otherwise.
        Specified by:
        isPhased in interface DuplicatesGTRec
        Parameters:
        sample - a sample index
        Returns:
        true if the genotype for the specified sample is a phased, nonmissing genotype
      • allele1

        public int allele1​(int sample)
        Description copied from interface: DuplicatesGTRec
        Returns the first allele for the specified sample or -1 if the allele is missing. The two alleles for a sample are arbitrarily ordered if this.unphased(marker, sample) == false.
        Specified by:
        allele1 in interface DuplicatesGTRec
        Parameters:
        sample - a sample index
        Returns:
        the first allele for the specified sample
      • allele2

        public int allele2​(int sample)
        Description copied from interface: DuplicatesGTRec
        Returns the second allele for the specified sample or -1 if the allele is missing. The two alleles for a sample are arbitrarily ordered if this.unphased(marker, sample) == false.
        Specified by:
        allele2 in interface DuplicatesGTRec
        Parameters:
        sample - a sample index
        Returns:
        the second allele for the specified sample
      • gl

        public float gl​(int sample,
                        int a1,
                        int a2)
        Description copied from interface: GTRec
        Returns the probability of the observed data for the specified sample if the specified pair of ordered alleles is the true ordered genotype.
        Specified by:
        gl in interface GTRec
        Parameters:
        sample - the sample index
        a1 - the first allele index
        a2 - the second allele index
        Returns:
        the probability of the observed data for the specified sample if the specified pair of ordered alleles is the true ordered genotype.
      • get

        public int get​(int hap)
        Description copied from interface: DuplicatesGTRec
        Returns the specified allele for the specified haplotype or -1 if the allele is missing. The two alleles for a sample at a marker are arbitrarily ordered if this.unphased(marker, hap/2) == false.
        Specified by:
        get in interface DuplicatesGTRec
        Specified by:
        get in interface IntArray
        Parameters:
        hap - a haplotype index
        Returns:
        the specified allele for the specified sample
      • alleles

        public int[] alleles()
        Description copied from interface: DuplicatesGTRec
        Returns an array of length this.size() whose j-th element is equal to this.allele(j}
        Specified by:
        alleles in interface DuplicatesGTRec
        Returns:
        an array of length this.size() whose j-th element is equal to this.allele(j}
      • nAlleles

        public int nAlleles()
        Description copied from interface: MarkerContainer
        Returns the number of marker alleles.
        Specified by:
        nAlleles in interface MarkerContainer
        Returns:
        the number of marker alleles.
      • toString

        public java.lang.String toString()
        Returns the data represented by this as a VCF record with a GT format field. The returned VCF record will have missing QUAL and INFO fields, will have "PASS" in the filter field, and will have a GT format field.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the data represented by this as a VCF record with a GT format field