Problem with SPARQL query nested value extraction

I am trying to extract ?id ?label ?synonym ?dbXref ?isa ?someValuesFrom, from owl file with tags with the same below structure.

<owl:Class rdf:about="http://purl.obolibrary.org/obo/GO_0000015">
    <rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/GO_1902494"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://purl.obolibrary.org/obo/BFO_0000050"/>
            <owl:someValuesFrom rdf:resource="http://purl.obolibrary.org/obo/GO_0005829"/>
        </owl:Restriction>
    </rdfs:subClassOf>
    <obo1:IAO_0000115>A multimeric enzyme complex, usually a dimer or an octamer, that catalyzes the            conversion of 2-phospho-D-glycerate to phosphoenolpyruvate and water.</obo1:IAO_0000115>
    <oboInOwl:hasExactSynonym>enolase complex</oboInOwl:hasExactSynonym>
    <oboInOwl:hasOBONamespace>cellular_component</oboInOwl:hasOBONamespace>
    <oboInOwl:id>GO:0000015</oboInOwl:id>
    <oboInOwl:inSubset rdf:resource="http://purl.obolibrary.org/obo/go#goslim_metagenomics"/>
    <rdfs:label>phosphopyruvate hydratase complex</rdfs:label>
 </owl:Class>

I used rdflib and below is the query. but the result shows None for ?someValuesFrom

query = """
SELECT ?id ?label ?synonym ?dbXref ?isa  ?someValuesFrom
WHERE {
    ?class rdf:type owl:Class .
    ?class oboInOwl:id ?id ;
    rdfs:label ?label .
OPTIONAL {
    ?class oboInOwl:hasExactSynonym ?synonym .}
    OPTIONAL {
        ?class oboInOwl:hasDbXref ?dbXref .}
    OPTIONAL {
        ?class rdfs:subClassOf ?isa .}
    OPTIONAL {
        ?class   rdfs:subClassOf ?subclass .
        ?subclass  rdf:type  rdfs:subClassOf .
        ?subclass  owl:Restriction  ?restriction .
        ?restriction rdf:type   owl:Restriction .
        ?restriction owl:someValuesFrom ?someValuesFrom .
        }
}"""

Could someone help me to get the value for the "?someValuesFrom".

Upvotes: 0

Views: 28

Answers (0)

Related Questions