Class PairHMMModel
java.lang.Object
org.broadinstitute.hellbender.utils.pairhmm.PairHMMModel
Helper class that implement calculations required to implement the PairHMM Finite State Automation (FSA) model.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Position in the transition probability array for the Deletion-to-Deletion transition.static final int
Position in the transition probability array for the Indel-to-Match transition.static final int
Position in the transition probability array for the Insertion-to-Insertion transition.static final int
Position in the transition probability array for the Match-to-Deletion transition.static final int
Position in the transition probability array for the Match-to-Insertion transition.static final int
Position in the transition probability array for the Match-to-Match transition.static final int
Length of the standard transition probability array. -
Method Summary
Modifier and TypeMethodDescriptionstatic double[][]
createTransitionMatrix
(int maxReadLength) Creates a transition probability matrix large enough to work with sequences of a particular length.static double
matchToMatchProb
(byte insQual, byte delQual) Returns the probability that neither of two event takes place.static double
matchToMatchProb
(int insQual, int delQual) Returns the probability that neither of two events, insertion and deletion, takes place.static double
matchToMatchProbLog10
(byte insQual, byte delQual) Returns the log10 probability that neither of two events, insertion and deletion, takes place.static double
matchToMatchProbLog10
(int insQual, int delQual) Returns the log-probability that neither of two events takes place.static double[][]
qualToTransProbs
(byte[] insQuals, byte[] delQuals, byte[] gcps) Returns a matrix with the transition probabilities for a number of bases.static double[]
qualToTransProbs
(byte insQual, byte delQual, byte gcp) Returns a transition probability array given the different quality scores affecting a read site.static void
qualToTransProbs
(double[][] dest, byte[] insQuals, byte[] delQuals, byte[] gcps) Fills ax matrix with the transition probabilities for a number of bases.static void
qualToTransProbs
(double[] dest, byte insQual, byte delQual, byte gcp) Fills a transition probability array given the different quality scores affecting a read sitestatic double[][]
qualToTransProbsLog10
(byte[] insQuals, byte[] delQuals, byte[] gcps) Returns a matrix with the log10 transition probabilities for a number of bases.static double[]
qualToTransProbsLog10
(byte insQual, byte delQual, byte gcp) Returns a transition log10 probability array given the different quality scores affecting a read site.static void
qualToTransProbsLog10
(double[][] dest, byte[] insQuals, byte[] delQuals, byte[] gcps) Fills a matrix with the log10 transition probabilities for a number of bases.static void
qualToTransProbsLog10
(double[] dest, byte insQual, byte delQual, byte gcp) Fills a transition log10-probability array given the different quality scores affecting a read site.
-
Field Details
-
TRANS_PROB_ARRAY_LENGTH
public static final int TRANS_PROB_ARRAY_LENGTHLength of the standard transition probability array.- See Also:
-
matchToMatch
public static final int matchToMatchPosition in the transition probability array for the Match-to-Match transition.- See Also:
-
indelToMatch
public static final int indelToMatchPosition in the transition probability array for the Indel-to-Match transition.- See Also:
-
matchToInsertion
public static final int matchToInsertionPosition in the transition probability array for the Match-to-Insertion transition.- See Also:
-
insertionToInsertion
public static final int insertionToInsertionPosition in the transition probability array for the Insertion-to-Insertion transition.- See Also:
-
matchToDeletion
public static final int matchToDeletionPosition in the transition probability array for the Match-to-Deletion transition.- See Also:
-
deletionToDeletion
public static final int deletionToDeletionPosition in the transition probability array for the Deletion-to-Deletion transition.- See Also:
-
-
Method Details
-
qualToTransProbs
public static void qualToTransProbs(double[] dest, byte insQual, byte delQual, byte gcp) Fills a transition probability array given the different quality scores affecting a read site- Parameters:
insQual
- the insertion quality score as a byte.delQual
- the deletion quality score as a byte.gcp
- the gap-continuation-penalty score as a byte.- Throws:
NullPointerException
- ifdest
isnull
.ArrayIndexOutOfBoundsException
- ifdest
is not large enough.IllegalArgumentException
- ifinsQual
,delQual
orgcp
is less than negative.
-
qualToTransProbs
public static double[] qualToTransProbs(byte insQual, byte delQual, byte gcp) Returns a transition probability array given the different quality scores affecting a read site.- Parameters:
insQual
- the insertion quality score as a byte.delQual
- the deletion quality score as a byte.gcp
- the gap-continuation-penalty score as a byte.- Returns:
- never
null
. An array of lengthTRANS_PROB_ARRAY_LENGTH
. - Throws:
NullPointerException
- ifdest
isnull
.ArrayIndexOutOfBoundsException
- ifdest
is not large enough.IllegalArgumentException
- ifinsQual
,delQual
orgcp
is less than negative.
-
qualToTransProbs
public static void qualToTransProbs(double[][] dest, byte[] insQuals, byte[] delQuals, byte[] gcps) Fills ax matrix with the transition probabilities for a number of bases. The first dimension of the matrix correspond to the different bases where the first one is stored in position 1. Thus the position 0 is left empty and the length of the resulting matrix is actuallyinsQual.length + 1
. Each entry is the transition probability array for that base with a length ofTRANS_PROB_ARRAY_LENGTH
.- Parameters:
dest
- the matrix to updateinsQuals
- insertion qualities.delQuals
- deletion qualities.gcps
- gap-continuation penalty qualities.- Throws:
NullPointerException
- if any of the input arrays, matrices isnull
or any entry indest
isnull
.IllegalArgumentException
- ifIllegalArgumentException
if the input array don't have the same length.ArrayIndexOutOfBoundsException
- ifdest
or any of its elements is not large enough to contain the transition matrix.
-
qualToTransProbs
public static double[][] qualToTransProbs(byte[] insQuals, byte[] delQuals, byte[] gcps) Returns a matrix with the transition probabilities for a number of bases. The first dimension of the matrix correspond to the different bases where the first one is stored in position 1. Thus the position 0 is left empty and the length of the resulting matrix is actuallyinsQual.length + 1
. Each entry is the transition probability array for that base with a length ofTRANS_PROB_ARRAY_LENGTH
.- Parameters:
insQuals
- insertion qualities.delQuals
- deletion qualities.gcps
- gap-continuation penalty qualities.- Returns:
- never
null
, an matrix of the dimensions explained above. - Throws:
NullPointerException
- if any of the input arrays isnull
.IllegalArgumentException
- ifIllegalArgumentException
if the input array don't have the same length.
-
qualToTransProbsLog10
public static void qualToTransProbsLog10(double[] dest, byte insQual, byte delQual, byte gcp) Fills a transition log10-probability array given the different quality scores affecting a read site.- Parameters:
insQual
- the insertion quality score as a byte.delQual
- the deletion quality score as a byte.gcp
- the gap-continuation-penalty score as a byte.- Throws:
NullPointerException
- ifdest
isnull
.ArrayIndexOutOfBoundsException
- ifdest
is not large enough.IllegalArgumentException
- ifinsQual
,delQual
orgcp
is less than negative.
-
qualToTransProbsLog10
public static double[] qualToTransProbsLog10(byte insQual, byte delQual, byte gcp) Returns a transition log10 probability array given the different quality scores affecting a read site.- Parameters:
insQual
- the insertion quality score as a byte.delQual
- the deletion quality score as a byte.gcp
- the gap-continuation-penalty score as a byte.- Returns:
- never
null
. An array of lengthTRANS_PROB_ARRAY_LENGTH
. - Throws:
NullPointerException
- ifdest
isnull
.ArrayIndexOutOfBoundsException
- ifdest
is not large enough.IllegalArgumentException
- ifinsQual
,delQual
orgcp
is less than negative.
-
qualToTransProbsLog10
public static void qualToTransProbsLog10(double[][] dest, byte[] insQuals, byte[] delQuals, byte[] gcps) Fills a matrix with the log10 transition probabilities for a number of bases. The first dimension of the matrix correspond to the different bases where the first one is stored in position 1. Thus the position 0 is left empty and the length of the resulting matrix is actuallyinsQual.length + 1
. Each entry is the transition probability array for that base with a length ofTRANS_PROB_ARRAY_LENGTH
.- Parameters:
insQuals
- insertion qualities.delQuals
- deletion qualities.gcps
- gap-continuation penalty qualities.- Throws:
NullPointerException
- if any of the input arrays, matrices isnull
or any entry indest
isnull
.IllegalArgumentException
- ifIllegalArgumentException
if the input array don't have the same length.ArrayIndexOutOfBoundsException
- ifdest
or any of its elements is not large enough to contain the transition matrix.
-
qualToTransProbsLog10
public static double[][] qualToTransProbsLog10(byte[] insQuals, byte[] delQuals, byte[] gcps) Returns a matrix with the log10 transition probabilities for a number of bases. The first dimension of the matrix correspond to the different bases where the first one is stored in position 1. Thus the position 0 is left empty and the length of the resulting matrix is actuallyinsQual.length + 1
. Each entry is the transition probability array for that base with a length ofTRANS_PROB_ARRAY_LENGTH
.- Parameters:
insQuals
- insertion qualities.delQuals
- deletion qualities.gcps
- gap-continuation penalty qualities.- Returns:
- never
null
, an matrix of the dimensions explained above. - Throws:
NullPointerException
- if any of the input arrays isnull
.IllegalArgumentException
- ifIllegalArgumentException
if the input array don't have the same length.
-
createTransitionMatrix
public static double[][] createTransitionMatrix(int maxReadLength) Creates a transition probability matrix large enough to work with sequences of a particular length.- Parameters:
maxReadLength
- the maximum read length for the transition matrix.- Returns:
- never
null
. A matrix ofmaxReadLength + 1
byTRANS_PROB_ARRAY_LENGTH
positions.
-
matchToMatchProb
public static double matchToMatchProb(byte insQual, byte delQual) Returns the probability that neither of two event takes place. We assume that both event never occur together and that delQual is the conditional probability (qual. encoded) of the second event, given the first event didn't took place. So that the probability of no event is:
We assume that both event never occur together so that the probability of no event is:
1 - ProbErr(insQual) - ProbErr(delQual)
- Parameters:
insQual
- PhRED scaled quality/probability of the first event.delQual
- PhRED scaled quality/probability of the second event.- Returns:
- a value between 0 and 1.
-
matchToMatchProbLog10
public static double matchToMatchProbLog10(byte insQual, byte delQual) Returns the log10 probability that neither of two events, insertion and deletion, takes place. We assume that both event never occur together so that the probability of no event is:
1 - ProbErr(insQual) - ProbErr(delQual)
- Parameters:
insQual
- PhRED scaled quality/probability of an insertion.delQual
- PhRED scaled quality/probability of a deletion.- Returns:
- a value between 0 and -Inf.
-
matchToMatchProb
public static double matchToMatchProb(int insQual, int delQual) Returns the probability that neither of two events, insertion and deletion, takes place. We assume that both event never occur together and that delQual is the conditional probability (qual. encoded) of the second event, given the first event didn't took place. So that the probability of no event is:
1 - ProbErr(insQual) - ProbErr(delQual)
- Parameters:
insQual
- PhRED scaled quality/probability of an insertion.delQual
- PhRED scaled quality/probability of a deletion.- Returns:
- a value between 0 and 1.
-
matchToMatchProbLog10
public static double matchToMatchProbLog10(int insQual, int delQual) Returns the log-probability that neither of two events takes place. We assume that both events never occur together and that delQual is the conditional probability (qual. encoded) of the second event, given the first event didn't took place. So that the probability of no event is:
1 - ProbErr(insQual) - ProbErr(delQual)
- Parameters:
insQual
- PhRED scaled quality/probability of an insertion.delQual
- PhRED scaled quality/probability of a deletion.- Returns:
- a value between 0 and -Inf.
-