CancerTypeAnalyzer { public boolean isCancerTypeMatch(@NotNull String knowledgebaseCancerType, @Nullable String primaryTumorLocation) { if (primaryTumorLocation == null) { return false; } Set<String> doidsForPrimaryTumorLocation = primaryTumorToDOIDMapper.findDoids(primaryTumorLocation); if (doidsForPrimaryTumorLocation == null) { return false; } Set<String> doidsForCancerType = cancerTypeToDOIDMapper.findDoids(knowledgebaseCancerType); return doidsForCancerType != null && !Collections.disjoint(doidsForPrimaryTumorLocation, doidsForCancerType); } @VisibleForTesting  CancerTypeAnalyzer(@NotNull final CancerTypeToDOIDMapper cancerTypeToDOIDMapper,
            @NotNull final PrimaryTumorToDOIDMapper primaryTumorToDOIDMapper); @NotNull static CancerTypeAnalyzer createFromKnowledgeBase(@NotNull String knowledgebaseCancerTypesTsv); boolean isCancerTypeMatch(@NotNull String knowledgebaseCancerType, @Nullable String primaryTumorLocation);  }
@Test public void canMatchDOIDToPrimaryTumorLocation() { Map<String, Set<String>> cancerTypeMappings = Maps.newHashMap(); cancerTypeMappings.put("NSCLC", Sets.newHashSet("0010")); Map<String, Set<String>> primaryTumorLocationMappings = Maps.newHashMap(); primaryTumorLocationMappings.put("Lung", Sets.newHashSet("0010")); CancerTypeAnalyzer cancerTypeAnalyzer = new CancerTypeAnalyzer(new CancerTypeToDOIDMapper(cancerTypeMappings), new PrimaryTumorToDOIDMapper(primaryTumorLocationMappings)); assertFalse(cancerTypeAnalyzer.isCancerTypeMatch("Skin", "Lung")); assertFalse(cancerTypeAnalyzer.isCancerTypeMatch("Lung", "Lung")); assertTrue(cancerTypeAnalyzer.isCancerTypeMatch("NSCLC", "Lung")); }