New methods to generated compressed SQ quality elements in line with the SAM spec.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@699 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
kiran 2009-05-14 16:50:31 +00:00
parent c3b2c66911
commit 64c65c7751
1 changed files with 21 additions and 0 deletions

View File

@ -73,6 +73,18 @@ public class QualityUtils {
return compressedQual;
}
static public byte baseAndProbDiffToCompressedQuality(int baseIndex, double probdiff) {
byte compressedQual = 0;
compressedQual = (byte) baseIndex;
byte cprob = (byte) probdiff;
byte qualmask = (byte) 252;
compressedQual += ((cprob << 2) & qualmask);
return compressedQual;
}
/**
* From a compressed base, extract the base index (0:A, 1:C, 2:G, 3:T)
*
@ -98,6 +110,15 @@ public class QualityUtils {
return ((double) x2)/100.0;
}
static public double compressedQualityToProbDiff(byte compressedQual) {
// Because java natives are signed, extra care must be taken to avoid
// shifting a 1 into the sign bit in the implicit promotion of 2 to an int.
int x2 = ((int) compressedQual) & 0xff;
x2 = (x2 >>> 2);
return ((double) x2);
}
/**
* Return the complement of a base index.
*