htsjdk.samtools
Class SQTagUtil

java.lang.Object
  extended by htsjdk.samtools.SQTagUtil

public class SQTagUtil
extends java.lang.Object

Utility methods for encoding and decoding the SQ tag value of SAMRecord.


Nested Class Summary
static class SQTagUtil.SQBase
          The ordinals of these are stored in the high-order 2 bits of each byte of the SQ tag.
 
Field Summary
static byte MAX_QUALITY
           
 
Constructor Summary
SQTagUtil()
           
 
Method Summary
static byte baseAndProbDiffToSqValue(int base, byte probRatio)
          Compress a base and a log probabiliy difference (-10log10(p3/p2)) into a single byte so that it can be output in a SAMRecord's SQ field.
static byte baseAndProbDiffToSqValue(SQTagUtil.SQBase base, byte probRatio)
          Compress a base and a log probabiliy difference (-10log10(p3/p2)) into a single byte so that it can be output in a SAMRecord's SQ field.
static void reverseComplementSqArray(byte[] sqArray)
          Reverses and complements the sqValues in place.
static byte sqScaledProbabilityRatio(double secondBestLikelihood, double thirdBestLikelihood)
          Convert a pair of likelihoods into a value suitable for passing to baseAndProbDiffToSqValue.
static SQTagUtil.SQBase sqValueToBase(byte sqValue)
          Retrieve the 2nd-best base call from SQ value.
static int sqValueToBaseOrdinal(byte sqValue)
          Retrieve the 2nd-best base call from SQ value.
static byte sqValueToProbRatio(byte sqValue)
          Retrieve SQ-scaled probability ratio from SQ value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_QUALITY

public static final byte MAX_QUALITY
See Also:
Constant Field Values
Constructor Detail

SQTagUtil

public SQTagUtil()
Method Detail

sqScaledProbabilityRatio

public static byte sqScaledProbabilityRatio(double secondBestLikelihood,
                                            double thirdBestLikelihood)
Convert a pair of likelihoods into a value suitable for passing to baseAndProbDiffToSqValue.

Parameters:
secondBestLikelihood - Probability of the 2nd-best base call. 1 > secondBestLikelihood > thirdBestLikelihood.
thirdBestLikelihood - Probability of the 3rd-best base call. thirdBestLikelihood > 0.
Returns:
ratio of input probabilities for storing in SQ tag.

baseAndProbDiffToSqValue

public static byte baseAndProbDiffToSqValue(SQTagUtil.SQBase base,
                                            byte probRatio)
Compress a base and a log probabiliy difference (-10log10(p3/p2)) into a single byte so that it can be output in a SAMRecord's SQ field.

Parameters:
base - the 2nd-best base.
probRatio - the log probability difference between the secondary and tertiary bases (-10log10(p3/p2)), rounded to an integer and capped so it fits in 6 bits.
Returns:
a byte containing the index and the log probability difference.

baseAndProbDiffToSqValue

public static byte baseAndProbDiffToSqValue(int base,
                                            byte probRatio)
Compress a base and a log probabiliy difference (-10log10(p3/p2)) into a single byte so that it can be output in a SAMRecord's SQ field.

Parameters:
base - the 2nd-best base (A=0, C=1, G=2, T=3).
probRatio - the log probability difference between the secondary and tertiary bases (-10log10(p3/p2)), rounded to an integer and capped so it fits in 6 bits. If this value is > MAX_QUALITY, it is truncated to that.
Returns:
a byte containing the index and the log probability difference.

sqValueToProbRatio

public static byte sqValueToProbRatio(byte sqValue)
Retrieve SQ-scaled probability ratio from SQ value.

Parameters:
sqValue -
Returns:
the log probability difference between the secondary and tertiary bases (-10log10(p3/p2)).

sqValueToBase

public static SQTagUtil.SQBase sqValueToBase(byte sqValue)
Retrieve the 2nd-best base call from SQ value.

Parameters:
sqValue -
Returns:
2nd-best base call.

sqValueToBaseOrdinal

public static int sqValueToBaseOrdinal(byte sqValue)
Retrieve the 2nd-best base call from SQ value.

Parameters:
sqValue -
Returns:
Ordinal of 2nd-best base call.

reverseComplementSqArray

public static void reverseComplementSqArray(byte[] sqArray)
Reverses and complements the sqValues in place.

Parameters:
sqArray - Array of SQ-values, with 2nd-best base in high-order 2 bits, and probability diff in low-order 6 bits.