A class with some static methods that aid the manipulation of quality scores and probabilities (including a method to compress a base and quality score into a byte for SAM output.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@271 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
kiran 2009-04-02 22:06:15 +00:00
parent b7a67da775
commit a8a6c63a32
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package org.broadinstitute.sting.utils;
public class QualityUtils {
private QualityUtils() {}
static public double qualToProb(byte qual) {
return 1.0 - Math.pow(10.0, ((double) qual)/-10.0);
}
static public byte probToQual(double prob) {
return (byte) Math.round(-10.0*Math.log10(1.0 - prob + 0.0001));
}
static public byte qualAndProbToCompressedQuality(int baseIndex, double prob) {
byte compressedQual = (byte) baseIndex;
byte cprob = (byte) (100.0*prob);
byte qualmask = (byte) 252;
compressedQual += ((cprob << 2) & qualmask);
return compressedQual;
}
}