phenoscape / owlery

Owlery is a set of REST web services which allow querying of an OWL reasoner containing a configured set of ontologies.
MIT License
16 stars 11 forks source link

How to use Owlery with a Triple Store #141

Open rpgoldman opened 3 years ago

rpgoldman commented 3 years ago

Owlery has solved a big problem for me: making an OpenAPI-accessible server that can answer DL queries.

But now I would like to investigate further the entities that I retrieve from Owlery. E.g., what is the value of some property or properties of an individual I find.

IIUC, one must team Owlery up with a separate SPARQL database to handle this. Is this the correct procedure:

  1. Use an OWL reasoner such as HermiT to expand the ontology to contain explicit assertions that are only implicit in the ontology. I think this is what robot's materialize command is for, but I'm not entirely sure.

  2. Load the resulting ontology file into some SPARQL-capable database. It seems like Apache's Fuseki might be an appropriate choice, although I confess to not having done a lot of comparison shopping.

balhoff commented 3 years ago

@rpgoldman I have typically used Owlery as a parallel service to a SPARQL endpoint. I have an application which is querying a SPARQL endpoint for certain information (like labels for certain IRIs), and submits queries to Owlery for reasoner questions. So the integration is all in application code.

Your proposed steps could be independent of Owlery I think. If you are mainly interested in the inferred class hierarchy, and not generating ad hoc class expressions for DL queries, you could materialize rdfs:subClassOf links ahead of time and store in the triple store. Confusingly, you would want ROBOT reason for that. materialize is a bit more specialized; it generates existential relations that aren't explicitly stated in the ontology.

I use Owlery when I want to submit arbitrary user-generated queries like 'bone element' and part_of some skull and develops_from 'endochondral tissue'.

There is a fancier integration between Owlery and a triplestore. You can embed a class expression inside a SPARQL query using an Owlery-specific datatype. Then submit that SPARQL query to Owlery, which will expand the class expression using the reasoner, and inject all the resulting terms into a rewritten query. The response is a new SPARQL query. You then submit that SPARQL query to your triplestore. You can see some examples here: https://github.com/phenoscape/owlet/wiki

rpgoldman commented 3 years ago

Thank you very much, @balhoff ! I will have a look at that as soon as possible. Right now I'm still having some trouble with my owlery setup, as witness my earlier query (the novelette I wrote and called an issue!).