Package phase

Class BasicPhaseStates


  • public final class BasicPhaseStates
    extends java.lang.Object

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

    Instances of BasicPhaseStates are not thread-safe.

    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int ibsStates​(int sample, byte[][][] nMismatches)
      Stores the Li and Stephens HMM for the specified target sample in the specified arrays.
      int ibsStates​(int sample, MarkerCluster mc, java.util.List<int[]> refAtMissingGT, byte[][][] nMismatches)
      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.
      int nMarkers()
      Returns the number of markers.
      int nTargSamples()
      Returns the number of target samples.
      • Methods inherited from class java.lang.Object

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

      • BasicPhaseStates

        public BasicPhaseStates​(PbwtPhaseIbs ibsHaps,
                                int maxStates)
        Constructs a new BasicPhaseStates 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

      • nTargSamples

        public int nTargSamples()
        Returns the number of target samples.
        Returns:
        the number of target samples
      • nMarkers

        public int nMarkers()
        Returns the number of markers.
        Returns:
        the number of markers
      • 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,
                             MarkerCluster mc,
                             java.util.List<int[]> refAtMissingGT,
                             byte[][][] nMismatches)
        Stores the Li and Stephens HMM for the specified target sample in the specified arrays. The nMismatches parameter is an array of three two-dimensional arrays: nMismatches[0] stores stores the allele mismatch data between the reference haplotypes and the haplotype composed of homozygous target genotypes, nMismatches[1] stores the allele mismatch data between the reference haplotypes and the first target haplotype, and nMismatches[2] stores the allele mismatch data between the reference haplotypes and the first target haplotype. Each two-dimensional array must have at least mc.nClusters() rows, and a column for each HMM state. An element of the two-dimensional array is 0 if the target and reference allele match and is 1 otherwise.
        Parameters:
        sample - the target sample index
        mc - the marker clusters
        refAtMissingGT - a list of arrays in which HMM state alleles at markers for which one or both target haplotypes have a missing allele
        nMismatches - arrays for storing present or absence of mismatches between target and reference alleles
        Returns:
        the number of state alleles at each marker
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nTargSamples()
        java.lang.IndexOutOfBoundsException - if nMismatches.length < 3
        java.lang.IndexOutOfBoundsException - if there exists j such that 0 < j && j < 3 && nMismatches[j].length < mc.nClusters()
        java.lang.IndexOutOfBoundsException - if there exists j, m such that (0 < j && j < 3 && 0 < m && m < mc.nClusters()), and nMismatches[j][m].length is less than the number of model states at marker m
        java.lang.IndexOutOfBoundsException - if missAlleles.get(j) is less than the number of model states for any j that indexes the missing genotypes
        java.lang.NullPointerException - if (mc == null || refAtMissingGT == null) or if any array is null
      • ibsStates

        public int ibsStates​(int sample,
                             byte[][][] nMismatches)
        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 nMismatchs[0][m][j] and nMismatches[1][m][j] respectively.
        Parameters:
        sample - the target sample index
        nMismatches - an array of two two-dimensional arrays in which the number of allele mismatches with reference haplotypes for the first haplotype and the second haplotype will be stored
        Returns:
        the number of state alleles at each marker
        Throws:
        java.lang.IndexOutOfBoundsException - if sample < 0 || sample >= this.nTargSamples()
        java.lang.IndexOutOfBoundsException - if nMismatches.length < 2
        java.lang.IndexOutOfBoundsException - if there exists j such that (0 < j && j < 2 && nMismatches[j].length < this.nMarkers())
        java.lang.IndexOutOfBoundsException - if there exists j, m such that (0 < j && j < 2 && 0 < m && m < this.nMarkers()), and nMismatches[j][m].length is less than the total number of model states
        java.lang.NullPointerException - if any array is null