Class PairHMMModel

java.lang.Object
org.broadinstitute.hellbender.utils.pairhmm.PairHMMModel

public final class PairHMMModel extends Object
Helper class that implement calculations required to implement the PairHMM Finite State Automation (FSA) model.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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 Type
    Method
    Description
    static 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 site
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TRANS_PROB_ARRAY_LENGTH

      public static final int TRANS_PROB_ARRAY_LENGTH
      Length of the standard transition probability array.
      See Also:
    • matchToMatch

      public static final int matchToMatch
      Position in the transition probability array for the Match-to-Match transition.
      See Also:
    • indelToMatch

      public static final int indelToMatch
      Position in the transition probability array for the Indel-to-Match transition.
      See Also:
    • matchToInsertion

      public static final int matchToInsertion
      Position in the transition probability array for the Match-to-Insertion transition.
      See Also:
    • insertionToInsertion

      public static final int insertionToInsertion
      Position in the transition probability array for the Insertion-to-Insertion transition.
      See Also:
    • matchToDeletion

      public static final int matchToDeletion
      Position in the transition probability array for the Match-to-Deletion transition.
      See Also:
    • deletionToDeletion

      public static final int deletionToDeletion
      Position 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 - if dest is null.
      ArrayIndexOutOfBoundsException - if dest is not large enough.
      IllegalArgumentException - if insQual, delQual or gcp 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 length TRANS_PROB_ARRAY_LENGTH.
      Throws:
      NullPointerException - if dest is null.
      ArrayIndexOutOfBoundsException - if dest is not large enough.
      IllegalArgumentException - if insQual, delQual or gcp 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 actually insQual.length + 1.

      Each entry is the transition probability array for that base with a length of TRANS_PROB_ARRAY_LENGTH.

      Parameters:
      dest - the matrix to update
      insQuals - insertion qualities.
      delQuals - deletion qualities.
      gcps - gap-continuation penalty qualities.
      Throws:
      NullPointerException - if any of the input arrays, matrices is null or any entry in dest is null.
      IllegalArgumentException - if IllegalArgumentException if the input array don't have the same length.
      ArrayIndexOutOfBoundsException - if dest 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 actually insQual.length + 1.

      Each entry is the transition probability array for that base with a length of TRANS_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 is null.
      IllegalArgumentException - if IllegalArgumentException 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 - if dest is null.
      ArrayIndexOutOfBoundsException - if dest is not large enough.
      IllegalArgumentException - if insQual, delQual or gcp 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 length TRANS_PROB_ARRAY_LENGTH.
      Throws:
      NullPointerException - if dest is null.
      ArrayIndexOutOfBoundsException - if dest is not large enough.
      IllegalArgumentException - if insQual, delQual or gcp 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 actually insQual.length + 1.

      Each entry is the transition probability array for that base with a length of TRANS_PROB_ARRAY_LENGTH.

      Parameters:
      insQuals - insertion qualities.
      delQuals - deletion qualities.
      gcps - gap-continuation penalty qualities.
      Throws:
      NullPointerException - if any of the input arrays, matrices is null or any entry in dest is null.
      IllegalArgumentException - if IllegalArgumentException if the input array don't have the same length.
      ArrayIndexOutOfBoundsException - if dest 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 actually insQual.length + 1.

      Each entry is the transition probability array for that base with a length of TRANS_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 is null.
      IllegalArgumentException - if IllegalArgumentException 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 of maxReadLength + 1 by TRANS_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.