Package vcf

Class LowMafRefDiallelicGTRec

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

    public final class LowMafRefDiallelicGTRec
    extends java.lang.Object
    implements RefGTRec

    Class LowMafRefDiallelicGTRec represent represents phased, non-missing genotypes for a list of reference samples at a single diallelic marker.

    Class LowMafRefDiallelicGTRec stores haplotypes that carry the minor allele.

    Instances of class LowMemRefDiallelicGTRec are immutable.

    • 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 alleleCount​(int allele)
      Returns the number of haplotypes that carry the specified non-major allele.
      int[] alleleCounts()
      Returns an array of length this.nAlleles() whose j-th element is the allele count of the j-th allele.
      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.
      int hapIndex​(int allele, int copy)
      Returns index of the haplotype that carries the specified copy of the specified allele.
      int[][] hapIndices()
      Returns an array whose j-th element is null if j is the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry the j-th allele sorted in increasing order
      boolean isAlleleCoded()
      Returns true if this instance stores the indices of haplotypes that carry non-major alleles, and returns false otherwise.
      boolean isCarrier​(int allele, int hap)
      Returns true if the specified haplotype carries the specified allele and return false otherwise.
      boolean isPhased()
      Returns true.
      boolean isPhased​(int sample)
      Returns true.
      int majorAllele()
      Returns the index of the major allele.
      IntArray map​(int index)
      Returns this.maps()[index].
      IntArray[] maps()
      Returns an array of maps, which when composed map haplotype indices to alleles.
      Marker marker()
      Returns the marker.
      int nMaps()
      Returns this.maps().length
      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
    • Constructor Detail

      • LowMafRefDiallelicGTRec

        public LowMafRefDiallelicGTRec​(RefGTRec rec)
        Constructs a new LowMafRefDiallelicGTRec instance from the specified data.
        Parameters:
        rec - the phased, non-missing genotype data
        Throws:
        java.lang.IllegalArgumentException - if rec.marker().nAlleles() != 2
        java.lang.NullPointerException - if rec == null
      • LowMafRefDiallelicGTRec

        public LowMafRefDiallelicGTRec​(VcfRecGTParser gtp)
        Constructs a new LowMafRefDiallelicGTRec instance from the specified data.
        Parameters:
        gtp - a VCF record parser that extracts sample genotypes
        Throws:
        java.lang.IllegalArgumentException - if the VCF record contains an unphased genotype or missing allele
        java.lang.IllegalArgumentException - if gtp.nAlleles() != 2
        java.lang.IllegalArgumentException - if a format error is detected in the VCF record
        java.lang.NullPointerException - if gtp == null
      • LowMafRefDiallelicGTRec

        public LowMafRefDiallelicGTRec​(Marker marker,
                                       Samples samples,
                                       int[][] hapIndices)
        Constructs a new LowMafRefDiallelicGTRec instance from the specified data. The specified hapIndices array is required to have length 2 and contain exactly one null element. The null element should be the major allele because this is most memory-efficient, but this requirement is not enforced.
        Parameters:
        marker - the marker
        samples - the samples
        hapIndices - whose j-th element is a list of haplotypes sorted in increasing order that carry the j-th allele, or is null
        Throws:
        java.lang.IllegalArgumentException - if marker.nAlleles() != 2
        java.lang.IllegalArgumentException - if marker.nAlleles() != hapIndices.length
        java.lang.IllegalArgumentException - if the (hapIndices does not contain exactly one null element
        java.lang.IllegalArgumentException - if the non-null element of hapIndices is not a sorted list of distinct haplotype indices between 0 (inclusive) and 2*samples.size() (exclusive)
        java.lang.NullPointerException - if marker == null || samples == null || hapIndices == null
    • Method Detail

      • hapIndices

        public int[][] hapIndices()
        Description copied from interface: RefGTRec
        Returns an array whose j-th element is null if j is the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry the j-th allele sorted in increasing order
        Specified by:
        hapIndices in interface RefGTRec
        Returns:
        an array whose j-th element is null if j is the major allele with lowest index, and otherwise is an array of indices of haplotypes that carry the j-th allele sorted in increasing order
      • isPhased

        public boolean isPhased​(int sample)
        Description copied from interface: RefGTRec
        Returns true.
        Specified by:
        isPhased in interface DuplicatesGTRec
        Specified by:
        isPhased in interface RefGTRec
        Parameters:
        sample - the sample index
        Returns:
        true
      • 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.
        Specified by:
        size in interface DuplicatesGTRec
        Specified by:
        size in interface IntArray
        Returns:
        the number of haplotypes
      • 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
      • 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}
      • isAlleleCoded

        public boolean isAlleleCoded()
        Description copied from interface: RefGTRec
        Returns true if this instance stores the indices of haplotypes that carry non-major alleles, and returns false otherwise.
        Specified by:
        isAlleleCoded in interface RefGTRec
        Returns:
        true if this instance stores the indices of haplotypes that carry non-major alleles
      • majorAllele

        public int majorAllele()
        Description copied from interface: RefGTRec
        Returns the index of the major allele.
        Specified by:
        majorAllele in interface RefGTRec
        Returns:
        the index of the major allele
      • alleleCounts

        public int[] alleleCounts()
        Description copied from interface: RefGTRec
        Returns an array of length this.nAlleles() whose j-th element is the allele count of the j-th allele.
        Specified by:
        alleleCounts in interface RefGTRec
        Returns:
        an array of allele counts
      • alleleCount

        public int alleleCount​(int allele)
        Description copied from interface: RefGTRec
        Returns the number of haplotypes that carry the specified non-major allele.
        Specified by:
        alleleCount in interface RefGTRec
        Parameters:
        allele - an allele index
        Returns:
        the number of haplotypes that carry the specified non-major allele
      • hapIndex

        public int hapIndex​(int allele,
                            int copy)
        Description copied from interface: RefGTRec
        Returns index of the haplotype that carries the specified copy of the specified allele.
        Specified by:
        hapIndex in interface RefGTRec
        Parameters:
        allele - an allele index
        copy - a copy index
        Returns:
        index of the haplotype that carries the specified allele
      • isCarrier

        public boolean isCarrier​(int allele,
                                 int hap)
        Description copied from interface: RefGTRec
        Returns true if the specified haplotype carries the specified allele and return false otherwise.
        Specified by:
        isCarrier in interface RefGTRec
        Parameters:
        allele - an allele index
        hap - a haplotype index
        Returns:
        true if the specified haplotype carries the specified allele
      • 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
      • nMaps

        public int nMaps()
        Description copied from interface: RefGTRec
        Returns this.maps().length
        Specified by:
        nMaps in interface RefGTRec
        Returns:
        this.maps().length
      • maps

        public IntArray[] maps()
        Description copied from interface: RefGTRec
        Returns an array of maps, which when composed map haplotype indices to alleles. The allele on haplotype h is determined by the following calculation:
                    IntArray[] maps = this.maps();
                    int value = maps[0].get(h);
                    for (int j=1; j<maps.length; ++j) {
                       value = indexArrays[j].get(value);
                    }
                    int allele = value
               
        Specified by:
        maps in interface RefGTRec
        Returns:
        an array of maps, which when composed map haplotype indices to alleles
      • map

        public IntArray map​(int index)
        Description copied from interface: RefGTRec
        Returns this.maps()[index].
        Specified by:
        map in interface RefGTRec
        Parameters:
        index - the index in this.maps()
        Returns:
        this.maps()[index]