HCLS/OntologyTaskForce/Ontologization for Transitive Closure Inferences/Examples

From W3C Wiki

This is a demonstration of 3 patterns for encoding hierarchy using OWL

To demonstrate I represent a small piece of the ISA hierarchy from Gene Ontology. Spaces represent the depth in the hierarchy. The parent is the item above with less indentation.


GO_0000060
  GO_0000189
     GO_0000201
     GO_0000208
  GO_0007184
  GO_0007262
  GO_0035105
     GO_0006993


The first pattern is to use subclass relations to represent the parent-child relationship.


Namespace(go = <http://www.geneontology.org/owl/#>)
Ontology(<http://example.com/#> 
  Class(go:GO_0000201 partial go:GO_0000189 )
  Class(go:GO_0000208 partial go:GO_0000189 )
  Class(go:GO_0000189 partial go:GO_0000060 )
  Class(go:GO_0007184 partial go:GO_0000060 )
  Class(go:GO_0007262 partial go:GO_0000060 )
  Class(go:GO_0006993 partial go:GO_0035105 )
  Class(go:GO_0035105 partial go:GO_0000060 )
)


Media:HCLS$$OntologyTaskForce$$Ontologization_for_Transitive_Closure_Inferences$$Examples$type-hierarchy.owl

To query for the transitive children, using SPARQL, we ask for all the subclasses of the term. In this case we ask for all children of the top term: GO_0000060. Note that we filter out !owl:Nothing, the subclass of all classes, and the top level term itself, since anything is a subclass of itself.


PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX go: <http://www.geneontology.org/owl/#>
SELECT ?term 
WHERE { 
  ?term rdfs:subClassOf go:GO_0000060 . 
FILTER 
  ((!((?term =  <http://www.w3.org/2002/07/owl#Nothing> ))) 
  && (!((?term =  go:GO_0000060 ))))
       } 

Results:
go:GO_0007262
go:GO_0000189
go:GO_0035105
go:GO_0007184
go:GO_0000201
go:GO_0000208
go:GO_0006993



The second pattern is to use an existential hierarchy. This is the technique used, for example, to represent non-isa relationships in the OWL translations of the OBO ontologies.


Namespace(go = <http://www.geneontology.org/owl/#>)
Ontology(<http://example.com/#> 
  ObjectProperty(go:go_isa Transitive )
  Class(go:GO_0000201 partial restriction(go:go_isa someValuesFrom(go:GO_0000189 )))
  Class(go:GO_0000208 partial restriction(go:go_isa someValuesFrom(go:GO_0000189 )))
  Class(go:GO_0000189 partial restriction(go:go_isa someValuesFrom(go:GO_0000060 )))
  Class(go:GO_0007184 partial restriction(go:go_isa someValuesFrom(go:GO_0000060 )))
  Class(go:GO_0007262 partial restriction(go:go_isa someValuesFrom(go:GO_0000060 )))
  Class(go:GO_0006993 partial restriction(go:go_isa someValuesFrom(go:GO_0035105 )))
  Class(go:GO_0035105 partial restriction(go:go_isa someValuesFrom(go:GO_0000060 )))

  Class(go:probe complete restriction(go:go_isa someValuesFrom(go:GO_0000060 )))
)


Media:HCLS$$OntologyTaskForce$$Ontologization_for_Transitive_Closure_Inferences$$Examples$existential-hierarchy.owl

Query for subs in SPARQL requires a tbox query that is either not currently available in Pellet, or which I don't know how to do. So to query we create a probe class, and ask for the subclasses of the probe class. Support for this sort of query is available directly in DIG, I believe, and should be available in Pellet soon.


PREFIX go: <http://www.geneontology.org/owl/#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?term
WHERE { 
  ?term rdfs:subClassOf go:probe . 
FILTER 
  ((!((?term =  <http://www.w3.org/2002/07/owl#Nothing> ))) && (!((?term =  go:probe ))))
      } 

Results:
go:GO_0007262
go:GO_0000189
go:GO_0007184
go:GO_0035105
go:GO_0000201
go:GO_0000208
go:GO_0006993


An alternative is to query for the direct subterms by finding classes that are defined in terms of the restriction. You would then need to loop doing the same query on the results to get the full set.


PREFIX go: <http://www.geneontology.org/owl/#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?term
WHERE { 
  ?term rdfs:subClassOf ?_restriction . 
  ?_restriction owl:onProperty go:go_isa . 
  ?_restriction owl:someValuesFrom go:GO_0000060 . 
      } 

Results:
 go:GO_0000189
 go:GO_0007184
 go:GO_0007262
 go:GO_0035105



The third pattern is to represent the hierarchy as individuals,


Namespace(go = <http://www.geneontology.org/owl/#>)
Ontology(<http://example.com/#> 
  Class(go:term partial )
  ObjectProperty(go:go_isa Transitive )
  Individual(go:GO_0000201 type(go:term )value(go:go_isa go:GO_0000189 ))
  Individual(go:GO_0000208 type(go:term )value(go:go_isa go:GO_0000189 ))
  Individual(go:GO_0000189 type(go:term )value(go:go_isa go:GO_0000060 ))
  Individual(go:GO_0007184 type(go:term )value(go:go_isa go:GO_0000060 ))
  Individual(go:GO_0007262 type(go:term )value(go:go_isa go:GO_0000060 ))
  Individual(go:GO_0006993 type(go:term )value(go:go_isa go:GO_0035105 ))
  Individual(go:GO_0035105 type(go:term )value(go:go_isa go:GO_0000060 ))
)


Media:HCLS$$OntologyTaskForce$$Ontologization_for_Transitive_Closure_Inferences$$Examples$individual-hierarchy.owl

To query, we simply ask for the go_isa slot value on the term we are interested in, which is declared as transitive.


PREFIX go: <http://www.geneontology.org/owl/#>
SELECT DISTINCT ?term
WHERE { 
?term go:go_isa go:GO_0000060 . } 
Results:
go:GO_0007262
go:GO_0000189
go:GO_0035105
go:GO_0007184
go:GO_0000201
go:GO_0000208
go:GO_0006993


The lisp code that generated these examples is hierarchy-examples.lisp, and patterns.lisp