I'm trying to perform an ontology matching task using two anatomy ontologies in rdf format (using rdflib). All of the organs in the ontology have their own classes, and they are grouped with superclasses such as "reproductive system part", for example. What I want is to run a query that retrieves all of the nodes connected to a certain class, both inbound and outbound connections. I tried the following:
querytrial1=graph.query("""SELECT ?node ?nodeLabel ?othernodes ?othernodesLabel where {
?node ?y ?othernodes .
?node rdfs:label ?nodeLabel .
?othernodes rdfs:label ?othernodesLabel
}
LIMIT 100""")
and then this for the inbound connections:
querytrial2=graph.query("""SELECT ?node ?nodeLabel ?othernode2 ?othernodeLabel2 where {
?othernodes2 ?z ?node .
?node rdfs:label ?nodeLabel .
?othernodes2 rdfs:label ?othernodes2Label
}
LIMIT 100""")
The first one only returns some of the desired connections. It doesn't return the node listed in the class restriction:
It returns the subClassOf, but not the property restriction and the someValuesFrom: class.
Is there a way to run a query and get the node cited in the property restriction?
Any advice would be much appreciated. I've attached the ontology in case anyone would like to look at it.