Package vcf

Class BasicGT

java.lang.Object
vcf.BasicGT
All Implemented Interfaces:
GT

public final class BasicGT extends Object implements GT

Class BasicGT represents genotypes for a list of markers and samples.

Instances of class BasicGT are immutable

  • Constructor Summary

    Constructors
    Constructor
    Description
    BasicGT(GTRec[] recs)
    Constructs a BasicGT instance from the specified data
    BasicGT(Markers markers, Samples samples, GTRec[] recs)
    Constructs a BasicGT instance from the specified data.
    BasicGT(Samples samples, GTRec[] recs)
    Constructs a BasicGT instance from the specified data
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    allele(int marker, int hap)
    Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.
    static int
    genotype(int a1, int a2)
    Returns the genotype index corresponding to the specified unordered alleles.
    boolean
    Returns true if the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returns false otherwise.
    boolean
    Returns true if the markers are ordered by decreasing chromosome base position, and returns false otherwise.
    marker(int markerIndex)
    Returns the specified marker.
    Returns the list of markers in order of increasing chromosome position.
    int
    Returns the number of haplotypes.
    int
    Returns the number of markers.
    int
    Returns the number of samples.
    restrict(int start, int end)
    Returns a new GT instance restricted to genotype data for the specified markers.
    static BasicGT
    restrict(BasicGT gt, int[] indices)
    Returns a BasicGT instance restricted to genotype data for the specified markers.
    restrict(Markers restrictedMarkers, int[] indices)
    Returns a GT instance restricted to genotype data for the specified markers.
    Returns the list of samples.
    Returns a string representation of this.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BasicGT

      public BasicGT(GTRec[] recs)
      Constructs a BasicGT instance from the specified data
      Parameters:
      recs - genotype records for a list of markers
      Throws:
      IllegalArgumentException - if elements of recs corresponding to the same chromosome are not contiguous and sorted in chromosome position order
      IllegalArgumentException - if recs.length == 0
      IllegalArgumentException - if any two elements of recs correspond to the same genetic marker
      IllegalArgumentException - if (recs[j].samples().equals(recs[k].samples()) == false) for any j, k satisfying (0 <= j && j < k && j < recs.length)
      NullPointerException - if recs == null
      NullPointerException - if (recs[j] == null) any j satisfying (0 <= j && j < recs.length)
    • BasicGT

      public BasicGT(Samples samples, GTRec[] recs)
      Constructs a BasicGT instance from the specified data
      Parameters:
      samples - the list of samples with genotype data
      recs - genotype records for a list of markers
      Throws:
      IllegalArgumentException - if elements of recs corresponding to the same chromosome are not contiguous and sorted in chromosome position order
      IllegalArgumentException - if any two elements of recs correspond to the same genetic marker
      IllegalArgumentException - if (recs[j].samples().equals(samples) == false) for any j satisfying (0 <= j && j < recs.length)
      NullPointerException - if samples == null || recs == null
      NullPointerException - if (recs[j] == null) any j satisfying (0 <= j && j < recs.length)
    • BasicGT

      public BasicGT(Markers markers, Samples samples, GTRec[] recs)
      Constructs a BasicGT instance from the specified data.
      Parameters:
      markers - the list of markers with genotype data
      samples - the list of samples with genotype data
      recs - the genotype data for each marker
      Throws:
      IllegalArgumentException - if (recs[j].marker().equals(markers.marker(j)) == false) for any j satisfying (0 <= j && j < recs.length)
      IllegalArgumentException - if (recs[j].samples().equals(samples) == false) for any j satisfying (0 <= j && j < recs.length)
      NullPointerException - if (markers == null || samples == null || recs == null)
      NullPointerException - if (recs[j] == null) any j satisfying (0 <= j && j < recs.length)
  • Method Details

    • genotype

      public static int genotype(int a1, int a2)
      Returns the genotype index corresponding to the specified unordered alleles.
      Parameters:
      a1 - the first allele index of an unordered genotype
      a2 - the second allele index of an unordered genotype
      Returns:
      the genotype index corresponding to the specified unordered alleles
      Throws:
      IllegalArgumentException - if a1 < 0 || a2 < 0
    • isReversed

      public boolean isReversed()
      Description copied from interface: GT
      Returns true if the markers are ordered by decreasing chromosome base position, and returns false otherwise.
      Specified by:
      isReversed in interface GT
      Returns:
      true if the markers are ordered by decreasing chromosome base position
    • nMarkers

      public int nMarkers()
      Description copied from interface: GT
      Returns the number of markers.
      Specified by:
      nMarkers in interface GT
      Returns:
      the number of markers
    • marker

      public Marker marker(int markerIndex)
      Description copied from interface: GT
      Returns the specified marker.
      Specified by:
      marker in interface GT
      Parameters:
      markerIndex - a marker index
      Returns:
      the specified marker
    • markers

      public Markers markers()
      Description copied from interface: GT
      Returns the list of markers in order of increasing chromosome position. If (this.isReversed() == false) then (this.markers().marker(j).equals(this.marker(j)) == true) for all (0 <= j && j < this.nMarkers()). If (this.isReversed() == true) then (this.markers().marker(this.nMarkers() - 1 - j).equals(this.marker(j)) == true) for all (0 <= j && j < this.nMarkers())
      Specified by:
      markers in interface GT
      Returns:
      the list of markers in order of increasing chromosome position
    • nHaps

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

      public int nSamples()
      Description copied from interface: GT
      Returns the number of samples.
      Specified by:
      nSamples in interface GT
      Returns:
      the number of samples
    • samples

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

      public boolean isPhased()
      Description copied from interface: GT
      Returns true if the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returns false otherwise.
      Specified by:
      isPhased in interface GT
      Returns:
      true if the genotype for each marker and sample is a phased, non-missing genotype
    • allele

      public int allele(int marker, int hap)
      Description copied from interface: GT
      Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing. The order of the two alleles is unspecified if this.isPhased() == false.
      Specified by:
      allele in interface GT
      Parameters:
      marker - the marker index
      hap - the haplotype index
      Returns:
      the allele on the specified haplotype for the specified marker
    • restrict

      public static BasicGT restrict(BasicGT gt, int[] indices)
      Returns a BasicGT instance restricted to genotype data for the specified markers.
      Parameters:
      gt - the BasicGT instance to be restricted
      indices - a list of distinct marker indices (from this.markers()) in increasing order
      Returns:
      a GT instance restricted to genotype data for the specified markers
      Throws:
      IndexOutOfBoundsException - if there exists j such that (0 <= j && j < indices.length) such that (indices[j] < 0 || indices[j] >= gt.nMarkers())
      IllegalArgumentException - if there exists j such that (1 <= j && j < indices.length) such that (indices[j] <= indice[j - 1])
      NullPointerException - if gt == null || indices == null
    • restrict

      public BasicGT restrict(Markers restrictedMarkers, int[] indices)
      Description copied from interface: GT
      Returns a GT instance restricted to genotype data for the specified markers.
      Specified by:
      restrict in interface GT
      Parameters:
      restrictedMarkers - the list of markers in the returned instance
      indices - a list of distinct marker indices (from this.markers()) in increasing order
      Returns:
      a GT instance restricted to genotype data for the specified markers
    • restrict

      public BasicGT restrict(int start, int end)
      Description copied from interface: GT
      Returns a new GT instance restricted to genotype data for the specified markers.
      Specified by:
      restrict in interface GT
      Parameters:
      start - the start marker (inclusive)
      end - the end marker (exclusive)
      Returns:
      a GT instance restricted to genotype data for the specified markers
    • toString

      public String toString()
      Returns a string representation of this. The exact details of the representation are unspecified and subject to change.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this