A set of SPARQL examples that are used in different SIB resources
Extracting an UniProtKB primary accession from our IRIs. Is done with a bit of string manipulation. While UniProt primary accession are unique within UniProtKB they may be reused by accident or itentionally by other data sources. If we provided them as strings (not IRI) and if you used them in a query that way, you might accidentaly retrieve completely wrong records.
PREFIX uniprotkb: <http://purl.uniprot.org/uniprot/>
PREFIX up: <http://purl.uniprot.org/core/>
SELECT
?primaryAccession
?protein
WHERE {
?protein a up:Protein .
BIND(substr(str(?protein), strlen(str(uniprotkb:))+1) AS ?primaryAccession)
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?primaryAccession"):::projected
v1("?protein"):::projected
c2(["up:Protein"]):::iri
v1 --"a"--> c2
bind0[/"substring(str(?protein),string-length(str('uniprotkb:')) + '+1^^xsd:integer')"/]
v1 --o bind0
bind0 --as--o v2