From 182c32a2b7efaf01ae683af1ccba8b3a271ca122 Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Thu, 21 Feb 2013 18:18:10 -0500 Subject: [PATCH] Relax bounds checking in QualityUtils.boundQual -- Previous version did runtime checking that qual >= 0 but BQSR was relying on boundQual to restore -1 to 1. So relax the bound. --- .../src/org/broadinstitute/sting/utils/QualityUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java b/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java index 1dcd5a9ae..fe782bc31 100644 --- a/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java +++ b/public/java/src/org/broadinstitute/sting/utils/QualityUtils.java @@ -375,13 +375,14 @@ public class QualityUtils { * WARNING -- because this function takes a byte for maxQual, you must be careful in converting * integers to byte. The appropriate way to do this is ((byte)(myInt & 0xFF)) * - * @param qual the uncapped quality score as an integer + * @param qual the uncapped quality score as an integer. Can be < 0 (which may indicate an error in the + * client code), which will be brought back to 1, but this isn't an error, as some + * routines may use this functionality (BaseRecalibrator, for example) * @param maxQual the maximum quality score, must be less < 255 * @return the bounded quality score */ @Ensures("(result & 0xFF) >= 1 && (result & 0xFF) <= (maxQual & 0xFF)") public static byte boundQual(final int qual, final byte maxQual) { - if ( qual < 0 ) throw new IllegalArgumentException("qual must be >= 0 " + qual); return (byte) (Math.max(Math.min(qual, maxQual & 0xFF), 1) & 0xFF); } }