Interface OntologyService
-
- All Known Implementing Classes:
AbstractBaseCodeOntologyService
,AbstractOntologyService
,AbstractOntologyService
,CellLineOntologyService
,CellTypeOntologyService
,ChebiOntologyService
,DiseaseOntologyService
,ExperimentalFactorOntologyService
,FMAOntologyService
,GenericOntologyService
,HumanDevelopmentOntologyService
,HumanPhenotypeOntologyService
,MammalianPhenotypeOntologyService
,MedicOntologyService
,MouseDevelopmentOntologyService
,NIFSTDOntologyService
,ObiService
,SequenceOntologyService
,UberonOntologyService
,UnitsOntologyService
public interface OntologyService
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
OntologyService.InferenceMode
static class
OntologyService.LanguageLevel
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
cancelInitializationThread()
Cancel a running initialization thread.default Collection<OntologySearchResult<OntologyIndividual>>
findIndividuals(String search, int maxResults)
Looks for any individuals that match the given search string.Collection<OntologySearchResult<OntologyIndividual>>
findIndividuals(String search, int maxResults, boolean keepObsoletes)
Looks for any individuals that match the given search string.default Collection<OntologySearchResult<OntologyResource>>
findResources(String searchString, int maxResults)
Looks for any resources (terms or individuals) that match the given search stringCollection<OntologySearchResult<OntologyResource>>
findResources(String search, int maxResults, boolean keepObsoletes)
Looks for any resources (terms or individuals) that match the given search stringdefault Collection<OntologySearchResult<OntologyTerm>>
findTerm(String search, int maxResults)
Looks for any terms that match the given search string.Collection<OntologySearchResult<OntologyTerm>>
findTerm(String search, int maxResults, boolean keepObsoletes)
Looks for any terms that match the given search string.OntologyTerm
findUsingAlternativeId(String alternativeId)
Find a term using an alternative ID.Set<String>
getAdditionalPropertyUris()
Obtain the URIs used as additional properties when inferring parents and children.Set<String>
getAllURIs()
Obtain all the resource URIs in this ontology.default Set<OntologyTerm>
getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties)
Obtain all the children of a given set of terms, excluding obsolete terms.Set<OntologyTerm>
getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
Obtain all the children of a given set of terms.String
getDescription()
Obtain a description of this ontology if available.Set<String>
getExcludedWordsFromStemming()
Obtain the words that should be excluded from stemming.OntologyService.InferenceMode
getInferenceMode()
Obtain the inference mode used for this ontology.OntologyService.LanguageLevel
getLanguageLevel()
Obtain the OWL language level supported by this ontology.String
getName()
Obtain the name of this ontology if available.default Set<OntologyTerm>
getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties)
Obtain all the parents of a given set of terms, excluding obsolete terms.Set<OntologyTerm>
getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
Obtain all the parents of a given set of terms.boolean
getProcessImports()
Check if this ontology will process imports.OntologyResource
getResource(String uri)
Looks through both Terms and Individuals for a OntologyResource that has a uri matching the uri given.OntologyTerm
getTerm(String uri)
Looks for a OntologyTerm that has the match in URI givenCollection<OntologyIndividual>
getTermIndividuals(String uri)
Obtain all the individuals for a given term URI.void
index(boolean force)
Index the ontology for performing full-text searches.void
initialize(boolean forceLoad, boolean forceIndexing)
Initialize this ontology service.void
initialize(InputStream stream, boolean forceIndexing)
Initialize this ontology service from a stream.boolean
isEnabled()
Check if this ontology is enabled.boolean
isInitializationThreadAlive()
Check if the initialization thread is alive.boolean
isInitializationThreadCancelled()
Check if the initialization thread is cancelled.boolean
isOntologyLoaded()
Used for determining if the Ontology has finished loading into memory.boolean
isSearchEnabled()
Check if this ontology has full-text search enabled.void
loadTermsInNameSpace(InputStream is, boolean forceIndex)
Deprecated.useinitialize(InputStream, boolean)
instead and possiblycancelInitializationThread()
prior to get any running initialization thread out of the wayvoid
setAdditionalPropertyUris(Set<String> additionalPropertyUris)
Set the URIs to be used as additional properties when inferring parents and children.void
setExcludedWordsFromStemming(Set<String> excludedWordsFromStemming)
Set words that should be excluded from stemming when searching.void
setInferenceMode(OntologyService.InferenceMode inferenceMode)
Set the inference mode used for this ontology.void
setLanguageLevel(OntologyService.LanguageLevel languageLevel)
Set the OWL language level supported by this ontology.void
setProcessImports(boolean processImports)
Allow of forbid this ontology to process imports.void
setSearchEnabled(boolean searchEnabled)
Enable or disable search for this ontology.void
startInitializationThread(boolean forceLoad, boolean forceIndexing)
Start the initialization thread.void
waitForInitializationThread()
Wait for the initialization thread to finish.
-
-
-
Method Detail
-
getDescription
@Nullable String getDescription()
Obtain a description of this ontology if available.
-
getProcessImports
boolean getProcessImports()
Check if this ontology will process imports.If disabled, ontologies imported by this ontology will not be loaded.
-
setProcessImports
void setProcessImports(boolean processImports)
Allow of forbid this ontology to process imports.Changes are applicable only if the service is re-initialized.
-
getLanguageLevel
OntologyService.LanguageLevel getLanguageLevel()
Obtain the OWL language level supported by this ontology.The default is to use
OntologyService.LanguageLevel.FULL
.
-
setLanguageLevel
void setLanguageLevel(OntologyService.LanguageLevel languageLevel)
Set the OWL language level supported by this ontology.Changes are applicable only if the service is re-initialized.
-
getInferenceMode
OntologyService.InferenceMode getInferenceMode()
Obtain the inference mode used for this ontology.The default is
OntologyService.InferenceMode.TRANSITIVE
.
-
setInferenceMode
void setInferenceMode(OntologyService.InferenceMode inferenceMode)
Set the inference mode used for this ontology.Changes are applicable only if the service is re-initialized.
-
isSearchEnabled
boolean isSearchEnabled()
Check if this ontology has full-text search enabled.This is necessary for finding term using full-text queries. If enabled, an index will be generated in during initialization by
initialize(boolean, boolean)
.Search is enabled by default.
-
setSearchEnabled
void setSearchEnabled(boolean searchEnabled)
Enable or disable search for this ontology.Changes are only applicable if the service is re-initialized.
-
getExcludedWordsFromStemming
Set<String> getExcludedWordsFromStemming()
Obtain the words that should be excluded from stemming.By default, all words are subject to stemming. The exact implementation of stemming depends on the actual search implementation.
-
setExcludedWordsFromStemming
void setExcludedWordsFromStemming(Set<String> excludedWordsFromStemming)
Set words that should be excluded from stemming when searching.
-
getAdditionalPropertyUris
Set<String> getAdditionalPropertyUris()
Obtain the URIs used as additional properties when inferring parents and children.The default is to use part of, proper part of and all of their sub-properties if inference is enabled.
-
setAdditionalPropertyUris
void setAdditionalPropertyUris(Set<String> additionalPropertyUris)
Set the URIs to be used as additional properties when inferring parents and children.Changes are applicable only if the service is re-initialized.
-
initialize
void initialize(boolean forceLoad, boolean forceIndexing)
Initialize this ontology service.- Parameters:
forceLoad
- Force loading of ontology, even if it is already loadedforceIndexing
- If forceLoad is also true, indexing will be performed. If you know the index is up-to-date, there's no need to do it again. Normally indexing is only done if there is no index, or if the ontology has changed since last loaded.
-
initialize
void initialize(InputStream stream, boolean forceIndexing)
Initialize this ontology service from a stream.Note that when this method of initialization is used, the ontology cache is not created on-disk.
-
findIndividuals
default Collection<OntologySearchResult<OntologyIndividual>> findIndividuals(String search, int maxResults) throws OntologySearchException
Looks for any individuals that match the given search string.Obsolete terms are filtered out.
- Throws:
OntologySearchException
-
findIndividuals
Collection<OntologySearchResult<OntologyIndividual>> findIndividuals(String search, int maxResults, boolean keepObsoletes) throws OntologySearchException
Looks for any individuals that match the given search string.- Parameters:
search
- search querykeepObsoletes
- retain obsolete terms- Throws:
OntologySearchException
-
findResources
default Collection<OntologySearchResult<OntologyResource>> findResources(String searchString, int maxResults) throws OntologySearchException
Looks for any resources (terms or individuals) that match the given search stringObsolete terms are filtered out.
- Returns:
- results, or an empty collection if the results are empty OR the ontology is not available to be searched.
- Throws:
OntologySearchException
-
findResources
Collection<OntologySearchResult<OntologyResource>> findResources(String search, int maxResults, boolean keepObsoletes) throws OntologySearchException
Looks for any resources (terms or individuals) that match the given search string- Parameters:
search
- search querykeepObsoletes
- retain obsolete terms- Throws:
OntologySearchException
-
findTerm
default Collection<OntologySearchResult<OntologyTerm>> findTerm(String search, int maxResults) throws OntologySearchException
Looks for any terms that match the given search string.Obsolete terms are filtered out.
- Throws:
OntologySearchException
-
findTerm
Collection<OntologySearchResult<OntologyTerm>> findTerm(String search, int maxResults, boolean keepObsoletes) throws OntologySearchException
Looks for any terms that match the given search string.- Parameters:
search
- search querykeepObsoletes
- retain obsolete terms- Throws:
OntologySearchException
-
findUsingAlternativeId
@Nullable OntologyTerm findUsingAlternativeId(String alternativeId)
Find a term using an alternative ID.
-
getResource
@Nullable OntologyResource getResource(String uri)
Looks through both Terms and Individuals for a OntologyResource that has a uri matching the uri given. If no OntologyTerm is found only then will ontologyIndividuals be searched. returns null if nothing is found.
-
getTerm
@Nullable OntologyTerm getTerm(String uri)
Looks for a OntologyTerm that has the match in URI given
-
getTermIndividuals
Collection<OntologyIndividual> getTermIndividuals(String uri)
Obtain all the individuals for a given term URI.
-
getParents
default Set<OntologyTerm> getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties)
Obtain all the parents of a given set of terms, excluding obsolete terms.
-
getParents
Set<OntologyTerm> getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
Obtain all the parents of a given set of terms.- Parameters:
terms
- set of terms whose parents are retrieveddirect
- only retain direct parentsincludeAdditionalProperties
- also include parents matched via additional propertieskeepObsoletes
- retain obsolete terms- Returns:
- a set of parent terms
-
getChildren
default Set<OntologyTerm> getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties)
Obtain all the children of a given set of terms, excluding obsolete terms.
-
getChildren
Set<OntologyTerm> getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, boolean keepObsoletes)
Obtain all the children of a given set of terms.- Parameters:
terms
- set of terms whose children are retrieveddirect
- only retain direct childrenincludeAdditionalProperties
- also include children matched via additional propertieskeepObsoletes
- retain obsolete terms- Returns:
- a set of child terms
-
isEnabled
boolean isEnabled()
Check if this ontology is enabled.
-
isOntologyLoaded
boolean isOntologyLoaded()
Used for determining if the Ontology has finished loading into memory. Although calls like getParents, getChildren will still work (its much faster once the ontologies have been preloaded into memory.)
-
startInitializationThread
void startInitializationThread(boolean forceLoad, boolean forceIndexing)
Start the initialization thread.If the initialization thread is already running, this method does nothing. If the initialization thread previously completed, the ontology will be reinitialized.
- Parameters:
forceLoad
- Force loading of ontology, even if it is already loadedforceIndexing
- If forceLoad is also true, indexing will be performed. If you know the index is up to date, there's no need to do it again. Normally indexing is only done if there is no index, or if the ontology has changed since last loaded.
-
isInitializationThreadAlive
boolean isInitializationThreadAlive()
Check if the initialization thread is alive.
-
isInitializationThreadCancelled
boolean isInitializationThreadCancelled()
Check if the initialization thread is cancelled.
-
cancelInitializationThread
void cancelInitializationThread()
Cancel a running initialization thread.
-
waitForInitializationThread
void waitForInitializationThread() throws InterruptedException
Wait for the initialization thread to finish.- Throws:
InterruptedException
-
index
void index(boolean force)
Index the ontology for performing full-text searches.- Parameters:
force
- if true, perform indexing even if an index already exists- See Also:
#findIndividuals(String)
,#findTerm(String)
,#findResources(String)
-
loadTermsInNameSpace
@Deprecated void loadTermsInNameSpace(InputStream is, boolean forceIndex)
Deprecated.useinitialize(InputStream, boolean)
instead and possiblycancelInitializationThread()
prior to get any running initialization thread out of the wayFor testing! Overrides normal way of loading the ontology. This does not index the ontology unless 'force' is true (if there is an existing index, it will be used)- Parameters:
is
- input stream from which the ontology model is loadedforceIndex
- initialize the index. Otherwise it will only be initialized if it doesn't exist.
-
-