Permalink
Browse files

Added quick check for creation of bad BAQ values associated with badl…

…y encoded base qualities; hopefully this can help us debug the non-reproducible issue seen by many users.
  • Loading branch information...
1 parent 3cb83c2 commit 482890667290c498b1561d59f92ff6f336730e99 @eitanbanks eitanbanks committed Nov 28, 2012
View
2 public/java/src/org/broadinstitute/sting/utils/QualityUtils.java
@@ -9,7 +9,7 @@
* @author Kiran Garimella
*/
public class QualityUtils {
- public final static byte MAX_RECALIBRATED_Q_SCORE = 93;
+ public final static byte MAX_RECALIBRATED_Q_SCORE = SAMUtils.MAX_PHRED_SCORE;
public final static byte MAX_QUAL_SCORE = SAMUtils.MAX_PHRED_SCORE;
public final static double ERROR_RATE_OF_MAX_QUAL_SCORE = qualToErrorProbRaw(MAX_QUAL_SCORE);
View
13 public/java/src/org/broadinstitute/sting/utils/baq/BAQ.java
@@ -406,10 +406,15 @@ public static String encodeBQTag(SAMRecord read, byte[] baq) {
// so BQi = Qi - BAQi + 64
byte[] bqTag = new byte[baq.length];
for ( int i = 0; i < bqTag.length; i++) {
- int bq = (int)read.getBaseQualities()[i] + 64;
- int baq_i = (int)baq[i];
- int tag = bq - baq_i;
- if ( tag < 0 ) throw new ReviewedStingException("BAQ tag calculation error. BAQ value above base quality at " + read);
+ final int bq = (int)read.getBaseQualities()[i] + 64;
+ final int baq_i = (int)baq[i];
+ final int tag = bq - baq_i;
+ // problem with the calculation of the correction factor; this is our problem
+ if ( tag < 0 )
+ throw new ReviewedStingException("BAQ tag calculation error. BAQ value above base quality at " + read);
+ // the original quality is too high, almost certainly due to using the wrong encoding in the BAM file
+ if ( tag > Byte.MAX_VALUE )
+ throw new UserException.MalformedBAM(read, "we encountered an extremely high quality score (" + (bq - 64) + ") with BAQ correction factor of " + baq_i + "; the BAM file appears to be using the wrong encoding for quality scores");
bqTag[i] = (byte)tag;
}
return new String(bqTag);

0 comments on commit 4828906

Please sign in to comment.