Reputation:
I'm new to SPARQL. I would like to get the preferred name of classes and their one top level upper classes and also their synonyms in the Radlex ontology, as hosted at BioPortal.
And The Output I want to see: output
Term: equal density subClassOf: density descriptor Synonym: isodens, equal-density,isodense
It looks like, the code below solved my problem, but still requires some modification. Because, it brings all off the upper classes but I only want one level upper class.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?concept ?subClassOf
WHERE
{ GRAPH <http://bioportal.bioontology.org/ontologies/RADLEX_OWL>
{ ?term a <http://bioontology.org/projects/ontologies/radlex/radlexOwl#radlex_metaclass> ;
<http://bioontology.org/projects/ontologies/radlex/radlexOwl#Preferred_name> ?concept
}
?term rdfs:subClassOf ?upperClass.
?upperClass <http://bioontology.org/projects/ontologies/radlex/radlexOwl#Preferred_name> ?subClassOf.
} LIMIT 10 OFFSET 10
Upvotes: 0
Views: 481
Reputation:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX radlex: <http://bioontology.org/projects/ontologies/radlex/radlexOwlDlComponent#>
SELECT DISTINCT ?term ?name ?synonym ?subClassOf ?subClassOf_name
FROM <http://bioportal.bioontology.org/ontologies/RID>
WHERE
{
?term radlex:Preferred_name ?name .
?term radlex:Synonym ?synonym .
?term rdfs:subClassOf ?subClassOf .
?subClassOf radlex:Preferred_name ?subClassOf_name
} LIMIT 10
Upvotes: 0
Reputation: 3096
It looks like one of your main struggles is finding where to start, or how to specify the root of the Radlex subclasses.
I have no experience with Radlex, and I haven't been using Bioportal much recently. When I opened the Radlex ontology in Protege, its class hierarchy looked reasonable to me. But the results from the Bioportal endpoint are surprising.
For example, RID5635 "coin" is a subclass of RID5633 "personal item", and is an instance of radlex_metaclass, but not an instance of owl:Class, as I would expect from using OBO foundry ontologies. It doesn't look like all of the Radlex subclasses come from the radlex_metaclass, so that makes it trickier to get all of the subclasses with a single triple pattern like
?s a owl:Class
It also doesn't look like the Bioportal endpoint supports RDFS property paths, so we can't ask for
?s a rdfs:subClassOf* <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID1>
Therefore, I can't guarantee that this query returns all of the subclasses in Radlex... just all of the immediate subclasses of radlex_metaclass
Finally, as AKSW pointed out, http://bioontology.org/projects/ontologies/radlex/radlexOwl# is the name of the ontology, not a superclass. It doesn't have subclasses and is not a solution to the root finding problem I described at the top of this answer.
I added a named graph restriction, but that probably isn't doing anything that isn't already done by asking for http://bioontology.org/projects/ontologies/radlex/radlexOwl#radlex_metaclass instances.
SELECT DISTINCT *
WHERE
{ GRAPH <http://bioportal.bioontology.org/ontologies/RADLEX_OWL>
{ ?radlexclass a <http://bioontology.org/projects/ontologies/radlex/radlexOwl#radlex_metaclass> ;
<http://bioontology.org/projects/ontologies/radlex/radlexOwl#Preferred_name> ?prefName
}
}
gives results like this
+------------------------------------------------------------------------+---------------------------------------------------------------------+
| radlexclass | prefName |
+------------------------------------------------------------------------+---------------------------------------------------------------------+
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID19012> | "posterior root of left first sacral nerve" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID23593> | "nerve to third posterior cervical intertransversarius" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID11053> | "hydrophilic wire" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID5825> | "right" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID18947> | "posterior root of sixth cervical nerve" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID16116> | "set of short association fibers of telencephalon" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID23701> | "left third thoracic nerve" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID23274> | "ascending branch of meningeal branch of right second sacral nerve" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID25244> | "right intermediomedial nucleus" |
| <http://bioontology.org/projects/ontologies/radlex/radlexOwl#RID5699> | "coalescent" |
+------------------------------------------------------------------------+---------------------------------------------------------------------+
etc.
Upvotes: 3