VariantDataServiceImpl implements VariantDataService { @Override public PathogenicityData getVariantPathogenicityData(Variant variant, Set<PathogenicitySource> pathogenicitySources) { PathogenicityData defaultPathogenicityData = defaultPathogenicityDao.getPathogenicityData(variant); if (pathogenicitySources.isEmpty()) { return PathogenicityData.of(defaultPathogenicityData.getClinVarData()); } List<PathogenicityScore> allPathScores = new ArrayList<>(); if (variant.getVariantEffect() != VariantEffect.SYNONYMOUS_VARIANT) { addAllWantedScores(pathogenicitySources, defaultPathogenicityData, allPathScores); } List<PathogenicityData> optionalPathData = getOptionalPathogenicityData(variant, pathogenicitySources); for (PathogenicityData pathogenicityData : optionalPathData) { allPathScores.addAll(pathogenicityData.getPredictedPathogenicityScores()); } return PathogenicityData.of(defaultPathogenicityData.getClinVarData(), allPathScores); } private  VariantDataServiceImpl(Builder builder); @Override boolean variantIsWhiteListed(Variant variant); @Override FrequencyData getVariantFrequencyData(Variant variant, Set<FrequencySource> frequencySources); @Override PathogenicityData getVariantPathogenicityData(Variant variant, Set<PathogenicitySource> pathogenicitySources); static Builder builder();  }
@Test public void serviceReturnsPathogenicityDataForVariant() { PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.POLYPHEN, PathogenicitySource.MUTATION_TASTER, PathogenicitySource.SIFT)); assertThat(result, equalTo(PATH_DATA)); }
@Test public void serviceReturnsClinVarDataEvenWhenNoSourcesAreDefined() { PathogenicityData result = instance.getVariantPathogenicityData(variant, Collections.emptySet()); assertThat(result, equalTo(PathogenicityData.of(PATH_CLINVAR_DATA))); }
@Test public void serviceReturnsSpecifiedPathogenicityDataForMissenseVariant() { variant = buildVariantOfType(VariantEffect.MISSENSE_VARIANT); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.POLYPHEN)); assertThat(result, equalTo(PathogenicityData.of(PATH_CLINVAR_DATA, PolyPhenScore.of(1f)))); }
@Test public void serviceReturnsCaddDataForMissenseVariant() { variant = buildVariantOfType(VariantEffect.MISSENSE_VARIANT); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.CADD)); assertThat(result, equalTo(PathogenicityData.of(PATH_CLINVAR_DATA, CADD_DATA.getPredictedScore(PathogenicitySource.CADD)))); }
@Test public void serviceReturnsCaddAndStandardMissenseDescriptorDataForMissenseVariant() { variant = buildVariantOfType(VariantEffect.MISSENSE_VARIANT); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.CADD, PathogenicitySource.POLYPHEN)); assertThat(result, equalTo(PathogenicityData.of(PATH_CLINVAR_DATA, PolyPhenScore.of(1f), CaddScore.of(15f)))); }
@Test public void serviceReturnsSpecifiedPathogenicityDataForKnownNonCodingVariant() { variant = buildVariantOfType(VariantEffect.REGULATORY_REGION_VARIANT); PathogenicityData expectedNcdsData = PathogenicityData.of(PATH_CLINVAR_DATA, RemmScore.of(1f)); Mockito.when(mockRemmDao.getPathogenicityData(variant)).thenReturn(expectedNcdsData); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.REMM)); assertThat(result, equalTo(expectedNcdsData)); }
@Test public void pathogenicityDataForKnownNonCodingVariantShouldContainClinVarData() { variant = buildVariantOfType(VariantEffect.REGULATORY_REGION_VARIANT); PathogenicityData expectedPathData = PathogenicityData.of(PATH_CLINVAR_DATA); Mockito.when(mockRemmDao.getPathogenicityData(variant)).thenReturn(expectedPathData); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.REMM)); assertThat(result, equalTo(expectedPathData)); }
@Test public void serviceReturnsSpecifiedPathogenicityDataForNonCodingNonRegulatoryVariant() { variant = buildVariantOfType(VariantEffect.SPLICE_REGION_VARIANT); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.REMM)); assertThat(result, equalTo(PathogenicityData.of(PATH_CLINVAR_DATA))); }
@Test public void serviceReturnsCaddAndNonCodingScoreForKnownNonCodingVariant() { variant = buildVariantOfType(VariantEffect.REGULATORY_REGION_VARIANT); PathogenicityData expectedNcdsData = PathogenicityData.of(PATH_CLINVAR_DATA, CaddScore.of(15f), RemmScore.of(1f)); Mockito.when(mockRemmDao.getPathogenicityData(variant)).thenReturn(expectedNcdsData); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.CADD, PathogenicitySource.REMM)); assertThat(result, equalTo(expectedNcdsData)); }
@Test public void serviceQueryForSynonymousVariantReturnsEmptyPathogenicityData() { variant = buildVariantOfType(VariantEffect.SYNONYMOUS_VARIANT); Mockito.when(defaultPathogenicityDao.getPathogenicityData(variant)).thenReturn(PathogenicityData.of(MutationTasterScore.of(1f))); PathogenicityData result = instance.getVariantPathogenicityData(variant, EnumSet.of(PathogenicitySource.MUTATION_TASTER)); assertThat(result, equalTo(PathogenicityData.empty())); }