Package vcf

Class Markers

java.lang.Object
vcf.Markers

public final class Markers extends Object

Class Markers represent a list of markers in chromosome order.

Instances of class Markers are immutable.

  • Method Summary

    Modifier and Type
    Method
    Description
    int
    allele(BitArray hapBits, int marker)
    Returns the specified allele
    void
    allelesToBits(int[] alleles, BitArray bitList)
    Stores the specified alleles in the specified bitList
    int[]
    Returns the specified allele stored in the specified hapBits array.
    boolean
    contains(Marker marker)
    Returns true if the specified marker is not null and is an element in the list of markers represented by this, and returns false otherwise.
    static Markers
    create(Marker[] markers)
    Returns a new Markers instance that is constructed from the specified data.
    int[]
    Return an array of length this.size() + 1 whose k-th value is the the sum of the number of possible genotypes for markers with index less than k
    boolean
    Returns true if the specified object is a Markers instance which represents the same list of markers as this, and returns false otherwise.
    int
    Returns a hash code value for the object.
    marker(int marker)
    Returns the specified marker.
    Returns the list of markers.
    restrict(int[] indices)
    Returns a Markers instance that represents the specified markers.
    restrict(int start, int end)
    Returns a Markers instance that represents the specified range of marker indices.
    void
    setAllele(int marker, int allele, BitArray bitList)
    Stores the specified alleles in the specified bitList
    int
    Returns the number of markers.
    int
    Returns this.sumAlleles(this.nMarkers()).
    int
    sumAlleles(int marker)
    Returns the sum of the number of alleles for the markers with index less than the specified index.
    int
    Returns this.sumHaplotypeBits(this.nMarkers()).
    int
    sumHapBits(int marker)
    Returns the number of bits requires to store a haplotype for the markers with index less than the specified index.
    Returns a string representation of this.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • create

      public static Markers create(Marker[] markers)
      Returns a new Markers instance that is constructed from the specified data.
      Parameters:
      markers - a list of markers in chromosome order
      Returns:
      a new Markers instance corresponding to the specified list of markers
      Throws:
      IllegalArgumentException - if markers on a chromosome are not in chromosome order
      IllegalArgumentException - if there are duplicate markers
      IllegalArgumentException - if the markers on a chromosome do not form a contiguous set of entries within the array
      NullPointerException - if markers == null or if markers[j] == null for any j satisfying (0 <= j && j < markers.length)
    • cumSumGenotypes

      public int[] cumSumGenotypes()
      Return an array of length this.size() + 1 whose k-th value is the the sum of the number of possible genotypes for markers with index less than k
      Returns:
      an array whose k-th value is the the sum of the number of possible genotypes for markers with index less than k
    • hashCode

      public int hashCode()
      Returns a hash code value for the object. The returned hash code equals Arrays.deepHashCode(this.markers()).
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for the object
    • equals

      public boolean equals(Object obj)
      Returns true if the specified object is a Markers instance which represents the same list of markers as this, and returns false otherwise. Two lists of markers are the same if the lists have the same size and if markers with the same index in the two lists are equal.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be tested for equality with this
      Returns:
      true if the specified object is a Markers instance which represents the same list of markers as this
    • size

      public int size()
      Returns the number of markers.
      Returns:
      the number of markers
    • marker

      public Marker marker(int marker)
      Returns the specified marker.
      Parameters:
      marker - a marker index
      Returns:
      the specified marker
      Throws:
      IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
    • markers

      public Marker[] markers()
      Returns the list of markers.
      Returns:
      the list of markers
    • contains

      public boolean contains(Marker marker)
      Returns true if the specified marker is not null and is an element in the list of markers represented by this, and returns false otherwise.
      Parameters:
      marker - a marker
      Returns:
      true if the specified marker is not null and is an element in the list of markers represented by this
    • restrict

      public Markers restrict(int start, int end)
      Returns a Markers instance that represents the specified range of marker indices.
      Parameters:
      start - the starting marker index (inclusive)
      end - the ending marker index (exclusive)
      Returns:
      a Markers instance that represents the specified range of marker indices
      Throws:
      IndexOutOfBoundsException - if start < 0 || end > this.nMarkers()
      IllegalArgumentException - if start >= end
    • restrict

      public Markers restrict(int[] indices)
      Returns a Markers instance that represents the specified markers.
      Parameters:
      indices - a list of distinct marker indices in increasing order
      Returns:
      a new Markers instance that represents the specified markers
      Throws:
      IndexOutOfBoundsException - if there exists j such that (0 <= j && j < indices.length) such that (indices[j] < 0 || indices[j] >= this.nMarkers())
      IllegalArgumentException - if there exists j such that (1 <= j && j < indices.length) such that (indices[j] <= indice[j - 1])
      NullPointerException - if indices == null
    • sumAlleles

      public int sumAlleles(int marker)
      Returns the sum of the number of alleles for the markers with index less than the specified index.
      Parameters:
      marker - a marker index
      Returns:
      the sum of the number of alleles for the markers with index less than the specified index
      Throws:
      IndexOutOfBoundsException - if marker < 0 || marker > this.nMarkers()
    • sumAlleles

      public int sumAlleles()
      Returns this.sumAlleles(this.nMarkers()).
      Returns:
      this.sumAlleles(this.nMarkers())
    • sumHapBits

      public int sumHapBits(int marker)
      Returns the number of bits requires to store a haplotype for the markers with index less than the specified index.
      Parameters:
      marker - a marker index
      Returns:
      the number of bits requires to store a haplotype for the markers with index less than the specified index
      Throws:
      IndexOutOfBoundsException - if marker < 0 || marker > this.nMarkers()
    • sumHapBits

      public int sumHapBits()
      Returns this.sumHaplotypeBits(this.nMarkers()).
      Returns:
      this.sumHaplotypeBits(this.nMarkers())
    • bitsToAlleles

      public int[] bitsToAlleles(BitArray hapBits)
      Returns the specified allele stored in the specified hapBits array. The contract for this method is undefined if the specified hapBits array was not created with the this.allelesToBits() method.
      Parameters:
      hapBits - the bit array storing the haplotype alleles
      Returns:
      the specified allele stored in the specified hapBits array.
      Throws:
      NullPointerException - if hapBits == null
    • allelesToBits

      public void allelesToBits(int[] alleles, BitArray bitList)
      Stores the specified alleles in the specified bitList
      Parameters:
      alleles - a sequence of alleles
      bitList - a sequence of bits
      Throws:
      IllegalArgumentException - if alleles.length != this.nMarkers()
      IllegalArgumentException - if bitList.size() != this.sumHaplotypeBits()
      IllegalArgumentException - if there exists a k such that (0 < k && k < alleles.length) and (alleles[k] < 0 || alleles[k] >= this.marker(k).nAlleles())
      NullPointerException - if alleles == null || bitList == null
    • setAllele

      public void setAllele(int marker, int allele, BitArray bitList)
      Stores the specified alleles in the specified bitList
      Parameters:
      marker - a marker index
      allele - an allele index
      bitList - a sequence of bits
      Throws:
      IllegalArgumentException - if alleles.length != this.nMarkers()
      IllegalArgumentException - if bitList.size() != this.sumHaplotypeBits()
      IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
      IndexOutOfBoundsException - if allele < 0 || allele >= this.marker(marker).nAlleles()
      NullPointerException - if bitList == null
    • allele

      public int allele(BitArray hapBits, int marker)
      Returns the specified allele
      Parameters:
      hapBits - a haplotype encoded as bits with the this.allelesToBits() method
      marker - a marker index
      Returns:
      the specified allele
      Throws:
      IndexOutOfBoundsException - if marker < 0 || marker >= this.nMarkers()
      IndexOutOfBoundsException - if hapBits.size() < this.sumHaplotypeBits(marker + 1)
      NullPointerException - if hapBits == null
    • 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