owltools.mooncat
Class PropertyViewOntologyBuilder

java.lang.Object
  extended by owltools.mooncat.PropertyViewOntologyBuilder

public class PropertyViewOntologyBuilder
extends Object

This class will create a property view or *faceted* view over an ontology using a specified property (relation). One use for this is building Solr indexes - each property view ontology would correspond to a distinct facet. For example, a faceted view over samples classified using a cell type ontology might have individual classifications for sample-by-cell-lineage, sample-by-system, sample-by-disease

Algorithm

A PropertyViewOntology O(P) is a materialized view over a Source Ontology O using an object property P, such that for every class C in O there is a class C(P) in O(P), together with an axiom C(P) = P some C. In addition, O(P) imports O. Each class C(P) in O(P) is optionally named automatically according to some template. An Inferred PropertyViewOntology O(P)' is created by adding all direct inferred subclass axioms between classes in O(P)', as well as inferred class assertion axioms. Optionally, another import can be added to O(P) - this is where we would add an ontology of elements to classified using classes in O(P). The elements may be individuals or classes. We denote this as O(P,O^e) where O^e is the imported element ontology, and O(P,O^e)' is obtained by finding all inferred direct subclass axioms between classes in O(P) or subclass/class assertion axioms between entities i O^e and classes in O(P). For example, if the O is an anatomy ontology (which includes partOf relations) including classes {body, limb, forelimb, hand, ...} and axioms {forelimb SubClassOf limb, hand SubClassOf part_of finger}, then the O(partOf) will include only equivalence axioms, all of the form {'forelimb part' = partOf some forelimb, hand part' = partOf some hand, etc} (assuming we use a naming scheme where we suffix using " part"). After reasoning, the inferred property view ontology O(partOf)' will contain subclass axioms forming a hierarchy like this:
  body part
    limb part
      forelimb part
        hand part
          finger part
            phalanx part
 
If we also have an additional element ontology G containing individuals {gene1, gene2, ...} and class assertions {gene1 Type expressedIn some finger, ...}, where expressedIn is declared as expressedIn o partOf -> expressedIn Then the combined subclass/class assertion hierarchy O(expressedIn,G)' will look like this:
  body gene
    limb gene
      forelimb gene
        hand gene
          finger gene
            gene1
            phalanx gene
 
TODO - allow O(P)' to be exported as SKOS

Notes

If you have some 'leaf' element to classify - e.g. genes - make sure you pass in an elementsOntology E. Otherwise these will go into O(P) as "P some gene123", which will not classify as anything.

Author:
cjm

Constructor Summary
PropertyViewOntologyBuilder(org.semanticweb.owlapi.model.OWLDataFactory owlDataFactory, org.semanticweb.owlapi.model.OWLOntologyManager owlOntologyManager, org.semanticweb.owlapi.model.OWLOntology sourceOntology, org.semanticweb.owlapi.model.OWLOntology unitsOntology, org.semanticweb.owlapi.model.OWLObjectProperty viewProperty)
           
PropertyViewOntologyBuilder(org.semanticweb.owlapi.model.OWLOntology sourceOntology, org.semanticweb.owlapi.model.OWLOntology elementsOntology, org.semanticweb.owlapi.model.OWLObjectProperty viewProperty)
           
 
Method Summary
 void addViewEntities(Set<org.semanticweb.owlapi.model.OWLEntity> newEntities)
           
 void buildInferredViewOntology(org.semanticweb.owlapi.reasoner.OWLReasoner reasoner)
          Once the PVO has been constructed, this uses a reasoner to classify it.
 void buildViewOntology()
          As buildViewOntology(IRI, IRI), but both O(P) and O(P)' have automatically generated IRIs
 void buildViewOntology(org.semanticweb.owlapi.model.IRI avoIRI, org.semanticweb.owlapi.model.IRI ivoIRI)
          Constructs a property view ontology O(P) or O(P,E) from source ontology O, such that every class C in O has a corresponding view class C' in O(P), such that C' EquivalentTo = P some C O(P) imports both the O, and optionally the elements ontology E - in which case we call the ontology O(P,E).
 org.semanticweb.owlapi.model.OWLOntology getAssertedViewOntology()
          Automatically generated Property View Ontology O(P) containing axioms C' == P some C, for each C in source ontology
 org.semanticweb.owlapi.model.OWLOntology getElementsOntology()
           
 org.semanticweb.owlapi.model.OWLOntology getInferredViewOntology()
          Generated after running buildInferredViewOntology(OWLReasoner) Note that O(P) and O(P)' can share the same object, i.e the assertedViewOntology is augmented to become the inferred view ontology
 Set<org.semanticweb.owlapi.model.OWLEntity> getViewEntities()
           
 String getViewLabelPrefix()
           
 String getViewLabelSuffix()
           
 org.semanticweb.owlapi.model.OWLClass getViewRootClass()
          As the we treat Thing as belonging to O, O(P) will contain "P some Thing", and this will be the root of O(P)
 boolean isAssumeOBOStyleIRIs()
           
 boolean isClassifyIndividuals()
           
 boolean isFilterUnused()
           
 boolean isUseOriginalClassIRIs()
           
 void setAssertedViewOntology(org.semanticweb.owlapi.model.OWLOntology assertedViewOntology)
           
 void setAssumeOBOStyleIRIs(boolean isAssumeOBOStyleIRIs)
          set to false if IRIs are not OBO purls.
 void setClassifyIndividuals(boolean isClassifyIndividuals)
           
 void setElementsOntology(org.semanticweb.owlapi.model.OWLOntology elementsOntology)
           
 void setFilterUnused(boolean isFilterUnused)
           
 void setInferredViewOntology(org.semanticweb.owlapi.model.OWLOntology inferredViewOntology)
           
 void setUseOriginalClassIRIs(boolean isUseOriginalClassIRIs)
           
 void setViewEntities(Set<org.semanticweb.owlapi.model.OWLEntity> viewEntities)
           
 void setViewLabelPrefix(String viewLabelPrefix)
          Set this to prefix all class labels in O(P)
 void setViewLabelPrefixAndSuffix(String viewLabelPrefix, String viewLabelSuffix)
           
 void setViewLabelSuffix(String viewLabelSuffix)
          Set this to suffix all class labels in O(P)
 void translateABoxToTBox()
           
 void translateABoxToTBox(org.semanticweb.owlapi.model.OWLOntology srcOnt)
          generates SubClassOf axioms from ClassAssertion axioms Note that property assertions are currently ignored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyViewOntologyBuilder

public PropertyViewOntologyBuilder(org.semanticweb.owlapi.model.OWLOntology sourceOntology,
                                   org.semanticweb.owlapi.model.OWLOntology elementsOntology,
                                   org.semanticweb.owlapi.model.OWLObjectProperty viewProperty)
Parameters:
sourceOntology -
elementsOntology -
viewProperty -

PropertyViewOntologyBuilder

public PropertyViewOntologyBuilder(org.semanticweb.owlapi.model.OWLDataFactory owlDataFactory,
                                   org.semanticweb.owlapi.model.OWLOntologyManager owlOntologyManager,
                                   org.semanticweb.owlapi.model.OWLOntology sourceOntology,
                                   org.semanticweb.owlapi.model.OWLOntology unitsOntology,
                                   org.semanticweb.owlapi.model.OWLObjectProperty viewProperty)
Parameters:
owlDataFactory -
owlOntologyManager -
sourceOntology -
unitsOntology -
viewProperty -
Method Detail

getAssertedViewOntology

public org.semanticweb.owlapi.model.OWLOntology getAssertedViewOntology()
Automatically generated Property View Ontology O(P) containing axioms C' == P some C, for each C in source ontology

Returns:

setAssertedViewOntology

public void setAssertedViewOntology(org.semanticweb.owlapi.model.OWLOntology assertedViewOntology)

getInferredViewOntology

public org.semanticweb.owlapi.model.OWLOntology getInferredViewOntology()
Generated after running buildInferredViewOntology(OWLReasoner) Note that O(P) and O(P)' can share the same object, i.e the assertedViewOntology is augmented to become the inferred view ontology

Returns:
O(P)' or O(P,E)'

setInferredViewOntology

public void setInferredViewOntology(org.semanticweb.owlapi.model.OWLOntology inferredViewOntology)

getElementsOntology

public org.semanticweb.owlapi.model.OWLOntology getElementsOntology()

setElementsOntology

public void setElementsOntology(org.semanticweb.owlapi.model.OWLOntology elementsOntology)

getViewEntities

public Set<org.semanticweb.owlapi.model.OWLEntity> getViewEntities()
Returns:
The set of all entities in the view ontology O(P)

setViewEntities

public void setViewEntities(Set<org.semanticweb.owlapi.model.OWLEntity> viewEntities)

addViewEntities

public void addViewEntities(Set<org.semanticweb.owlapi.model.OWLEntity> newEntities)

getViewRootClass

public org.semanticweb.owlapi.model.OWLClass getViewRootClass()
As the we treat Thing as belonging to O, O(P) will contain "P some Thing", and this will be the root of O(P)

Returns:
the root declared class of O(P)

getViewLabelPrefix

public String getViewLabelPrefix()

setViewLabelPrefix

public void setViewLabelPrefix(String viewLabelPrefix)
Set this to prefix all class labels in O(P)

Parameters:
viewLabelPrefix -

getViewLabelSuffix

public String getViewLabelSuffix()

setViewLabelSuffix

public void setViewLabelSuffix(String viewLabelSuffix)
Set this to suffix all class labels in O(P)

Parameters:
viewLabelSuffix -

setViewLabelPrefixAndSuffix

public void setViewLabelPrefixAndSuffix(String viewLabelPrefix,
                                        String viewLabelSuffix)

isUseOriginalClassIRIs

public boolean isUseOriginalClassIRIs()

setUseOriginalClassIRIs

public void setUseOriginalClassIRIs(boolean isUseOriginalClassIRIs)

isClassifyIndividuals

public boolean isClassifyIndividuals()

setClassifyIndividuals

public void setClassifyIndividuals(boolean isClassifyIndividuals)

isFilterUnused

public boolean isFilterUnused()

setFilterUnused

public void setFilterUnused(boolean isFilterUnused)

isAssumeOBOStyleIRIs

public boolean isAssumeOBOStyleIRIs()

setAssumeOBOStyleIRIs

public void setAssumeOBOStyleIRIs(boolean isAssumeOBOStyleIRIs)
set to false if IRIs are not OBO purls. if true, then IRIs in O(P) will be formed by concatenating C and P IDs

Parameters:
isAssumeOBOStyleIRIs - - default is true

buildViewOntology

public void buildViewOntology()
                       throws org.semanticweb.owlapi.model.OWLOntologyCreationException
As buildViewOntology(IRI, IRI), but both O(P) and O(P)' have automatically generated IRIs

Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

buildViewOntology

public void buildViewOntology(org.semanticweb.owlapi.model.IRI avoIRI,
                              org.semanticweb.owlapi.model.IRI ivoIRI)
                       throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Constructs a property view ontology O(P) or O(P,E) from source ontology O, such that every class C in O has a corresponding view class C' in O(P), such that C' EquivalentTo = P some C O(P) imports both the O, and optionally the elements ontology E - in which case we call the ontology O(P,E). As part of this procedure, an inferred property view ontology O(P)' or O(P,E)' is created You must call buildInferredViewOntology yourself (because you need to set up the reasoner object yourself, and feed in O(P) as input) TODO - use reasonerfactory E.g.
                pvob.buildViewOntology(IRI.create("http://x.org"), IRI.create("http://y.org"));
                OWLOntology avo = pvob.getAssertedViewOntology();
                OWLReasoner vr = reasonerFactory.createReasoner(avo);
                pvob.buildInferredViewOntology(vr); 
 

Parameters:
avoIRI -
ivoIRI -
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

buildInferredViewOntology

public void buildInferredViewOntology(org.semanticweb.owlapi.reasoner.OWLReasoner reasoner)
Once the PVO has been constructed, this uses a reasoner to classify it. The inferred direct superclasses of all view entities are added to the IPVO In addition to classifying PVO, the elements ontology (e,g genes) is also classified.

Parameters:
reasoner -

translateABoxToTBox

public void translateABoxToTBox(org.semanticweb.owlapi.model.OWLOntology srcOnt)
                         throws org.semanticweb.owlapi.model.OWLOntologyCreationException
generates SubClassOf axioms from ClassAssertion axioms Note that property assertions are currently ignored

Parameters:
srcOnt -
isReplaceOntology -
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException

translateABoxToTBox

public void translateABoxToTBox()
                         throws org.semanticweb.owlapi.model.OWLOntologyCreationException
Throws:
org.semanticweb.owlapi.model.OWLOntologyCreationException


Copyright © 2010-2012. All Rights Reserved.