OWLGraphWrapper extends OWLGraphWrapperEdgesAdvanced { public List<ISynonym> getOBOSynonyms(OWLObject c) { OWLEntity e; if (c instanceof OWLEntity) { e = (OWLEntity) c; } else { return null; } List<ISynonym> synonyms = null; synonyms = merge(synonyms, getOBOSynonyms(e, Obo2OWLVocabulary.IRI_OIO_hasExactSynonym)); synonyms = merge(synonyms, getOBOSynonyms(e, Obo2OWLVocabulary.IRI_OIO_hasRelatedSynonym)); synonyms = merge(synonyms, getOBOSynonyms(e, Obo2OWLVocabulary.IRI_OIO_hasNarrowSynonym)); synonyms = merge(synonyms, getOBOSynonyms(e, Obo2OWLVocabulary.IRI_OIO_hasBroadSynonym)); return synonyms; } OWLGraphWrapper(OWLOntology ontology); @Deprecated  OWLGraphWrapper(OWLOntology ontology, boolean isMergeImportClosure);  OWLGraphWrapper(String iri); @Deprecated void useImportClosureForQueries(); @Deprecated void addQueryOntology(OWLOntology extOnt); @Deprecated OWLOntology getOntology(); @Deprecated void setOntology(OWLOntology ontology); @Deprecated String[] getSynonymStrings(OWLObject c); List<ISynonym> getOBOSynonyms(OWLObject c); List<String> getOBOSynonymStrings(OWLObject c, List<String> sargs); static final String DEFAULT_IRI_PREFIX; }
@Test public void testGetOBOSynonymsWithXrefs() throws Exception{ OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("caro.obo"); OWLObject cls = wrapper.getOWLClass(OWLGraphWrapper.DEFAULT_IRI_PREFIX + "CARO_0001001"); List<ISynonym> synonyms = wrapper.getOBOSynonyms(cls); assertEquals(1, synonyms.size()); ISynonym synonym = synonyms.get(0); assertEquals("nerve fiber bundle", synonym.getLabel()); assertEquals("EXACT", synonym.getScope()); assertNull(synonym.getCategory()); assertNotNull(synonym.getXrefs()); assertEquals(1, synonym.getXrefs().size()); assertEquals("FBC:DOS", synonym.getXrefs().iterator().next()); }
@Test public void testGetOBOSynonymsMultipleScopes() throws Exception{ OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("ncbi_taxon_slim.obo"); OWLObject cls = wrapper.getOWLClass(OWLGraphWrapper.DEFAULT_IRI_PREFIX + "NCBITaxon_10088"); List<ISynonym> synonyms = wrapper.getOBOSynonyms(cls); assertEquals(2, synonyms.size()); ISynonym synonym1 = synonyms.get(0); ISynonym synonym2 = synonyms.get(1); if (synonym1.getLabel().equals("mice")) { ISynonym temp = synonym1; synonym1 = synonym2; synonym2 = temp; } assertEquals("Nannomys", synonym1.getLabel()); assertEquals("RELATED", synonym1.getScope()); assertNull(synonym1.getCategory()); assertNull(synonym1.getXrefs()); assertEquals("mice", synonym2.getLabel()); assertEquals("EXACT", synonym2.getScope()); assertNull(synonym2.getCategory()); assertNull(synonym2.getXrefs()); }
@Test public void testGetOBOSynonymsCategory() throws Exception { OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("synonym_category_test.obo"); OWLClass cls1 = wrapper.getOWLClassByIdentifier("TEST:0001"); List<ISynonym> synonyms1 = wrapper.getOBOSynonyms(cls1); assertEquals(2, synonyms1.size()); ISynonym syn11 = synonyms1.get(0); assertEquals("Japanese Synonym", syn11.getLabel()); assertEquals("Japanese", syn11.getCategory()); assertEquals("FOO:bar", syn11.getXrefs().iterator().next()); assertEquals(OboFormatTag.TAG_EXACT.getTag(), syn11.getScope()); ISynonym syn12 = synonyms1.get(1); assertEquals("simple 1", syn12.getLabel()); assertNull(syn12.getCategory()); assertEquals("FOO:bar", syn12.getXrefs().iterator().next()); assertEquals(OboFormatTag.TAG_EXACT.getTag(), syn12.getScope()); OWLClass cls2 = wrapper.getOWLClassByIdentifier("TEST:0002"); List<ISynonym> synonyms2 = wrapper.getOBOSynonyms(cls2); assertEquals(2, synonyms2.size()); ISynonym syn21 = synonyms2.get(0); assertEquals("Spanish Synonym", syn21.getLabel()); assertEquals("Spanish", syn21.getCategory()); assertNull(syn21.getXrefs()); assertEquals(OboFormatTag.TAG_EXACT.getTag(), syn21.getScope()); ISynonym syn22 = synonyms2.get(1); assertEquals("simple 2", syn22.getLabel()); assertNull(syn22.getCategory()); assertNull(syn22.getXrefs()); assertEquals(OboFormatTag.TAG_EXACT.getTag(), syn22.getScope()); }