Package ubic.gemma.core.ontology
Class OntologyServiceImpl
- java.lang.Object
-
- ubic.gemma.core.ontology.OntologyServiceImpl
-
- All Implemented Interfaces:
InitializingBean
,OntologyService
@Service public class OntologyServiceImpl extends Object implements OntologyService, InitializingBean
Has a static method for finding out which ontologies are loaded into the system and a general purpose find method that delegates to the many ontology services. NOTE: Logging messages from this service are important for tracking changes to annotations.- Author:
- pavlidis
-
-
Constructor Summary
Constructors Constructor Description OntologyServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Collection<CharacteristicValueObject>
findExperimentsCharacteristicTags(String searchQuery, int maxResults, boolean useNeuroCartaOntology, long timeout, TimeUnit timeUnit)
Using the ontology and values in the database, for a search searchQuery given by the client give an ordered list of possible choicesMap<OntologyTerm,Long>
findObsoleteTermUsage(long timeout, TimeUnit timeUnit)
Locates usages of obsolete terms in Characteristics, ignoring Gene Ontology annotations.Collection<OntologySearchResult<OntologyTerm>>
findTerms(String search, int maxResults, long timeout, TimeUnit timeUnit)
Given a search string will look through the loaded ontologies for terms that match the search term.Collection<CharacteristicValueObject>
findTermsInexact(String queryString, int maxResults, Taxon taxon, long timeout, TimeUnit timeUnit)
Given a search string will first look through the characteristic database for any entries that have a match.Map<String,OntologyTerm>
fixOntologyTermLabels(boolean dryRun, long timeout, TimeUnit timeUnit)
Check all system uses of ontology terms for the correct label and fix any mismatches based on the ontology OWL files.Set<OntologyTerm>
getCategoryTerms()
Obtain terms which are allowed for use in the category of aCharacteristic
.Set<OntologyTerm>
getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, long timeout, TimeUnit timeUnit)
Obtain the children of a collection of terms.String
getDefinition(String uri, long timeout, TimeUnit timeUnit)
Obtain a definition for the given URI.Set<OntologyTerm>
getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, long timeout, TimeUnit timeUnit)
Obtain the parents of a collection of terms.Set<OntologyProperty>
getRelationTerms()
Obtain terms allowed for the predicate (relationship) in aStatement
.OntologyTerm
getTerm(String uri, long timeout, TimeUnit timeUnit)
Obtain a term for the given URI.Set<OntologyTerm>
getTerms(Collection<String> uris, long timeout, TimeUnit timeUnit)
Return all the terms matching the given URIs.void
reindexAllOntologies()
Recreate the search indices, for ontologies that are loaded.void
reinitializeAndReindexAllOntologies()
Reinitialize (and reindex) all the ontologies "from scratch".
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
findExperimentsCharacteristicTags
public Collection<CharacteristicValueObject> findExperimentsCharacteristicTags(String searchQuery, int maxResults, boolean useNeuroCartaOntology, long timeout, TimeUnit timeUnit) throws SearchException
Using the ontology and values in the database, for a search searchQuery given by the client give an ordered list of possible choices- Specified by:
findExperimentsCharacteristicTags
in interfaceOntologyService
- Parameters:
searchQuery
- search queryuseNeuroCartaOntology
- use neurocarta ontology- Returns:
- characteristic vos
- Throws:
SearchTimeoutException
- if the search times outSearchException
-
findTerms
public Collection<OntologySearchResult<OntologyTerm>> findTerms(String search, int maxResults, long timeout, TimeUnit timeUnit) throws SearchException
Description copied from interface:OntologyService
Given a search string will look through the loaded ontologies for terms that match the search term. If the query looks like a URI, it just retrieves the term. For other queries, this a lucene backed search, is inexact and for general terms can return a lot of results.- Specified by:
findTerms
in interfaceOntologyService
- Parameters:
search
- search query- Returns:
- returns a collection of ontologyTerm's
- Throws:
SearchTimeoutException
- if the search times outSearchException
-
findTermsInexact
public Collection<CharacteristicValueObject> findTermsInexact(String queryString, int maxResults, @Nullable Taxon taxon, long timeout, TimeUnit timeUnit) throws SearchException
Description copied from interface:OntologyService
Given a search string will first look through the characteristic database for any entries that have a match. If a ontologyTermURI is given it will add all the individuals from that URI that match the search term criteria to the returned list also.- Specified by:
findTermsInexact
in interfaceOntologyService
- Parameters:
queryString
- query stringtaxon
- Only used if we're going to search for genes or taxon is otherwise relevant; if null, restriction is not used.- Returns:
- characteristic vos
- Throws:
SearchTimeoutException
- if the search times outSearchException
-
getParents
public Set<OntologyTerm> getParents(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Obtain the parents of a collection of terms.- Specified by:
getParents
in interfaceOntologyService
- Throws:
TimeoutException
- if the timeout is exceeded- See Also:
OntologyTerm.getParents(boolean, boolean)
-
getChildren
public Set<OntologyTerm> getChildren(Collection<OntologyTerm> terms, boolean direct, boolean includeAdditionalProperties, long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Obtain the children of a collection of terms.- Specified by:
getChildren
in interfaceOntologyService
- Throws:
TimeoutException
- if the timeout is exceeded- See Also:
OntologyTerm.getChildren(boolean, boolean)
-
getCategoryTerms
public Set<OntologyTerm> getCategoryTerms()
Description copied from interface:OntologyService
Obtain terms which are allowed for use in the category of aCharacteristic
.- Specified by:
getCategoryTerms
in interfaceOntologyService
-
getRelationTerms
public Set<OntologyProperty> getRelationTerms()
Description copied from interface:OntologyService
Obtain terms allowed for the predicate (relationship) in aStatement
.- Specified by:
getRelationTerms
in interfaceOntologyService
-
getDefinition
public String getDefinition(String uri, long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Obtain a definition for the given URI.- Specified by:
getDefinition
in interfaceOntologyService
- Throws:
TimeoutException
-
getTerm
public OntologyTerm getTerm(String uri, long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Obtain a term for the given URI.- Specified by:
getTerm
in interfaceOntologyService
- Throws:
TimeoutException
-
getTerms
public Set<OntologyTerm> getTerms(Collection<String> uris, long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Return all the terms matching the given URIs.- Specified by:
getTerms
in interfaceOntologyService
- Throws:
TimeoutException
- if the timeout is exceeded
-
reindexAllOntologies
public void reindexAllOntologies()
Description copied from interface:OntologyService
Recreate the search indices, for ontologies that are loaded.- Specified by:
reindexAllOntologies
in interfaceOntologyService
-
reinitializeAndReindexAllOntologies
public void reinitializeAndReindexAllOntologies()
Description copied from interface:OntologyService
Reinitialize (and reindex) all the ontologies "from scratch". This is necessary if indices are old etc. This should be admin-only.- Specified by:
reinitializeAndReindexAllOntologies
in interfaceOntologyService
-
findObsoleteTermUsage
public Map<OntologyTerm,Long> findObsoleteTermUsage(long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Locates usages of obsolete terms in Characteristics, ignoring Gene Ontology annotations. Requires the ontologies are loaded into memory.Will also find terms that are no longer in an ontology we use.
- Specified by:
findObsoleteTermUsage
in interfaceOntologyService
- Returns:
- map of value URI to a representative characteristic using the term. The latter will contain a count of how many occurrences there were.
- Throws:
TimeoutException
-
fixOntologyTermLabels
public Map<String,OntologyTerm> fixOntologyTermLabels(boolean dryRun, long timeout, TimeUnit timeUnit) throws TimeoutException
Description copied from interface:OntologyService
Check all system uses of ontology terms for the correct label and fix any mismatches based on the ontology OWL files. This should be run periodically along with findObsoleteTerms.- Specified by:
fixOntologyTermLabels
in interfaceOntologyService
- Parameters:
dryRun
- if true, no changes will be made in the database and just print them out instead.- Returns:
- Throws:
TimeoutException
-
-