Package vcf

Interface RefGTRec

All Superinterfaces:
GTRec, IntArray
All Known Implementing Classes:
AlleleRefGTRec, HapRefGTRec, IntArrayRefGTRec, TwoAlleleRefGTRec

public interface RefGTRec extends GTRec

Interface RefGTRec represents represents phased genotype data for one marker. For implementations of this interface, unless otherwise specified in the implementation documentation, if the isAlleleCoded() method returns false, the majorAllele(), alleleCount(), and hapIndex() methods will be computationally expensive with compute time proportional to the number of haplotypes. Alternatively if the isAlleleCoded() method returns true, the maps() and map() methods will be computationally expensive with compute time proportional to the number of haplotypes.

All instances of RefGTRec are required to be immutable.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    alleleCount(int allele)
    Returns the number of haplotypes that carry the specified non-major allele.
    int[]
    Returns an array of length this.nAlleles() whose j-th element is the allele count of the j-th allele.
    static RefGTRec
    alleleRefGTRec(Marker marker, Samples samples, int[][] alleleToHaps)
    Constructs and returns a new allele-coded RefGTRec instance from the specified data.
    static RefGTRec
    Returns an allele-coded RefGTRec instance for the specified data.
    static RefGTRec
    Constructs and returns a new allele-coded RefGTRec instance from the specified data.
    int[][]
    Returns an array of length this.marker().nAlleles() whose j-th element is null or is a list of the haplotypes in increasing order that carry allele j.
    int
    hapIndex(int allele, int copy)
    Returns index of the haplotype that carries the specified copy of the specified allele.
    Returns an IndexArray with this.size() elements that maps haplotype to allele.
    boolean
    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
    Returns true.
    boolean
    isPhased(int sample)
    Returns true.
    int
    Returns the major allele with lowest index.
    map(int index)
    Returns this.maps()[index].
    Returns an array of maps, which when composed map haplotype indices to alleles.
    int
    Returns the sum of the lengths of non-null rows of this.alleleToHaps().
    int
    Returns this.maps().length

    Methods inherited from interface vcf.GTRec

    get, marker, samples, size
  • Method Details

    • alleleRefGTRec

      static RefGTRec alleleRefGTRec(RefGTRec rec)
      Returns an allele-coded RefGTRec instance for the specified data.
      Parameters:
      rec - the phased, non-missing genotype data
      Returns:
      an allele-coded RefGTRec instance for the specified data
      Throws:
      NullPointerException - if rec == null
    • alleleRefGTRec

      static RefGTRec alleleRefGTRec(VcfRecGTParser gtp)
      Constructs and returns a new allele-coded RefGTRec instance from the specified data.
      Parameters:
      gtp - a VCF record parser that extracts sample genotypes
      Returns:
      an allele-coded RefGTRec instance
      Throws:
      IllegalArgumentException - if the VCF record contains an unphased genotype or missing allele
      IllegalArgumentException - if a format error is detected in the VCF record
      NullPointerException - if gtp == null
    • alleleRefGTRec

      static RefGTRec alleleRefGTRec(Marker marker, Samples samples, int[][] alleleToHaps)
      Constructs and returns a new allele-coded RefGTRec instance from the specified data.
      Parameters:
      marker - the marker
      samples - the samples
      alleleToHaps - an array whose j-th element is null if j is the major allele and otherwise is a list of haplotypes sorted in increasing order that carry the j-th allele. If there is more than one allele with a maximal allele count, the major allele is the smallest allele with maximal allele count. If a haplotype is contained in a list for more than one non-major allele, the haplotype will be assumed to carry the smallest allele.
      Returns:
      an allele-coded RefGTRec instance
      Throws:
      IllegalArgumentException - if the (hapIndices[j] == null) and j is not the major allele or if (hapIndices[j] != null) and j is the major allele
      IllegalArgumentException - if any non-null element of hapIndices is not a sorted list of distinct haplotype indices between 0 (inclusive) and 2*samples.size() (exclusive)
      IllegalArgumentException - if marker.nAlleles() != hapIndices.length
      NullPointerException - if marker == null || samples == null || hapIndices == null
    • alleleToHaps

      int[][] alleleToHaps()
      Returns an array of length this.marker().nAlleles() whose j-th element is null or is a list of the haplotypes in increasing order that carry allele j. Exactly one element of the returned array must be null. It is recommended that the null element correspond to the major allele with lowest index, but this is not a requirement for implementations of this method.
      Returns:
      Returns an array of length this..marker().nAlleles() whose j-th element is null or is a list of the haplotypes in increasing order that carry allele j
    • hapToAllele

      IndexArray hapToAllele()
      Returns an IndexArray with this.size() elements that maps haplotype to allele.
      Returns:
      an IndexArray with this.size() elements that maps haplotype to allele
    • nAlleleCodedHaps

      int nAlleleCodedHaps()
      Returns the sum of the lengths of non-null rows of this.alleleToHaps().
      Returns:
      the sum of the lengths of non-null rows of this.alleleToHaps()
    • isPhased

      boolean isPhased(int sample)
      Returns true.
      Specified by:
      isPhased in interface GTRec
      Parameters:
      sample - the sample index
      Returns:
      true
      Throws:
      IndexOutOfBoundsException - if sample < 0 || sample >= this.nSamples()
    • isPhased

      boolean isPhased()
      Returns true.
      Specified by:
      isPhased in interface GTRec
      Returns:
      true
    • isAlleleCoded

      boolean isAlleleCoded()
      Returns true if this instance stores the indices of haplotypes that carry non-major alleles, and returns false otherwise.
      Returns:
      true if this instance stores the indices of haplotypes that carry non-major alleles
    • majorAllele

      int majorAllele()
      Returns the major allele with lowest index.
      Returns:
      the major allele with lowest index
    • alleleCounts

      int[] alleleCounts()
      Returns an array of length this.nAlleles() whose j-th element is the allele count of the j-th allele.
      Returns:
      an array of allele counts
    • alleleCount

      int alleleCount(int allele)
      Returns the number of haplotypes that carry the specified non-major allele.
      Parameters:
      allele - an allele index
      Returns:
      the number of haplotypes that carry the specified non-major allele
      Throws:
      IllegalArgumentException - if allele == this.majorAllele()
      IndexOutOfBoundsException - if allele < 0 || allele >= this.nAlleles()
    • hapIndex

      int hapIndex(int allele, int copy)
      Returns index of the haplotype that carries the specified copy of the specified allele.
      Parameters:
      allele - an allele index
      copy - a copy index
      Returns:
      index of the haplotype that carries the specified allele
      Throws:
      IllegalArgumentException - if allele == this.majorAllele()
      IndexOutOfBoundsException - if allele < 0 || allele >= this.nAlleles()
      IndexOutOfBoundsException - if copy < 0 || copy >= this.alleleCount(allele)
    • isCarrier

      boolean isCarrier(int allele, int hap)
      Returns true if the specified haplotype carries the specified allele and return false otherwise.
      Parameters:
      allele - an allele index
      hap - a haplotype index
      Returns:
      true if the specified haplotype carries the specified allele
      Throws:
      IndexOutOfBoundsException - if hap < 0 || hap >= this.size()
      IndexOutOfBoundsException - if allele < 0 || allele >= this.nAlleles()
    • nMaps

      int nMaps()
      Returns this.maps().length
      Returns:
      this.maps().length
    • maps

      IntArray[] maps()
      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
             
      Returns:
      an array of maps, which when composed map haplotype indices to alleles
    • map

      IntArray map(int index)
      Returns this.maps()[index].
      Parameters:
      index - the index in this.maps()
      Returns:
      this.maps()[index]
      Throws:
      IndexOutOfBoundsException - if index < 0 || index >= this.nMaps()