A set of SPARQL examples that are used in different SIB resources
Example (sample) of a cross-reference with its properties from each database
PREFIX cello: <https://purl.expasy.org/cellosaurus/rdf/ontology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
select ?db_class ?db (sample(?ac) as ?sample_ac) (sample(?disc) as ?sample_disc) (sample(?lbl) as ?sample_label) (sample(?url) as ?sample_url) where {
?xref a cello:Xref .
?xref cello:database ?db.
?xref cello:accession ?ac.
?db a ?db_class .
?db_class rdfs:subClassOf cello:Database . # (useful to get rid of irrelevant owl:NamedIndividual)
optional { ?xref cello:discontinued ?disc }.
optional { ?xref rdfs:label ?lbl }.
optional { ?xref rdfs:seeAlso ?url } .
# filter (bound(?disc)) # uncomment to see xrefs identifying a discontinued product reference in a catalog
# filter (bound(?lbl)) # uncomment to see xrefs having a label (genes, chemicals, anatomy, ...)
# filter (! bound(?url)) # uncomment to see xrefs having NO url (discontinued products, ...)
}
group by ?db_class ?db
order by ?db_class ?db
limit 300
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?ac"):::projected
v2("?db"):::projected
v1("?db_class"):::projected
v5("?disc"):::projected
v6("?lbl"):::projected
v8("?sample_ac")
v9("?sample_disc")
v10("?sample_label")
v11("?sample_url")
v7("?url"):::projected
v3("?xref")
c2(["cello:Xref"]):::iri
c6(["cello:Database"]):::iri
v3 --"a"--> c2
v3 --"cello:database"--> v2
v3 --"cello:accession"--> v4
v2 --"a"--> v1
v1 --"rdfs:subClassOf"--> c6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."cello:discontinued".-> v5
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."rdfs:label".-> v6
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."rdfs:seeAlso".-> v7
end
bind4[/"sample(?ac)"/]
v4 --o bind4
bind4 --as--o v8
bind5[/"sample(?disc)"/]
v5 --o bind5
bind5 --as--o v9
bind6[/"sample(?lbl)"/]
v6 --o bind6
bind6 --as--o v10
bind7[/"sample(?url)"/]
v7 --o bind7
bind7 --as--o v11