Package org.biojava.ontology
Interface Ontology
-
- All Superinterfaces:
Changeable
- All Known Subinterfaces:
ComparableOntology
- All Known Implementing Classes:
IntegerOntology
,Ontology.Impl
,SimpleComparableOntology
public interface Ontology extends Changeable
An ontology.This is just a set of Term objects, and a set of Triple objects describing relationships between these terms. This class does not itself contain any reasoning functionality. Ontology is a collection of facts, or axioms.
- Since:
- 1.4
- Author:
- Thomas Down, Matthew Pocock
- See Also:
ComparableOntology
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Ontology.Impl
A basic in-memory implementation of an ontology
-
Field Summary
Fields Modifier and Type Field Description static ChangeType
TERM
static ChangeType
TRIPLE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
containsTerm(String name)
Determines if this ontology currently contains a term namedname
boolean
containsTriple(Term subject, Term object, Term predicate)
See if a triple exists in this ontologyTerm
createTerm(String name)
Create a new term in this ontology.Term
createTerm(String name, String description)
Create a new term in this ontology.Term
createTerm(String name, String description, Object[] synonyms)
Create a new term in this ontology.Triple
createTriple(Term subject, Term object, Term predicate, String name, String description)
Creates a new Triple.Variable
createVariable(String name, String description)
Create a new term in this ontology that is used as a variable.void
deleteTerm(Term t)
Remove a term from an ontology, together with all triples which refer to it.String
getDescription()
Return a human-readable description of this ontology, or the empty string if none is availableString
getName()
Return the name of this ontologyOntologyOps
getOps()
Return the associated OntologyOps.Term
getTerm(String name)
Fetch the term with the specified name.Set<Term>
getTerms()
Return all the terms in this ontologySet<Triple>
getTriples(Term subject, Term object, Term predicate)
Return all triples from this ontology which match the supplied pattern.Term
importTerm(Term t, String localName)
Create a view of a term from another ontology.void
setDescription(String description)
set the description of this ontologyvoid
setName(String name)
Set the name for this ontology-
Methods inherited from interface org.biojava.utils.Changeable
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
-
-
-
-
Field Detail
-
TERM
static final ChangeType TERM
-
TRIPLE
static final ChangeType TRIPLE
-
-
Method Detail
-
getDescription
String getDescription()
Return a human-readable description of this ontology, or the empty string if none is available- Returns:
- the description of the term
-
setDescription
void setDescription(String description)
set the description of this ontology- Parameters:
description
-
-
getTerms
Set<Term> getTerms()
Return all the terms in this ontology- Returns:
- a Set of all Terms of the ontology.
-
getTerm
Term getTerm(String name) throws NoSuchElementException
Fetch the term with the specified name.- Parameters:
name
- the name of the term- Returns:
- The term named
name
- Throws:
NoSuchElementException
- if no term exists with that name
-
getTriples
Set<Triple> getTriples(Term subject, Term object, Term predicate)
Return all triples from this ontology which match the supplied pattern. If any of the parameters of this method arenull
, they are treated as wildcards.- Parameters:
subject
- The subject to search for, ornull
object
- The object to search for, ornull
predicate
- The relationship to search for, ornull
.- Returns:
- a Set of triples
-
getOps
OntologyOps getOps()
Return the associated OntologyOps. This method should be implemented by ontology implementors to allow OntoTools to get optimized access to some usefull ontology operations. It is not intended that users will ever invoke this. A sensible dumb implementation of this would return a per-ontology instance of DefaultOps.- Returns:
- the OntologyOps instance associated with this instance.
-
createTerm
Term createTerm(String name) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
Create a new term in this ontology.- Parameters:
name
- The name of the term (must be unique))- Returns:
- The newly created term.
- Throws:
IllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.AlreadyExistsException
- if a term of this name already existsChangeVetoException
-
createTerm
Term createTerm(String name, String description) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
Create a new term in this ontology.- Parameters:
name
- The name of the term (must be unique)description
- A human-readable description (may be empty)- Returns:
- The newly created term.
- Throws:
IllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.AlreadyExistsException
- if a term of this name already existsChangeVetoException
-
createTerm
Term createTerm(String name, String description, Object[] synonyms) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
Create a new term in this ontology.- Parameters:
name
- The name of the term (must be unique)description
- A human-readable description (may be empty)synonyms
- Some synonyms for this term.- Returns:
- The newly created term.
- Throws:
IllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.AlreadyExistsException
- if a term of this name already existsChangeVetoException
-
createVariable
Variable createVariable(String name, String description) throws AlreadyExistsException, ChangeVetoException, IllegalArgumentException
Create a new term in this ontology that is used as a variable.- Parameters:
name
- The name of the term (must be unique)description
- A human-readable description (may be empty)- Returns:
- The newly created term.
- Throws:
IllegalArgumentException
- if eithername
ordescription
isnull
, or violates some other constraint of this implementation.AlreadyExistsException
- if a term of this name already existsChangeVetoException
-
importTerm
Term importTerm(Term t, String localName) throws ChangeVetoException, IllegalArgumentException
Create a view of a term from another ontology. If the requested term has already been imported under that name, this method returns the existing RemoteTerm object. If the term that is being imported is itself a RemoteTerm instance then first unwrap the term back to the orriginal term it represents and then produce a RemoteTerm from that. If the term being imported orriginated from this ontology, then return that term unaltered.- Parameters:
t
- the Term to importlocalName
- the local name to import it under, optionally null- Returns:
- a Term
- Throws:
ChangeVetoException
IllegalArgumentException
-
createTriple
Triple createTriple(Term subject, Term object, Term predicate, String name, String description) throws AlreadyExistsException, ChangeVetoException
Creates a new Triple.- Parameters:
subject
- the subject Termobject
- the object Termpredicate
- the predicate Termname
- the name of the triple, or nulldescription
- the description of the triple, or null- Returns:
- a new Triple over these three terms
- Throws:
AlreadyExistsException
- if a triple already exists with the same subject, object and predicate, regardless of the name and descriptionChangeVetoException
NullPointerException
- if subject, object or predicate are nullIllegalArgumentException
- if subject, object or predicate are not all from the same ontology
-
containsTriple
boolean containsTriple(Term subject, Term object, Term predicate)
See if a triple exists in this ontology- Parameters:
subject
-object
-predicate
-- Returns:
- true if contained
-
deleteTerm
void deleteTerm(Term t) throws ChangeVetoException
Remove a term from an ontology, together with all triples which refer to it.- Parameters:
t
-- Throws:
ChangeVetoException
-
containsTerm
boolean containsTerm(String name)
Determines if this ontology currently contains a term namedname
- Parameters:
name
-- Returns:
- true is contained
-
-