A set of SPARQL examples that are used in different SIB resources
Proteins with associated pathways in WikiPathways
PREFIX : <http://nextprot.org/rdf/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT DISTINCT ?entry ?gen ?pathwayname WHERE {
SERVICE <https://sparql.wikipathways.org/sparql> {
{?geneProduct a wp:Protein}
union
{?geneProduct a wp:GeneProduct}
?geneProduct rdfs:label ?genraw .
bind (concat( ""^^xsd:string, ?genraw) as ?gen).
filter(!regex(?gen,"[ a-z-]")). # ensures official gene names for subsequent neXtprot matching
?geneProduct dcterms:isPartOf ?pathway .
?pathway a wp:Pathway .
?pathway wp:organism ?organism .
filter(contains(str(?organism),"9606")) # Human proteins
?pathway dcterms:title ?pathwayname .
}
?entry a :Entry .
?entry :gene / :recommendedName / rdfs:label ?gen .
}
order by ?pathwayname
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?entry"):::projected
v6("?gen"):::projected
v4("?geneProduct")
v5("?genraw")
v2("?organism")
v6("?pathway")
v1("?pathwayname"):::projected
a1((" "))
a2((" "))
c5(["wp:Protein"]):::iri
c9(["wp:Pathway"]):::iri
c6(["wp:GeneProduct"]):::iri
c12([":Entry"]):::iri
subgraph s1["https://sparql.wikipathways.org/sparql"]
style s1 stroke-width:4px;
f0[["contains(str(?organism),'9606')"]]
f0 --> v2
f1[["not regex(?gen,'#91; a-z-#93;')"]]
f1 --> v6
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v4 --"a"--> c6
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"a"--> c5
end
union0r <== or ==> union0l
end
v4 --"rdfs:label"--> v5
bind2[/"concat('',?genraw)"/]
v5 --o bind2
bind2 --as--o v6
v4 --"dcterms:isPartOf"--> v6
v6 --"a"--> c9
v6 --"wp:organism"--> v2
v6 --"dcterms:title"--> v1
end
v7 --"a"--> c12
v7 --":gene"--> a1
a1 --":recommendedName"--> a2
a2 --"rdfs:label"--> v6