GeneSetPropertyService { public Map<BioentityPropertyName, Set<String>> propertyValuesByType(String identifier, boolean isPlant) { identifier = identifier.toUpperCase(); if (GeneSetUtil.matchesReactomeID(identifier)) { if (isPlant) { return propertyValuesByType( PATHWAYID, identifier, reactomeClient.getPlantPathwayName(identifier).orElse("")); } else { return propertyValuesByType( PATHWAYID, identifier, reactomeClient.getPathwayName(identifier).orElse("")); } } else if (GeneSetUtil.matchesGeneOntologyAccession(identifier)) { return propertyValuesByType( GO, identifier, goPoTermTrader.get(identifier).map(OntologyTerm::name).orElse("")); } else if (GeneSetUtil.matchesPlantOntologyAccession(identifier)) { return propertyValuesByType( PO, identifier, goPoTermTrader.get(identifier).map(OntologyTerm::name).orElse("")); } else if (GeneSetUtil.matchesInterProAccession(identifier)) { return propertyValuesByType( INTERPRO, identifier, interProTermTrader.get(identifier).map(OntologyTerm::name).orElse("")); } else { return ImmutableMap.of(); } } @Inject  GeneSetPropertyService(GoPoTrader goPoTermTrader,
                                  InterProTrader interProTermTrader,
                                  ReactomeClient reactomeClient); Map<BioentityPropertyName, Set<String>> propertyValuesByType(String identifier, boolean isPlant); static final List<BioentityPropertyName> ALL; }
@Test public void propertyValuesByTypeReactome() { assertThat( subject.propertyValuesByType("R-HSA-0000000", false), hasEntry(is(BioentityPropertyName.PATHWAYID), isA(Set.class))); verify(reactomeClientMock).getPathwayName(anyString()); verifyZeroInteractions(goPoTermTraderMock, interProTermTraderMock); }
@Test public void propertyValuesByTypePlantReactome() { assertThat( subject.propertyValuesByType("R-GMA-2744341", true), hasEntry(is(BioentityPropertyName.PATHWAYID), isA(Set.class))); verify(reactomeClientMock).getPlantPathwayName(anyString()); verifyZeroInteractions(goPoTermTraderMock, interProTermTraderMock); }
@Test public void propertyValuesByTypeGeneOntology() { assertThat( subject.propertyValuesByType("GO:0000000", false), hasEntry(is(BioentityPropertyName.GO), isA(Set.class))); verify(goPoTermTraderMock).get("GO:0000000"); verifyZeroInteractions(reactomeClientMock, interProTermTraderMock); }
@Test public void propertyValuesByTypePlantOntology() { assertThat( subject.propertyValuesByType("PO:0000000", false), hasEntry(is(BioentityPropertyName.PO), isA(Set.class))); verify(goPoTermTraderMock).get("PO:0000000"); verifyZeroInteractions(reactomeClientMock, interProTermTraderMock); }
@Test public void propertyValuesByTypeInterPro() { assertThat( subject.propertyValuesByType("IPR0000000", false), hasEntry(is(BioentityPropertyName.INTERPRO), isA(Set.class))); verify(interProTermTraderMock).get("IPR0000000"); verifyZeroInteractions(reactomeClientMock, goPoTermTraderMock); }
@Test public void typeIsCaseInsensitive() { assertThat( subject.propertyValuesByType("r-hsa-0000000", false), hasEntry(is(BioentityPropertyName.PATHWAYID), isA(Set.class))); assertThat( subject.propertyValuesByType("go:0000000", false), hasEntry(is(BioentityPropertyName.GO), isA(Set.class))); assertThat( subject.propertyValuesByType("po:0000000", false), hasEntry(is(BioentityPropertyName.PO), isA(Set.class))); assertThat( subject.propertyValuesByType("ipr0000000", false), hasEntry(is(BioentityPropertyName.INTERPRO), isA(Set.class))); }
@Test public void propertyValuesByTypeUnknown() { Map<BioentityPropertyName, Set<String>> emptyMapOfPropertyValuesByType = ImmutableMap.of(); assertThat(subject.propertyValuesByType("foobar", false), is(emptyMapOfPropertyValuesByType)); verifyZeroInteractions(reactomeClientMock, goPoTermTraderMock, interProTermTraderMock); }