This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Order by subclass SPARQL

I have seen some posts about using the uniprot and the spraql endpoint to retrieve either all species belonging to a rank or identify what the parent class is of a species.

For example the following query will retrieve the lineage of a given organism

PREFIX up:<http://purl.uniprot.org/core/>
PREFIX taxon:<http://purl.uniprot.org/taxonomy/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT ?taxon ?name
WHERE
{
    ?taxon a up:Taxon .
    ?taxon up:scientificName ?name .
    taxon:1314 rdfs:subClassOf+ ?taxon .
}

However is there a way to order them by their subclass tree? I can always ask for 1 level up and then query again and again until I reach the ceiling or floor but there might be a more efficient way?

rdf subclassof sparql

1 answer

You can order by rank

PREFIX up:<http://purl.uniprot.org/core/>
PREFIX taxon:<http://purl.uniprot.org/taxonomy/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT ?taxon ?name ?rank
WHERE
{
    ?taxon a up:Taxon .
    ?taxon up:scientificName ?name .
    taxon:1314 rdfs:subClassOf ?taxon .
    ?taxon up:rank ?rank .
} ORDER BY ?rank

I am not sure what you mean by subtree. i.e. could you make some ascii art with the expected output.

Log in to answer this question.