Package phase

Class PhaseStates


  • public final class PhaseStates
    extends java.lang.Object

    Class PhaseStates has methods for constructing a Li and Stephens HMM for a target haplotype or target sample.

    Instances of PhaseStates are not thread-safe.

    • Constructor Summary

      Constructors 
      Constructor Description
      PhaseStates​(PhaseIbs ibsHaps, int maxStates)
      Constructs a new PhaseStates object from the specified data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int ibsStates​(int targHap, int[][] haps, byte[][] nMismatches)
      Stores the Li and Stephens HMM for the specified target haplotype in the specified arrays.
      int ibsStates​(int sample, int[] hap1, int[] hap2, java.util.List<int[]> missAlleles, byte[][] nMismatches1, byte[][] nMismatches2)
      Stores the Li and Stephens HMM for the specified target sample in the specified arrays.
      int maxStates()
      Returns the maximum number of HMM states at a marker.
      void updateFields​(int hap, int step)
      Add the specified segment of the specified reference haplotype to the HMM state space.
      • Methods inherited from class java.lang.Object

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

      • PhaseStates

        public PhaseStates​(PhaseIbs ibsHaps,
                           int maxStates)
        Constructs a new PhaseStates object from the specified data.
        Parameters:
        ibsHaps - the IBS haplotype segments
        maxStates - the maximum number of composite reference haplotypes that will be constructed
        Throws:
        java.lang.IllegalArgumentException - if maxStates < 1
        java.lang.NullPointerException - if ibsHaps == null
    • Method Detail

      • maxStates

        public int maxStates()
        Returns the maximum number of HMM states at a marker.
        Returns:
        the maximum number of HMM states at a marker
      • ibsStates

        public int ibsStates​(int sample,
                             int[] hap1,
                             int[] hap2,
                             java.util.List<int[]> missAlleles,
                             byte[][] nMismatches1,
                             byte[][] nMismatches2)
        Stores the Li and Stephens HMM for the specified target sample in the specified arrays. The number of allele mismatches (0 or 1) between hap1[m] and hap2[m] for the j-th state are stored in nMismatchs1[m][j] and nMismatches2[m][j] respectively.
        Parameters:
        sample - the target sample index
        hap1 - the alleles on the first target haplotype
        hap2 - the alleles on the second target haplotype
        missAlleles - a list of arrays for storing HMM state alleles at markers for which one or both target haplotypes have a missing allele
        nMismatches1 - a two-dimensional array in which the number of allele mismatches (0 or 1) for hap1 for each HMM state will be stored
        nMismatches2 - a two-dimensional array in which the number of allele mismatches (0 or 1) for hap2 for each HMM state will be stored
        Returns:
        the number of state alleles at each marker
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= phaseData.targGT().nSamples()
        java.lang.IndexOutOfBoundsException - if hap1.length < this.phaseData().targGT.nMarkers()
        java.lang.IndexOutOfBoundsException - if hap2.length < this.phaseData().targGT.nMarkers()
        java.lang.IndexOutOfBoundsException - if nMismatches1.length < this.phaseData().targGT().nMarkers()
        java.lang.IndexOutOfBoundsException - if nMismatches2.length < this.phaseData().targGT().nMarkers()
        java.lang.IndexOutOfBoundsException - if missAlleles.length is less than the number of markers for which (hap1[m] < 0 || hap2[m] < 0)
        java.lang.IndexOutOfBoundsException - if missAlleles.get(j) is less than the number of model states for any j satisfying (0 <= j && j < misAlleles.size())
        java.lang.IndexOutOfBoundsException - if nMismatches1[m].length is less than the number of model states for any marker m satisfying (0 <= m && m < nMismatches1.length)
        java.lang.IndexOutOfBoundsException - if nMismatches2[m].length is less than the number of model states for any marker m satisfying (0 <= m && m < nMismatches2.length)
        java.lang.NullPointerException - if any array is null or if missAlleles == null
      • ibsStates

        public int ibsStates​(int targHap,
                             int[][] haps,
                             byte[][] nMismatches)
        Stores the Li and Stephens HMM for the specified target haplotype in the specified arrays. The haplotype for the j-th state at the m-th marker is stored in haps[m][j]. The number of allele mismatches (0 or 1) between the haplotype for the j-th state and the target haplotype at the m-th marker is stored in nMismatches[m][j]. The number of HMM states states at each marker is returned.
        Parameters:
        targHap - the haplotype index
        haps - the two-dimensional array in which the haplotype for each HMM state will be stored
        nMismatches - the two-dimensional array in which the number of allele mismatches (0 or 1) for each HMM state will be stored
        Returns:
        the number of HMM states at each marker
        Throws:
        java.lang.IndexOutOfBoundsException - if targHap < 0 || targHap >= this.phaseData().targGT().nHaps()
        java.lang.IndexOutOfBoundsException - if haps.length < this.phaseData.targGT().nMarkers()
        java.lang.IndexOutOfBoundsException - if nMismatches.length < this.phaseData.targGT().nMarkers()
        java.lang.IndexOutOfBoundsException - if haps[m].length is less than the number of model states for any marker m satisfying (0 <= m && m < haps.length)
        java.lang.IndexOutOfBoundsException - if nMismatches[m].length is less than the number of model states for any marker m satisfying (0 <= m && m < nMismatches.length)
        java.lang.NullPointerException - if any array is null
      • updateFields

        public void updateFields​(int hap,
                                 int step)
        Add the specified segment of the specified reference haplotype to the HMM state space.
        Parameters:
        hap - a haplotype index
        step - a genomic interval
        Throws:
        java.lang.IndexOutOfBoundsException - if hap < 0 || hap >= this.phaseData().targGT().nHaps()
        java.lang.IndexOutOfBoundsException - if step < 0 || step >= this.phaseData().codedStates().nSteps()