Query subclass relations from NCBI taxonomy

Here's an example query where we want to extract all the subclass superclass relations given a particular class. In this case the class we are querying is Mus which is NCBI Taxon id 10088. This query is used for OBI to retrieve enough information to effectively use a Taxon id that has been requested to be available by OBI users, without importing all of the NCBI taxonomy.

We use two graphs, one with the inferred superclasses, so that we can retrieve all the superclasses given a taxon, and containing only the stated relations, so that we can get the direct subclass/superclass links. The UNION is used to retrieve the link from the supplied term to it's direct superclass, as the inferred graph is created by transitive closure of subClassOf, and so doesn't return the query class - even though in OWL every class is a subclass of itself.

See the Neurocommons development instance page for information about how the taxonomy was loaded and the inferred graph computed.

Click here to run the query now.

prefix rdfs:  prefix tax:  select ?sub ?sublabel ?super ?superlabel from  where {   { graph  { tax:_10088 rdfs:subClassOf ?sub. }   { ?sub rdfs:subClassOf ?super. ?sub rdfs:label ?sublabel. ?super rdfs:label ?superlabel }  }   UNION {    ?sub rdfs:subClassOf ?super. ?sub rdfs:label ?sublabel. ?super rdfs:label ?superlabel FILTER (?sub = tax:_10088) } }