Package phase
Class PhaseStates
- java.lang.Object
-
- phase.PhaseStates
-
public final class PhaseStates extends java.lang.ObjectClass
PhaseStateshas methods for constructing a Li and Stephens HMM for a target haplotype or target sample.Instances of
PhaseStatesare not thread-safe.
-
-
Constructor Summary
Constructors Constructor Description PhaseStates(PhaseIbs ibsHaps, int maxStates)Constructs a newPhaseStatesobject from the specified data.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intibsStates(int targHap, int[][] haps, byte[][] nMismatches)Stores the Li and Stephens HMM for the specified target haplotype in the specified arrays.intibsStates(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.intmaxStates()Returns the maximum number of HMM states at a marker.voidupdateFields(int hap, int step)Add the specified segment of the specified reference haplotype to the HMM state space.
-
-
-
Constructor Detail
-
PhaseStates
public PhaseStates(PhaseIbs ibsHaps, int maxStates)
Constructs a newPhaseStatesobject from the specified data.- Parameters:
ibsHaps- the IBS haplotype segmentsmaxStates- the maximum number of composite reference haplotypes that will be constructed- Throws:
java.lang.IllegalArgumentException- ifmaxStates < 1java.lang.NullPointerException- ifibsHaps == 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) betweenhap1[m]andhap2[m]for thej-th state are stored innMismatchs1[m][j]andnMismatches2[m][j]respectively.- Parameters:
sample- the target sample indexhap1- the alleles on the first target haplotypehap2- the alleles on the second target haplotypemissAlleles- a list of arrays for storing HMM state alleles at markers for which one or both target haplotypes have a missing allelenMismatches1- a two-dimensional array in which the number of allele mismatches (0 or 1) forhap1for each HMM state will be storednMismatches2- a two-dimensional array in which the number of allele mismatches (0 or 1) forhap2for each HMM state will be stored- Returns:
- the number of state alleles at each marker
- Throws:
java.lang.IndexOutOfBoundsException- ifsample < 0 || sample >= phaseData.targGT().nSamples()java.lang.IndexOutOfBoundsException- ifhap1.length < this.phaseData().targGT.nMarkers()java.lang.IndexOutOfBoundsException- ifhap2.length < this.phaseData().targGT.nMarkers()java.lang.IndexOutOfBoundsException- ifnMismatches1.length < this.phaseData().targGT().nMarkers()java.lang.IndexOutOfBoundsException- ifnMismatches2.length < this.phaseData().targGT().nMarkers()java.lang.IndexOutOfBoundsException- ifmissAlleles.lengthis less than the number of markers for which(hap1[m] < 0 || hap2[m] < 0)java.lang.IndexOutOfBoundsException- ifmissAlleles.get(j)is less than the number of model states for anyjsatisfying(0 <= j && j < misAlleles.size())java.lang.IndexOutOfBoundsException- ifnMismatches1[m].lengthis less than the number of model states for any markermsatisfying(0 <= m && m < nMismatches1.length)java.lang.IndexOutOfBoundsException- ifnMismatches2[m].lengthis less than the number of model states for any markermsatisfying(0 <= m && m < nMismatches2.length)java.lang.NullPointerException- if any array isnullor ifmissAlleles == 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 thej-th state at them-th marker is stored inhaps[m][j]. The number of allele mismatches (0 or 1) between the haplotype for thej-th state and the target haplotype at them-th marker is stored innMismatches[m][j]. The number of HMM states states at each marker is returned.- Parameters:
targHap- the haplotype indexhaps- the two-dimensional array in which the haplotype for each HMM state will be storednMismatches- 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- iftargHap < 0 || targHap >= this.phaseData().targGT().nHaps()java.lang.IndexOutOfBoundsException- ifhaps.length < this.phaseData.targGT().nMarkers()java.lang.IndexOutOfBoundsException- ifnMismatches.length < this.phaseData.targGT().nMarkers()java.lang.IndexOutOfBoundsException- ifhaps[m].lengthis less than the number of model states for any markermsatisfying(0 <= m && m < haps.length)java.lang.IndexOutOfBoundsException- ifnMismatches[m].lengthis less than the number of model states for any markermsatisfying(0 <= m && m < nMismatches.length)java.lang.NullPointerException- if any array isnull
-
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 indexstep- a genomic interval- Throws:
java.lang.IndexOutOfBoundsException- ifhap < 0 || hap >= this.phaseData().targGT().nHaps()java.lang.IndexOutOfBoundsException- ifstep < 0 || step >= this.phaseData().codedStates().nSteps()
-
-