InheritanceFilter implements GeneFilter { @Override public FilterResult runFilter(Gene gene) { if (compatibleModes.isEmpty() || compatibleModes.equals(JUST_ANY)) { return NOT_RUN; } addFilterResultToVariants(gene.getVariantEvaluations()); for (ModeOfInheritance modeOfInheritance : compatibleModes) { if (gene.isCompatibleWith(modeOfInheritance)) { return PASS; } } return FAIL; } InheritanceFilter(ModeOfInheritance compatibleMode);  InheritanceFilter(ModeOfInheritance... compatibleModes);  InheritanceFilter(Set<ModeOfInheritance> compatibleModes); Set<ModeOfInheritance> getCompatibleModes(); @Override FilterResult runFilter(Gene gene); @Override FilterType getFilterType(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final Set<ModeOfInheritance> JUST_ANY; }
@Test public void testGeneNotPassedOrFailedInheritanceFilterWhenInheritanceModeIsUnspecified() { InheritanceFilter instance = new InheritanceFilter(EnumSet.of(ModeOfInheritance.ANY)); FilterResult filterResult = instance.runFilter(compatibleWithAutosomalRecessive); assertThat(filterResult.wasRun(), is(false)); }
@Test public void testGeneNotPassedOrFailedInheritanceFilterWhenInheritanceModeIsEmpty() { InheritanceFilter instance = new InheritanceFilter(EnumSet.noneOf(ModeOfInheritance.class)); FilterResult filterResult = instance.runFilter(compatibleWithAutosomalRecessive); assertThat(filterResult.wasRun(), is(false)); }
@Test public void testFilterGenePasses() { InheritanceFilter dominantFilter = new InheritanceFilter(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); FilterResult filterResult = dominantFilter.runFilter(compatibleWithAutosomalDominant); FilterTestHelper.assertPassed(filterResult); }
@Test public void testFilterGenePassesAllInheritanceModes() { InheritanceFilter inheritanceFilter = new InheritanceFilter(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); FilterResult filterResult = inheritanceFilter.runFilter(compatibleWithAutosomalDominantAndRecessive); FilterTestHelper.assertPassed(filterResult); }
@Test public void testFilterGenePassesOneOfTheInheritanceModes() { InheritanceFilter inheritanceFilter = new InheritanceFilter(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); FilterResult filterResult = inheritanceFilter.runFilter(compatibleWithAutosomalDominant); FilterTestHelper.assertPassed(filterResult); }
@Test public void testFilterGeneFailsTheInheritanceModes() { InheritanceFilter recessiveFilter = new InheritanceFilter(EnumSet.of(ModeOfInheritance.X_RECESSIVE, ModeOfInheritance.AUTOSOMAL_RECESSIVE)); FilterResult filterResult = recessiveFilter.runFilter(compatibleWithAutosomalDominant); FilterTestHelper.assertFailed(filterResult); }
@Test public void testFilterGeneFails() { InheritanceFilter dominantFilter = new InheritanceFilter(EnumSet.of(ModeOfInheritance.AUTOSOMAL_DOMINANT)); FilterResult filterResult = dominantFilter.runFilter(compatibleWithAutosomalRecessive); FilterTestHelper.assertFailed(filterResult); }