@Test
  public void testQualCaches() {
    Assert.assertEquals(QualityUtils.qualToErrorProb((byte) 20), 0.01, 1e-6);
    Assert.assertEquals(QualityUtils.qualToErrorProbLog10((byte) 20), -2.0, 1e-6);
    Assert.assertEquals(QualityUtils.qualToProb((byte) 20), 0.99, 1e-6);
    Assert.assertEquals(QualityUtils.qualToProbLog10((byte) 20), -0.0043648054, 1e-6);

    Assert.assertEquals(QualityUtils.qualToErrorProb((byte) 30), 0.001, 1e-6);
    Assert.assertEquals(QualityUtils.qualToErrorProbLog10((byte) 30), -3.0, 1e-6);
    Assert.assertEquals(QualityUtils.qualToProb((byte) 30), 0.999, 1e-6);
    Assert.assertEquals(QualityUtils.qualToProbLog10((byte) 30), -0.000434511774, 1e-6);

    Assert.assertEquals(QualityUtils.qualToErrorProb((byte) 40), 0.0001, 1e-6);
    Assert.assertEquals(QualityUtils.qualToErrorProbLog10((byte) 40), -4.0, 1e-6);
    Assert.assertEquals(QualityUtils.qualToProb((byte) 40), 0.9999, 1e-6);
    Assert.assertEquals(QualityUtils.qualToProbLog10((byte) 40), -4.34316198e-5, 1e-6);
  }
  /** Example testng test using MyDataProvider */
  @Test(dataProvider = "QualTest")
  public void testMyData(final byte qual, final double errorRate) {
    final double trueRate = 1 - errorRate;

    final double actualErrorRate = QualityUtils.qualToErrorProb(qual);
    Assert.assertEquals(actualErrorRate, errorRate, TOLERANCE);
    final double actualTrueRate = QualityUtils.qualToProb(qual);
    Assert.assertEquals(actualTrueRate, trueRate, TOLERANCE);

    // log10 tests
    final double actualLog10ErrorRate = QualityUtils.qualToErrorProbLog10(qual);
    Assert.assertEquals(actualLog10ErrorRate, Math.log10(errorRate), TOLERANCE);
    final double actualLog10TrueRate = QualityUtils.qualToProbLog10(qual);
    Assert.assertEquals(actualLog10TrueRate, Math.log10(trueRate), TOLERANCE);

    // test that we can convert our error rates to quals, accounting for boundaries
    final int expectedQual = Math.max(Math.min(qual & 0xFF, QualityUtils.MAX_SAM_QUAL_SCORE), 1);
    final byte actualQual = QualityUtils.trueProbToQual(trueRate);
    Assert.assertEquals(actualQual, expectedQual & 0xFF);
    final byte actualQualFromErrorRate = QualityUtils.errorProbToQual(errorRate);
    Assert.assertEquals(actualQualFromErrorRate, expectedQual & 0xFF);

    for (int maxQual = 10; maxQual < QualityUtils.MAX_SAM_QUAL_SCORE; maxQual++) {
      final byte maxAsByte = (byte) (maxQual & 0xFF);
      final byte expectedQual2 = (byte) (Math.max(Math.min(qual & 0xFF, maxQual), 1) & 0xFF);
      final byte actualQual2 = QualityUtils.trueProbToQual(trueRate, maxAsByte);
      Assert.assertEquals(actualQual2, expectedQual2, "Failed with max " + maxQual);
      final byte actualQualFromErrorRate2 = QualityUtils.errorProbToQual(errorRate, maxAsByte);
      Assert.assertEquals(actualQualFromErrorRate2, expectedQual2, "Failed with max " + maxQual);

      // test the integer routines
      final byte actualQualInt2 = QualityUtils.trueProbToQual(trueRate, maxQual);
      Assert.assertEquals(actualQualInt2, expectedQual2, "Failed with max " + maxQual);
      final byte actualQualFromErrorRateInt2 = QualityUtils.errorProbToQual(errorRate, maxQual);
      Assert.assertEquals(actualQualFromErrorRateInt2, expectedQual2, "Failed with max " + maxQual);
    }
  }