Package vcf

Class IntArrayRefGTRec

java.lang.Object
vcf.IntArrayRefGTRec
All Implemented Interfaces:
IntArray, GTRec, RefGTRec

public final class IntArrayRefGTRec extends Object implements RefGTRec

Class IntArrayRefGT represents phased, non-missing genotypes for a list of reference samples at a single marker. Genotype emission probabilities are determined by the sample genotypes.

Instances of class IntArrayRefGT are immutable.

  • Constructor Summary

    Constructors
    Constructor
    Description
    IntArrayRefGTRec(Marker marker, Samples samples, int[] alleles)
    Constructs a new IntArrayRefGT instance from the specified phased genotype data.
    IntArrayRefGTRec(Marker marker, Samples samples, IndexArray alleles)
    Constructs a new IntArrayRefGT instance from the specified phased genotype data.
  • 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.
    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
    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.
    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.
    Returns the marker.
    int
    Returns the sum of the lengths of non-null rows of this.alleleToHaps().
    int
    Returns this.maps().length
    static int
    nonNullCnt(int[][] alleleToHaps)
    Returns the sum of the lengths of non-null rows of the specified two-dimensional array.
    Returns the samples.
    int
    Returns the number of haplotypes.
    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 Details

    • IntArrayRefGTRec

      public IntArrayRefGTRec(Marker marker, Samples samples, int[] alleles)
      Constructs a new IntArrayRefGT instance from the specified phased genotype data.
      Parameters:
      marker - the marker
      samples - the list of samples
      alleles - the list of phased alleles
      Throws:
      IllegalArgumentException - if alleles.length != 2*samples.size()
      IllegalArgumentException - if (alleles[j] < 0 || alleles[j] >= marker.nAlleles()) for any j satisfying 0 <= j && j < allele1.length
      NullPointerException - if marker==null || samples==null || alleles==null
    • IntArrayRefGTRec

      public IntArrayRefGTRec(Marker marker, Samples samples, IndexArray alleles)
      Constructs a new IntArrayRefGT instance from the specified phased genotype data.
      Parameters:
      marker - the marker
      samples - the list of samples
      alleles - the list of phased alleles
      Throws:
      IllegalArgumentException - if alleles.size() != 2*samples.size()
      IllegalArgumentException - if alleles.valueSize() >= marker.nAlleles()
      NullPointerException - if marker==null || samples==null || alleles==null
  • Method Details

    • isPhased

      public boolean isPhased(int sample)
      Description copied from interface: RefGTRec
      Returns true.
      Specified by:
      isPhased in interface GTRec
      Specified by:
      isPhased in interface RefGTRec
      Parameters:
      sample - the sample index
      Returns:
      true
    • isPhased

      public boolean isPhased()
      Returns true.
      Specified by:
      isPhased in interface GTRec
      Specified by:
      isPhased in interface RefGTRec
      Returns:
      true
    • 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 major allele with lowest index.
      Specified by:
      majorAllele in interface RefGTRec
      Returns:
      the major allele with lowest index
    • 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
    • samples

      public Samples samples()
      Returns the samples. The returned samples are the filtered samples after all sample exclusions.
      Specified by:
      samples in interface GTRec
      Returns:
      the samples.
    • size

      public int size()
      Description copied from interface: GTRec
      Returns the number of haplotypes.
      Specified by:
      size in interface GTRec
      Specified by:
      size in interface IntArray
      Returns:
      the number of haplotypes
    • marker

      public Marker marker()
      Description copied from interface: GTRec
      Returns the marker.
      Specified by:
      marker in interface GTRec
      Returns:
      the marker
    • alleleToHaps

      public int[][] alleleToHaps()
      Description copied from interface: RefGTRec
      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.
      Specified by:
      alleleToHaps in interface RefGTRec
      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

      public IndexArray hapToAllele()
      Description copied from interface: RefGTRec
      Returns an IndexArray with this.size() elements that maps haplotype to allele.
      Specified by:
      hapToAllele in interface RefGTRec
      Returns:
      an IndexArray with this.size() elements that maps haplotype to allele
    • nAlleleCodedHaps

      public int nAlleleCodedHaps()
      Description copied from interface: RefGTRec
      Returns the sum of the lengths of non-null rows of this.alleleToHaps().
      Specified by:
      nAlleleCodedHaps in interface RefGTRec
      Returns:
      the sum of the lengths of non-null rows of this.alleleToHaps()
    • get

      public int get(int hap)
      Description copied from interface: GTRec
      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 GTRec
      Specified by:
      get in interface IntArray
      Parameters:
      hap - a haplotype index
      Returns:
      the specified allele for the specified sample
    • 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 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 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]
    • nonNullCnt

      public static int nonNullCnt(int[][] alleleToHaps)
      Returns the sum of the lengths of non-null rows of the specified two-dimensional array.
      Parameters:
      alleleToHaps - a two-dimensional array
      Returns:
      the sum of the lengths of non-null rows
      Throws:
      NullPointerException - if alleleToHaps == null