A set of SPARQL examples that are used in different SIB resources
For two accession numbers (ACs) find the GO term labels and group them into GO process,function and component
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX GO:<http://purl.obolibrary.org/obo/GO_>
SELECT
(CONCAT(SUBSTR(STR(?protein), 33)) AS ?uniprot)
(GROUP_CONCAT(?celtype; separator=";") AS ?celtypes)
(GROUP_CONCAT(?biotype; separator=";") AS ?biotypes)
(GROUP_CONCAT(?moltype; separator=";") AS ?moltypes)
WHERE
{
VALUES (?ac) {("Q6GZX4") ("Q96375")}
BIND (IRI(CONCAT("http://purl.uniprot.org/uniprot/",?ac)) AS ?protein)
?protein a up:Protein .
?protein up:classifiedWith ?goTerm .
#Determine if the type is biological_process
OPTIONAL {
?goTerm rdfs:subClassOf GO:0008150 .
?goTerm rdfs:label ?biotype .
}
#Determine if the type is cellular_component
OPTIONAL {
?goTerm rdfs:subClassOf GO:0005575 .
?goTerm rdfs:label ?celtype .
}
#Determine if the type is molecular_function
OPTIONAL {
?goTerm rdfs:subClassOf GO:0003674 .
?goTerm rdfs:label ?moltype .
}
#Filter out the uniprot keywords
FILTER(bound(?biotype) || bound(?celtype) || bound(?moltype))
} GROUP BY ?protein
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?ac")
v1("?biotype"):::projected
v9("?biotypes")
v2("?celtype"):::projected
v8("?celtypes")
v6("?goTerm")
v3("?moltype"):::projected
v10("?moltypes")
v5("?protein"):::projected
v7("?uniprot")
c5(["GO:0008150"]):::iri
c8(["GO:0003674"]):::iri
c7(["GO:0005575"]):::iri
c2(["up:Protein"]):::iri
f0[["(bound(?biotype) || (bound(?celtype) || bound(?moltype)))"]]
f0 --> v1
f0 --> v2
f0 --> v3
bind1[/VALUES ?ac/]
bind1-->v4
bind10(["Q6GZX4"])
bind10 --> bind1
bind11(["Q96375"])
bind11 --> bind1
bind2[/"concat('http://purl.uniprot.org/uniprot/',?ac)"/]
v4 --o bind2
bind2 --as--o v5
v5 --"a"--> c2
v5 --"up:classifiedWith"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:subClassOf".-> c5
v6 --"rdfs:label"--> v1
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:subClassOf".-> c7
v6 --"rdfs:label"--> v2
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v6 -."rdfs:subClassOf".-> c8
v6 --"rdfs:label"--> v3
end
bind6[/"concat(substring(str(?protein),'33^^xsd:integer'))"/]
v5 --o bind6
bind6 --as--o v7
bind7[/"?celtype"/]
v2 --o bind7
bind7 --as--o v8
bind8[/"?biotype"/]
v1 --o bind8
bind8 --as--o v9
bind9[/"?moltype"/]
v3 --o bind9
bind9 --as--o v10