Package haplotype

Class BitHapPair

  • All Implemented Interfaces:
    HapPair

    public final class BitHapPair
    extends java.lang.Object
    implements HapPair

    Class BitHapPair represents a pair of haplotypes for a sample. The class stores alleles as a bit array.

    Instances of class BitHapPair are immutable.
    • Constructor Summary

      Constructors 
      Constructor Description
      BitHapPair​(Markers markers, int idIndex, int[] alleles1, int[] alleles2)
      Constructs a new BitHapPair instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int allele1​(int marker)
      Returns the first allele for the specified marker.
      int allele2​(int marker)
      Returns the second allele for the specified marker.
      int idIndex()
      Returns the sample identifier index.
      Marker marker​(int marker)
      Returns the specified marker.
      Markers markers()
      Returns the markers.
      int nMarkers()
      Returns the number of markers.
      java.lang.String toString()
      Returns a string representation of this.
      • Methods inherited from class java.lang.Object

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

      • BitHapPair

        public BitHapPair​(Markers markers,
                          int idIndex,
                          int[] alleles1,
                          int[] alleles2)
        Constructs a new BitHapPair instance.
        Parameters:
        markers - the sequence of markers
        idIndex - the sample identifier index
        alleles1 - the sequence of allele indices for the first haplotype
        alleles2 - the sequence of alleles indices for the second haplotype
        Throws:
        java.lang.IllegalArgumentException - if alleles1.length != markers.nMarkers() || alleles2.length != markers.nMarkers()
        java.lang.IllegalArgumentException - if alleles1[k] < 0 || allele1[k] >= markers.marker(k).nAlleles() for some k satisfying 0 <= k && k < markers.nMarkers()
        java.lang.IllegalArgumentException - if alleles2[k] < 0 || allele2[k] >= markers.marker(k).nAlleles() for some k satisfying 0 <= k && k < markers.nMarkers()
        java.lang.IndexOutOfBoundsException - if idIndex < 0
        java.lang.NullPointerException - if marker == null || alleles1 == null || allele2 == null
    • Method Detail

      • allele1

        public int allele1​(int marker)
        Description copied from interface: HapPair
        Returns the first allele for the specified marker.
        Specified by:
        allele1 in interface HapPair
        Parameters:
        marker - a marker index
        Returns:
        the first allele for the specified marker
      • allele2

        public int allele2​(int marker)
        Description copied from interface: HapPair
        Returns the second allele for the specified marker.
        Specified by:
        allele2 in interface HapPair
        Parameters:
        marker - a marker index
        Returns:
        the second allele for the specified marker
      • markers

        public Markers markers()
        Description copied from interface: HapPair
        Returns the markers.
        Specified by:
        markers in interface HapPair
        Returns:
        the markers
      • marker

        public Marker marker​(int marker)
        Description copied from interface: HapPair
        Returns the specified marker.
        Specified by:
        marker in interface HapPair
        Parameters:
        marker - a marker index
        Returns:
        the specified marker
      • nMarkers

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

        public int idIndex()
        Description copied from interface: HapPair
        Returns the sample identifier index.
        Specified by:
        idIndex in interface HapPair
        Returns:
        the sample identifier index
      • toString

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