SimpleVariantFilterRunner implements VariantFilterRunner { @Override public List<VariantEvaluation> run(VariantFilter filter, List<VariantEvaluation> variantEvaluations) { for (VariantEvaluation variantEvaluation : variantEvaluations) { run(filter, variantEvaluation); } return variantEvaluations; }  @Override List<VariantEvaluation> run(VariantFilter filter, List<VariantEvaluation> variantEvaluations);  }
@Test public void testUseNonDestructiveFilteringUsingInterfaceRunReturnsAllVariantEvaluations() { List<VariantFilter> filters = new ArrayList<>(); filters.add(targetFilter); filters.add(qualityFilter); filters.add(frequencyFilter); filters.forEach(filter -> instance.run(filter, variantEvaluations)); printVariantFilterStatus("passesAllFilters", passesAllFilters); assertThat(passesAllFilters.passedFilters(), is(true)); assertPassedFilters(passesAllFilters, VARIANT_EFFECT_FILTER, QUALITY_FILTER, FREQUENCY_FILTER); printVariantFilterStatus("failsAllFilters", failsAllFilters); assertThat(failsAllFilters.passedFilters(), is(false)); assertFailedFilters(failsAllFilters, VARIANT_EFFECT_FILTER, QUALITY_FILTER, FREQUENCY_FILTER); printVariantFilterStatus("passesQualityFrequencyFilter", passesQualityFrequencyFilter); assertThat(passesQualityFrequencyFilter.passedFilters(), is(false)); assertPassedFilters(passesQualityFrequencyFilter, QUALITY_FILTER, FREQUENCY_FILTER); assertFailedFilters(passesQualityFrequencyFilter, VARIANT_EFFECT_FILTER); printVariantFilterStatus("passesTargetQualityFilter", passesTargetQualityFilter); assertThat(passesTargetQualityFilter.passedFilters(), is(false)); assertPassedFilters(passesTargetQualityFilter, QUALITY_FILTER, VARIANT_EFFECT_FILTER); assertFailedFilters(passesTargetQualityFilter, FREQUENCY_FILTER); }
@Test public void testRunWithOneFilterReturnsAllVariants() { VariantFilter filterToPass = qualityFilter; List<VariantEvaluation> result = instance.run(filterToPass, variantEvaluations); assertThat(result, equalTo(variantEvaluations)); assertPassedFilterAndFailedAllOthers(passesAllFilters, filterToPass); assertPassedFilterAndFailedAllOthers(passesQualityFrequencyFilter, filterToPass); assertPassedFilterAndFailedAllOthers(passesTargetQualityFilter, filterToPass); assertFailsEverything(failsAllFilters); }
@Test public void testRunWithTwoFiltersInSuccessionReturnsAllVariants() { VariantFilter firstFilterToPass = qualityFilter; List<VariantEvaluation> result = instance.run(qualityFilter, variantEvaluations); assertThat(result, equalTo(variantEvaluations)); assertPassedFilterAndFailedAllOthers(passesAllFilters, firstFilterToPass); assertPassedFilterAndFailedAllOthers(passesQualityFrequencyFilter, firstFilterToPass); assertPassedFilterAndFailedAllOthers(passesTargetQualityFilter, firstFilterToPass); assertFailsEverything(failsAllFilters); VariantFilter secondFilterToPass = targetFilter; List<VariantEvaluation> secondResults = instance.run(secondFilterToPass, variantEvaluations); assertThat(secondResults, equalTo(variantEvaluations)); assertPassedFilters(passesAllFilters, firstFilterToPass.getFilterType(), secondFilterToPass.getFilterType()); System.out.println(passesAllFilters); assertPassedFilters(passesQualityFrequencyFilter, firstFilterToPass.getFilterType()); assertFailedFilters(passesQualityFrequencyFilter, secondFilterToPass.getFilterType()); System.out.println(passesQualityFrequencyFilter); assertPassedFilters(passesTargetQualityFilter, firstFilterToPass.getFilterType(), secondFilterToPass.getFilterType()); System.out.println(passesTargetQualityFilter); assertFailsEverything(failsAllFilters); System.out.println(failsAllFilters); }