How to create a rule set from an owl schema stored in RDF XML?

Problem:

I am attempting to enable queries containing rdfs:subClassOf with respect to the following prefix:

PREFIX bp: <http://www.biopax.org/release/biopax-level3.owl#>

Note that the above namespace <http://www.biopax.org/release/biopax-level3.owl#> is a schema written in RDF XML with terms like:

    <owl:Class rdf:ID="ComplexAssembly">
        <rdfs:subClassOf rdf:resource="#Conversion"/>

Attempted Solution:

Following the documentation on Enabling Inferencing, I created a rule set as follows:

rdfs_rule_set ('bp3','http://www.biopax.org/release/biopax-level3.owl#') ;

Sanity check:

SQL> select * from DB.DBA.SYS_RDF_SCHEMA;
RS_NAME                                                                           RS_URI                                                                            RS_G
VARCHAR NOT NULL                                                                  VARCHAR NOT NULL                                                                  VARCHAR
_______________________________________________________________________________

asEquivalent                                                                      urn:activitystreams-owl:map                                                       NULL
bp3                                                                               http://www.biopax.org/release/biopax-level3.owl#                                  NULL
http://www.w3.org/2002/07/owl#                                                    http://www.w3.org/2002/07/owl#                                                    NULL
ldp                                                                               http://www.w3.org/ns/ldp#                                                         NULL

4 Rows. -- 0 msec.

However, SPARQL queries with the following rule context still fail to perform expected traversals:

DEFINE input:inference "bp3"

PREFIX wp:    <http://vocabularies.wikipathways.org/wp#>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bp: <http://www.biopax.org/release/biopax-level3.owl#>

My concern is that the Examples in the Enabling Inference documentation usually specified inference graphs directly like:

ttlp ('
   <http://example.com/dataspace>                                 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://rdfs.org/sioc/ns#Space>.
   <http://example.com/dataspace/test2/weblog/test2tWeblog>  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://rdfs.org/sioc/types#Weblog> .
   <http://example.com/dataspace/discussion/oWiki-test1Wiki> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  <http://rdfs.org/sioc/types#MessageBoard>.
   <http://example.com/dataspace>                            <http://rdfs.org/sioc/ns#link>                     <http://example.com/ods> .
   <http://example.com/dataspace/test2/weblog/test2tWeblog>  <http://rdfs.org/sioc/ns#link>                     <http://example.com/dataspace/test2/weblog/test2tWeblog>.
   <http://example.com/dataspace/discussion/oWiki-test1Wiki> <http://rdfs.org/sioc/ns#link>                     <http://example.com/dataspace/discussion/oWiki-test1Wiki> .
   ', '', 'http://example.com/test');

Conversely, my inference rules are buried in a huge schema (http://www.biopax.org/release/biopax-level3.owl#) which resolves to an XML that begins like:

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE rdf:RDF [
    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
    <!ENTITY swrl "http://www.w3.org/2003/11/swrl#" >
    <!ENTITY swrlb "http://www.w3.org/2003/11/swrlb#" >
    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
    <!ENTITY protege "http://protege.stanford.edu/plugins/owl/protege#" >
    <!ENTITY xsp "http://www.owl-ontologies.com/2005/08/07/xsp.owl#" >
]>


<rdf:RDF xmlns="http://www.biopax.org/release/biopax-level3.owl#"
     xml:base="http://www.biopax.org/release/biopax-level3.owl"
     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     xmlns:swrl="http://www.w3.org/2003/11/swrl#"
     xmlns:protege="http://protege.stanford.edu/plugins/owl/protege#"
     xmlns:xsp="http://www.owl-ontologies.com/2005/08/07/xsp.owl#"
     xmlns:owl="http://www.w3.org/2002/07/owl#"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
     xmlns:swrlb="http://www.w3.org/2003/11/swrlb#"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <owl:Ontology rdf:about="">
        <rdfs:comment rdf:datatype="&xsd;string"
            >This is version 1.0  of the BioPAX Level 3 ontology.  The goal of the BioPAX group is to develop a common exchange format for biological pathway data.  More information is available at http://www.biopax.org.  This ontology is freely available under the LGPL (http://www.gnu.org/copyleft/lesser.html).</rdfs:comment>
    </owl:Ontology>
...

Do I need to somehow extract all rdfs:subPropertyOf and rdfs:subClassOf from this in order to create a rule set? If so, how can I do this automatically?

Yes, the inference graph data/rules do need to be loaded into Virtuoso before the inference rule is created. And if you inference graph containing the rules is a HTTP accessible URI in RDF/XML form it can be loaded as per this
Inference Rule example using transitive properties from SKOS vocabulary example, using the call DB.DBA.RDF_LOAD_RDFXML (http_get ('http://www.biopax.org/release/biopax-level3.owl#'), 'no', 'http://www.biopax.org/release/biopax-level3.owl#'); function.

1 Like

Thanks @hwilliams

In case I want to load a compressed HTTP accessible RDF/XML file, is there a way to do that using gz_uncompress?

I’m thinking something like the following but I’m not sure how to deal with the output file parameter:

DB.DBA.RDF_LOAD_RDFXML (
    http_get (
        gz_uncompress(
            'https://www.pathwaycommons.org/archives/PC2/v12/PathwayCommons12.reactome.BIOPAX.owl.gz'
        )
    ), '', 'http://pathwaycommons.org/pc12');

Uncompressing via HTTP on the fly would not work, the compressed file would have to be downloaded on the file system and then it can be uncompressed with the gz_file_open function.

1 Like