Minor cleanup and expansion of the RecalDatum unit tests
This commit is contained in:
parent
7ec7a5d6b6
commit
04cc75aaec
|
|
@ -135,14 +135,6 @@ public class RecalDatum {
|
||||||
this.estimatedQReported = estimatedQReported;
|
this.estimatedQReported = estimatedQReported;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RecalDatum createRandomRecalDatum(int maxObservations, int maxErrors) {
|
|
||||||
final Random random = new Random();
|
|
||||||
final int nObservations = random.nextInt(maxObservations);
|
|
||||||
final int nErrors = random.nextInt(maxErrors);
|
|
||||||
final int qual = random.nextInt(QualityUtils.MAX_QUAL_SCORE);
|
|
||||||
return new RecalDatum(nObservations, nErrors, (byte)qual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final double getEstimatedQReported() {
|
public final double getEstimatedQReported() {
|
||||||
return estimatedQReported;
|
return estimatedQReported;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,11 @@ public class RecalDatumUnitTest extends BaseTest {
|
||||||
Assert.assertEquals(datum.getEstimatedQReportedAsByte(), cfg.getReportedQual());
|
Assert.assertEquals(datum.getEstimatedQReportedAsByte(), cfg.getReportedQual());
|
||||||
BaseTest.assertEqualsDoubleSmart(datum.getEmpiricalQuality(), cfg.getErrorRatePhredScaled());
|
BaseTest.assertEqualsDoubleSmart(datum.getEmpiricalQuality(), cfg.getErrorRatePhredScaled());
|
||||||
BaseTest.assertEqualsDoubleSmart(datum.getEmpiricalErrorRate(), cfg.getErrorRate());
|
BaseTest.assertEqualsDoubleSmart(datum.getEmpiricalErrorRate(), cfg.getErrorRate());
|
||||||
|
|
||||||
|
final double e = datum.getEmpiricalQuality();
|
||||||
|
Assert.assertTrue(datum.getEmpiricalQualityAsByte() >= Math.floor(e));
|
||||||
|
Assert.assertTrue(datum.getEmpiricalQualityAsByte() <= Math.ceil(e));
|
||||||
|
Assert.assertNotNull(datum.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dataProvider = "RecalDatumTestProvider")
|
@Test(dataProvider = "RecalDatumTestProvider")
|
||||||
|
|
@ -145,10 +150,32 @@ public class RecalDatumUnitTest extends BaseTest {
|
||||||
cfg.exTotal++;
|
cfg.exTotal++;
|
||||||
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
||||||
|
|
||||||
|
datum = cfg.makeRecalDatum();
|
||||||
|
datum.increment(false);
|
||||||
|
cfg.exTotal++;
|
||||||
|
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
||||||
|
|
||||||
|
datum = cfg.makeRecalDatum();
|
||||||
|
datum.incrementNumObservations(2);
|
||||||
|
cfg.exTotal += 2;
|
||||||
|
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
||||||
|
|
||||||
|
datum = cfg.makeRecalDatum();
|
||||||
|
datum.incrementNumMismatches(2);
|
||||||
|
cfg.exError += 2;
|
||||||
|
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
||||||
|
|
||||||
|
|
||||||
datum = cfg.makeRecalDatum();
|
datum = cfg.makeRecalDatum();
|
||||||
datum.increment(10, 5);
|
datum.increment(10, 5);
|
||||||
cfg.exError += 5;
|
cfg.exError += 5;
|
||||||
cfg.exTotal += 10;
|
cfg.exTotal += 10;
|
||||||
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
assertBasicFeaturesOfRecalDatum(datum, cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNoObs() {
|
||||||
|
final RecalDatum rd = new RecalDatum(0, 0, (byte)10);
|
||||||
|
Assert.assertEquals(rd.getEmpiricalErrorRate(), 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,6 +21,14 @@ import java.util.*;
|
||||||
* @since 4/21/12
|
* @since 4/21/12
|
||||||
*/
|
*/
|
||||||
public class RecalibrationReportUnitTest {
|
public class RecalibrationReportUnitTest {
|
||||||
|
private static RecalDatum createRandomRecalDatum(int maxObservations, int maxErrors) {
|
||||||
|
final Random random = new Random();
|
||||||
|
final int nObservations = random.nextInt(maxObservations);
|
||||||
|
final int nErrors = random.nextInt(maxErrors);
|
||||||
|
final int qual = random.nextInt(QualityUtils.MAX_QUAL_SCORE);
|
||||||
|
return new RecalDatum(nObservations, nErrors, (byte)qual);
|
||||||
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
public void testOutput() {
|
public void testOutput() {
|
||||||
final int length = 100;
|
final int length = 100;
|
||||||
|
|
@ -86,12 +94,12 @@ public class RecalibrationReportUnitTest {
|
||||||
final int[] covariates = rc.getKeySet(offset, errorMode);
|
final int[] covariates = rc.getKeySet(offset, errorMode);
|
||||||
final int randomMax = errorMode == EventType.BASE_SUBSTITUTION ? 10000 : 100000;
|
final int randomMax = errorMode == EventType.BASE_SUBSTITUTION ? 10000 : 100000;
|
||||||
|
|
||||||
rgTable.put(RecalDatum.createRandomRecalDatum(randomMax, 10), covariates[0], errorMode.index);
|
rgTable.put(createRandomRecalDatum(randomMax, 10), covariates[0], errorMode.index);
|
||||||
qualTable.put(RecalDatum.createRandomRecalDatum(randomMax, 10), covariates[0], covariates[1], errorMode.index);
|
qualTable.put(createRandomRecalDatum(randomMax, 10), covariates[0], covariates[1], errorMode.index);
|
||||||
nKeys += 2;
|
nKeys += 2;
|
||||||
for (int j = 0; j < optionalCovariates.size(); j++) {
|
for (int j = 0; j < optionalCovariates.size(); j++) {
|
||||||
final NestedIntegerArray<RecalDatum> covTable = recalibrationTables.getTable(RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j);
|
final NestedIntegerArray<RecalDatum> covTable = recalibrationTables.getTable(RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j);
|
||||||
covTable.put(RecalDatum.createRandomRecalDatum(randomMax, 10), covariates[0], covariates[1], j, covariates[RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j], errorMode.index);
|
covTable.put(createRandomRecalDatum(randomMax, 10), covariates[0], covariates[1], j, covariates[RecalibrationTables.TableType.OPTIONAL_COVARIATE_TABLES_START.index + j], errorMode.index);
|
||||||
nKeys++;
|
nKeys++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue