FrequencyFilter implements VariantFilter { @Override public FilterResult runFilter(VariantEvaluation variantEvaluation) { if (variantEvaluation.isWhiteListed()) { return PASS; } FrequencyData frequencyData = variantEvaluation.getFrequencyData(); if (frequencyData.hasFrequencyOverPercentageValue(maxFreq)) { return FAIL; } return PASS; } FrequencyFilter(float maxFreq); float getMaxFreq(); @Override FilterType getFilterType(); @Override FilterResult runFilter(VariantEvaluation variantEvaluation); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testFilterPassesVariantEvaluationWithNoFrequencyData() { VariantEvaluation variantEvaluation = makeVariantEvaluation(); assertThat(instance.runFilter(variantEvaluation), equalTo(PASS_FREQUENCY_FILTER_RESULT)); }
@Test public void testFilterPassesVariantEvaluationWithFrequencyUnderThreshold() { VariantEvaluation variantEvaluation = makeVariantEvaluation(passFrequency(FrequencySource.ESP_ALL)); assertThat(instance.runFilter(variantEvaluation), equalTo(PASS_FREQUENCY_FILTER_RESULT)); }
@Test public void testFilterPassesVariantEvaluationWithAllFrequenciesUnderThreshold() { VariantEvaluation variantEvaluation = makeVariantEvaluation( passFrequency(FrequencySource.ESP_ALL), passFrequency(FrequencySource.THOUSAND_GENOMES) ); assertThat(instance.runFilter(variantEvaluation), equalTo(PASS_FREQUENCY_FILTER_RESULT)); }
@Test public void testFilterFailsVariantEvaluationWithFrequencyOverThreshold() { VariantEvaluation variantEvaluation = makeVariantEvaluation(failFrequency(FrequencySource.ESP_ALL)); assertThat(instance.runFilter(variantEvaluation), equalTo(FAIL_FREQUENCY_FILTER_RESULT)); }
@Test public void testFilterPassesVariantEvaluationWithFrequencyOverThresholdWhenVariantIsWhiteListed() { VariantEvaluation variantEvaluation = makeVariantEvaluation(failFrequency(FrequencySource.ESP_ALL)); variantEvaluation.setWhiteListed(true); assertThat(instance.runFilter(variantEvaluation), equalTo(PASS_FREQUENCY_FILTER_RESULT)); }
@Test public void testFilterFailsVariantEvaluationWithAtLeastFrequencyOverThreshold() { VariantEvaluation variantEvaluation = makeVariantEvaluation( passFrequency(FrequencySource.THOUSAND_GENOMES), failFrequency(FrequencySource.ESP_ALL) ); assertThat(instance.runFilter(variantEvaluation), equalTo(FAIL_FREQUENCY_FILTER_RESULT)); }