Order by subclass SPARQL
1
3
Entering edit mode
9.2 years ago
JJK ▴ 60

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 • 2.6k views
ADD COMMENT
4
Entering edit mode
9.2 years ago
me ▴ 760

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.

ADD COMMENT

Login before adding your answer.

Traffic: 1514 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6