MetricsChecker implements HealthChecker { @NotNull @Override public List<QCValue> run() throws IOException { WGSMetrics metrics = extractMetrics(); List<QCValue> qcValues = Lists.newArrayList(); qcValues.add(ImmutableQCValue.of(QCValueType.REF_COVERAGE_10X, String.valueOf(metrics.ref10xCoveragePercentage()))); qcValues.add(ImmutableQCValue.of(QCValueType.REF_COVERAGE_20X, String.valueOf(metrics.ref20xCoveragePercentage()))); if (tumorSample != null) { assert metrics.tumor30xCoveragePercentage() != null; assert metrics.tumor60xCoveragePercentage() != null; qcValues.add(ImmutableQCValue.of(QCValueType.TUMOR_COVERAGE_30X, String.valueOf(metrics.tumor30xCoveragePercentage()))); qcValues.add(ImmutableQCValue.of(QCValueType.TUMOR_COVERAGE_60X, String.valueOf(metrics.tumor60xCoveragePercentage()))); } return qcValues; } MetricsChecker(@NotNull final String refSample, @Nullable final String tumorSample, @NotNull final String metricsDirectory); @NotNull @Override List<QCValue> run();  }
@Test public void extractDataFromMetricsWorksForSomatic() throws IOException { MetricsChecker checker = new MetricsChecker("reference", "tumor", METRICS_DIRECTORY); List<QCValue> values = checker.run(); assertEquals(4, values.size()); for (QCValue value : values) { if (value.type() == QCValueType.REF_COVERAGE_10X) { assertEquals("0.98261", value.value()); } else if (value.type() == QCValueType.REF_COVERAGE_20X) { assertEquals("0.980701", value.value()); } else if (value.type() == QCValueType.TUMOR_COVERAGE_30X) { assertEquals("0.978779", value.value()); } else if (value.type() == QCValueType.TUMOR_COVERAGE_60X) { assertEquals("0.950264", value.value()); } } }
@Test public void extractDataFromMetricsWorksForSingleSample() throws IOException { MetricsChecker checker = new MetricsChecker("reference", null, METRICS_DIRECTORY); List<QCValue> values = checker.run(); assertEquals(2, values.size()); for (QCValue value : values) { if (value.type() == QCValueType.REF_COVERAGE_10X) { assertEquals("0.98261", value.value()); } else if (value.type() == QCValueType.REF_COVERAGE_20X) { assertEquals("0.980701", value.value()); } } }
@Test(expected = IOException.class) public void malformedYieldsIOException() throws IOException { MetricsChecker checker = new MetricsChecker("malformed", null, METRICS_DIRECTORY); checker.run(); }
@Test(expected = IOException.class) public void missingYieldsIOException() throws IOException { MetricsChecker checker = new MetricsChecker("missing", null, METRICS_DIRECTORY); checker.run(); }