Community-curated SPARQL example queries for multiple life-science endpoints.
Federated query connecting specimens in a natural-history collection (GBIF, institution code BR) to sequence data for the same species in UniProt. It reconstructs each specimen's canonical binomial from atomised Darwin Core fields (genericName + specificEpithet, since rdfs:label carries authorship) and matches it to UniProt's scientificName via a SERVICE call, returning the UniProt/NCBI taxon ID, a protein count, and the protein IRIs.
The link is taxon-level, not specimen-level: it shows that a species in the collection has molecular data in UniProt — not that any sequence was derived from these particular specimens. Establishing that true voucher link (specimen ↔ sequence) requires matching the Darwin Core triplet (institutionCode:catalogNumber) against a sequence record's specimen_voucher field, which lives in ENA/INSDC and is not part of this federation. This query therefore answers a scoping question: which collection taxa already have molecular data, and how much? — quantifying both the opportunity and the backlog.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dwc: <http://rs.tdwg.org/dwc/terms/>
PREFIX dwciri: <http://rs.tdwg.org/dwc/iri/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT ?species ?taxon
(COUNT(DISTINCT ?protein) AS ?protein_count)
(GROUP_CONCAT(STR(?protein); SEPARATOR=",") AS ?proteins)
WHERE {
{
SELECT DISTINCT ?species WHERE {
?occ dwc:institutionCode "BR" ; dwciri:toTaxon ?t .
?t dwc:genericName ?genus ; dwc:specificEpithet ?epithet .
BIND(CONCAT(STR(?genus), " ", STR(?epithet)) AS ?species)
}
}
SERVICE <https://qlever.cs.uni-freiburg.de/api/uniprot> {
?taxon up:scientificName ?species .
OPTIONAL { ?protein up:organism ?taxon }
}
}
GROUP BY ?species ?taxon
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?epithet")
v3("?genus")
v1("?occ")
v7("?protein"):::projected
v8("?protein_count")
v9("?proteins")
v5("?species"):::projected
v2("?t")
v6("?taxon"):::projected
c2(["BR"]):::literal
v1 --http://rs.tdwg.org/dwc/terms/institutionCode--> c2
v1 --http://rs.tdwg.org/dwc/iri/toTaxon--> v2
v2 --http://rs.tdwg.org/dwc/terms/genericName--> v3
v2 --http://rs.tdwg.org/dwc/terms/specificEpithet--> v4
bind0[/"concat(str(?genus),' ',str(?epithet))"/]
v3 --o bind0
v4 --o bind0
bind0 --as--o v5
subgraph s1["https://qlever.cs.uni-freiburg.de/api/uniprot"]
style s1 stroke-width:4px;
v6 --"up:scientificName"--> v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v7 -."up:organism".-> v6
end
end
bind3[/"count(?protein)"/]
v7 --o bind3
bind3 --as--o v8
bind4[/"str(?protein)"/]
v7 --o bind4
bind4 --as--o v9