FilterReportFactory { protected FilterReport makeFilterReport(Filter filter, AnalysisResults analysisResults) { FilterType filterType = filter.getFilterType(); Filter baseFilter = unWrapVariantFilterDataProvider(filter); switch (filterType) { case VARIANT_EFFECT_FILTER: return makeTargetFilterReport((VariantEffectFilter) baseFilter, analysisResults.getVariantEvaluations()); case KNOWN_VARIANT_FILTER: return makeKnownVariantFilterReport((KnownVariantFilter) baseFilter, analysisResults.getVariantEvaluations()); case FREQUENCY_FILTER: return makeFrequencyFilterReport((FrequencyFilter) baseFilter, analysisResults.getVariantEvaluations()); case QUALITY_FILTER: return makeQualityFilterReport((QualityFilter) baseFilter, analysisResults.getVariantEvaluations()); case PATHOGENICITY_FILTER: return makePathogenicityFilterReport((PathogenicityFilter) baseFilter, analysisResults.getVariantEvaluations()); case INTERVAL_FILTER: return makeIntervalFilterReport((IntervalFilter) baseFilter, analysisResults.getVariantEvaluations()); case INHERITANCE_FILTER: return makeInheritanceFilterReport((InheritanceFilter) baseFilter, analysisResults.getGenes()); case PRIORITY_SCORE_FILTER: return makePriorityScoreFilterReport((PriorityScoreFilter) baseFilter, analysisResults.getGenes()); default: return makeVariantFilterReport(filter, analysisResults.getVariantEvaluations()); } } FilterReportFactory(); List<FilterReport> makeFilterReports(Analysis analysis, AnalysisResults analysisResults);  }
@Test public void testMakeDefaultGeneFilterReportContainsCorrectNumberOfPassedAndFailedGenes() { Filter filter = new InheritanceFilter(ModeOfInheritance.AUTOSOMAL_RECESSIVE); FilterType filterType = filter.getFilterType(); genes.add(makePassedGene(filterType)); genes.add(makeFailedGene(filterType)); FilterReport report = instance.makeFilterReport(filter, analysisResults); assertThat(report.getPassed(), equalTo(1)); assertThat(report.getFailed(), equalTo(1)); }
@Test public void testMakeFrequencyFilterReportCanCopeWithNullFrequencyData() { Filter filter = new FrequencyFilter(0.1f); FilterType filterType = filter.getFilterType(); VariantEvaluation variantEvalWithNullFrequencyData = makeFailedVariant(filterType); variantEvalWithNullFrequencyData.setFrequencyData(null); variantEvaluations.add(variantEvalWithNullFrequencyData); FilterReport result = instance.makeFilterReport(filter, analysisResults); assertThat(result, notNullValue()); }
@Test public void testMakeKnownVariantFilterReportProducesCorrectStatistics() { Filter filter = new KnownVariantFilter(); FilterType filterType = filter.getFilterType(); VariantEvaluation completelyNovelVariantEval = makePassedVariant(filterType); completelyNovelVariantEval.setFrequencyData(FrequencyData.empty()); variantEvaluations.add(completelyNovelVariantEval); VariantEvaluation mostCommonVariantEvalInTheWorld = makeFailedVariant(filterType); mostCommonVariantEvalInTheWorld.setFrequencyData( FrequencyData.of(RsId.of(123456), Frequency.of(FrequencySource.THOUSAND_GENOMES, 100f), Frequency.of(FrequencySource.ESP_ALL, 100f), Frequency.of(FrequencySource.EXAC_OTHER, 100f) )); variantEvaluations.add(mostCommonVariantEvalInTheWorld); List<String> messages = new ArrayList<>(); messages.add("Removed 1 variants with no RSID or frequency data (50.0%)"); messages.add("dbSNP \"rs\" id available for 1 variants (50.0%)"); messages.add("Data available in dbSNP (for 1000 Genomes Phase I) for 1 variants (50.0%)"); messages.add("Data available in Exome Server Project for 1 variants (50.0%)"); messages.add("Data available from ExAC Project for 1 variants (50.0%)"); FilterReport report = new FilterReport(filter.getFilterType(), 1, 1, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); System.out.println(result); assertThat(result, equalTo(report)); }
@Test public void testMakePathogenicityFilterReportWhenRemovePathFilterCutOffIsTrue() { Filter filter = new PathogenicityFilter(true); FilterType filterType = FilterType.PATHOGENICITY_FILTER; ImmutableList<String> messages = ImmutableList.of("Retained all non-pathogenic variants of all types. Scoring was applied, but the filter passed all variants."); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); assertThat(result, equalTo(report)); }
@Test public void testMakePathogenicityFilterReportWhenRemovePathFilterCutOffIsNotSpecified() { Filter filter = new PathogenicityFilter(false); FilterType filterType = FilterType.PATHOGENICITY_FILTER; ImmutableList<String> messages = ImmutableList.of("Retained all non-pathogenic missense variants"); FilterReport report = new FilterReport(filterType, 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); assertThat(result, equalTo(report)); }
@Test public void testMakeIntervalFilterReportLotsOfIntervals() { List<ChromosomalRegion> intervals = new ArrayList<>(); intervals.add(new GeneticInterval(1, 2, 3)); intervals.add(new GeneticInterval(2, 2, 3)); intervals.add(new GeneticInterval(3, 2, 3)); intervals.add(new GeneticInterval(4, 2, 3)); intervals.add(new GeneticInterval(5, 2, 3)); intervals.add(new GeneticInterval(6, 2, 3)); intervals.add(new GeneticInterval(7, 2, 3)); Filter filter = new IntervalFilter(intervals); ImmutableList<String> messages = ImmutableList.of( "Restricted variants to intervals:", "1:2-3", "2:2-3", "3:2-3", "...", "7:2-3" ); FilterReport expected = new FilterReport(filter.getFilterType(), 0, 0, messages); FilterReport result = instance.makeFilterReport(filter, analysisResults); assertThat(result, equalTo(expected)); }