183_protein_count_by_clade_single_hop
- taxonomy
- clade
- aggregation
Compare the number of reviewed proteins in two named taxonomic clades (Primates, Rodentia), using a single-hop ?organism rdfs:subClassOf ?clade rather than the transitive rdfs:subClassOf+ or rdfs:subClassOf* form. UniProt's taxonomy is pre-flattened: every taxon carries a direct rdfs:subClassOf edge to every one of its ancestors, not only its immediate parent (verified live: taxon 9606, Homo sapiens, has 30 direct rdfs:subClassOf triples, one per ancestor up to cellular organisms), so a single hop already reaches every member of a clade at any depth and is far cheaper than the transitive path
Use at
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT
?clade
?cladeName
(COUNT(DISTINCT ?protein) AS ?proteinCount)
WHERE {
VALUES ?clade { <http://purl.uniprot.org/taxonomy/9443> <http://purl.uniprot.org/taxonomy/9989> }
?clade up:scientificName ?cladeName .
?protein up:reviewed true ;
up:organism ?organism .
?organism rdfs:subClassOf ?clade .
}
GROUP BY ?clade ?cladeName
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?clade"):::projected
v2("?cladeName"):::projected
v4("?organism")
v3("?protein"):::projected
v5("?proteinCount")
c3(["true^^xsd:boolean"]):::literal
bind0[/VALUES ?clade/]
bind0-->v1
bind00([http://purl.uniprot.org/taxonomy/9443])
bind00 --> bind0
bind01([http://purl.uniprot.org/taxonomy/9989])
bind01 --> bind0
v1 --"up:scientificName"--> v2
v3 --"up:reviewed"--> c3
v3 --"up:organism"--> v4
v4 --"rdfs:subClassOf"--> v1
bind2[/"count(?protein)"/]
v3 --o bind2
bind2 --as--o v5