uk.ac.ebi.microarray.zooma.retrieval
Class OntologyRetriever

java.lang.Object
  extended by uk.ac.ebi.microarray.zooma.retrieval.OntologyRetriever
All Implemented Interfaces:
OntologyTermRetriever

public class OntologyRetriever
extends java.lang.Object
implements OntologyTermRetriever

Retrieves OntologyTerms from an ontology file in OWL or OBO formats. This retriever uses the OWLAPI to load and handle the ontology, and operates over the reasoned version of the ontology using the pellet reasoner (and utilities from fluxion-utils). Therefore, you should only use this if you have direct axis to the ontology fiel, and you know this file will both classify and not overwhelm the capacity of the OWLAPI

Author:
Tony Burdett

Method Summary
 java.util.Collection<OntologyMappingContext> fetchMappingContexts(Value value, uk.ac.ebi.ontocat.OntologyTerm term)
          Fetch the contexts in which the given description is mapped to the given term, if any.
 java.util.Collection<uk.ac.ebi.ontocat.OntologyTerm> fetchTerms(Value value)
          Fetches terms that can be matched against EFO.
 java.util.Collection<uk.ac.ebi.ontocat.OntologyTerm> fetchTermsByAccession(java.lang.String accession)
          Takes the given term "accession" and attempts to resolve it against the URIs for classes in the ontology.
 java.util.List<java.lang.String> getClassNames(org.semanticweb.owl.model.OWLClass owlClass)
          Retrieve all possible names for the supplied class.
 java.util.Set<java.lang.String> getClassRDFSLabels(org.semanticweb.owl.model.OWLClass owlClass)
          Recovers all string values of the rdfs:label annotation attribute on the supplied class.
 java.util.Set<java.lang.String> getClassSynonyms(org.semanticweb.owl.model.OWLClass owlClass)
          Recovers all synonyms for the supplied owl class, based on the literal value of the efo synonym annotation.
static OntologyRetriever getInstance(java.lang.String ontologyName)
          Gets the singleton instance of a retriever for the named ontology.
 void init()
          Initializes this retriever, loading and preclassifying the ontology.
protected  boolean isObsolete(org.semanticweb.owl.model.OWLClass owlClass)
          Returns true if this ontology term is obsolete in EFO, false otherwise.
protected  boolean isUnit(org.semanticweb.owl.model.OWLClass owlClass)
           
protected  java.util.Set<org.semanticweb.owl.model.OWLClass> matchSearchString(java.lang.String searchString)
          Searches the classes known to this retriever for any that may match the given search string.
protected  java.lang.String normalizeSearchString(java.lang.String string)
          "Normalizes" a string into a searchable string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static OntologyRetriever getInstance(java.lang.String ontologyName)
Gets the singleton instance of a retriever for the named ontology.

Parameters:
ontologyName - the name of the ontology to retrieve, as specified in the config files
Returns:
an OntologyRetriever for the named ontology

init

public void init()
Initializes this retriever, loading and preclassifying the ontology. Class labels and uris are cached for faster searching


fetchTerms

public java.util.Collection<uk.ac.ebi.ontocat.OntologyTerm> fetchTerms(Value value)
                                                                throws java.io.IOException
Fetches terms that can be matched against EFO. By default, this excludes anything that is based on units (i.e. falls within the set of things that might be a member of the class UO:0000000). Searches are performed by exact text matching on term label or synonyms.

Specified by:
fetchTerms in interface OntologyTermRetriever
Parameters:
value - the text description to search for
Returns:
the collection of ontology terms retrieved
Throws:
java.io.IOException - if the ontology could not be read

fetchMappingContexts

public java.util.Collection<OntologyMappingContext> fetchMappingContexts(Value value,
                                                                         uk.ac.ebi.ontocat.OntologyTerm term)
                                                                  throws java.io.IOException
Description copied from interface: OntologyTermRetriever
Fetch the contexts in which the given description is mapped to the given term, if any. This returns a collection because there are no guarantees that a mapping has been supplied to the given description in exactly one way - there could be several possible context-dependent mappings in a single datasource, for example.

If there is no connection known between the supplied description and the supplied term in the datasource that backs this retriever, this method will return an empty list.

Specified by:
fetchMappingContexts in interface OntologyTermRetriever
Parameters:
value - the original description used to retrieve the supplied term
term - the term that is mapped to this description - usually, retrieved by OntologyTermRetriever.fetchTerms(uk.ac.ebi.microarray.zooma.lang.Value) first
Returns:
the contexts in which this mapping is described in the backing
Throws:
java.io.IOException - if context could not be fetched from the underlying source

fetchTermsByAccession

public java.util.Collection<uk.ac.ebi.ontocat.OntologyTerm> fetchTermsByAccession(java.lang.String accession)
Takes the given term "accession" and attempts to resolve it against the URIs for classes in the ontology. This uses simple substring matching, assuming that the "accession" (e.g. from Bioportal) matches against some fragment of the ontology class URI. If this yields no results, you could try using fetchTerms(uk.ac.ebi.microarray.zooma.lang.Value) to attempt to resolve the "accession" against the term name or synonym.

Parameters:
accession - the "accession" assigned to a term e.g. from bioportal
Returns:
the URI that the given accession probably resolves to

getClassNames

public java.util.List<java.lang.String> getClassNames(org.semanticweb.owl.model.OWLClass owlClass)
Retrieve all possible names for the supplied class. Class "names" include any labels attached to this class, or any synonyms supplied.

Parameters:
owlClass - the owl class to derive names for
Returns:
the list of strings representing labels or synonyms for this class

getClassRDFSLabels

public java.util.Set<java.lang.String> getClassRDFSLabels(org.semanticweb.owl.model.OWLClass owlClass)
Recovers all string values of the rdfs:label annotation attribute on the supplied class. This is computed over the inferred hierarchy, so labels of any equivalent classes will also be returned.

Parameters:
owlClass - the class to recover labels for
Returns:
the literal values of the rdfs:label annotation

getClassSynonyms

public java.util.Set<java.lang.String> getClassSynonyms(org.semanticweb.owl.model.OWLClass owlClass)
Recovers all synonyms for the supplied owl class, based on the literal value of the efo synonym annotation. The actual URI for this annotation is recovered from zooma-uris.properties, but at the time of writing was 'http://www.ebi.ac.uk/efo/alternative_term'. This class uses the

Parameters:
owlClass - the class to retrieve the synonyms of
Returns:
a set of strings containing all aliases of the supplied class

matchSearchString

protected java.util.Set<org.semanticweb.owl.model.OWLClass> matchSearchString(java.lang.String searchString)
Searches the classes known to this retriever for any that may match the given search string. This implementation uses very simple logic, simply looking for exact matches in class labels and synonyms. Other implementions, with more advanced searching, can obviously be implemented.

Parameters:
searchString - the search string - this will usually be the class name/synonym
Returns:
a set of matching classes.

normalizeSearchString

protected java.lang.String normalizeSearchString(java.lang.String string)
"Normalizes" a string into a searchable string. This implementation is fairly basic, it simply involves lowercasing the entire string, and stripping trailing and internal whitespace. You can extend this to provide more advanced normalization (for example, converting between English and American spellings).

Parameters:
string - the string to normalize
Returns:
the searchable string

isObsolete

protected boolean isObsolete(org.semanticweb.owl.model.OWLClass owlClass)
Returns true if this ontology term is obsolete in EFO, false otherwise. In EFO, a term is defined to be obsolete if and only if it is a subclass of ObsoleteTerm.

Parameters:
owlClass - the owlClass to check for obsolesence
Returns:
true if obsoleted, false otherwise

isUnit

protected boolean isUnit(org.semanticweb.owl.model.OWLClass owlClass)


Copyright © 2010. All Rights Reserved.