sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

neXtProt/NXQ_00253

Human pathways in which at least one protein is mitochondrial GOLD

Use at

PREFIX : <http://nextprot.org/rdf/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX nextprot_cv: <http://nextprot.org/rdf/terminology/>
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 ?pathwayname (group_concat(distinct ?gen ; SEPARATOR = ',') as ?gene) WHERE {
 SERVICE <https://sparql.wikipathways.org/sparql> {

 { ?geneProduct a wp:GeneProduct . }
 union
 { ?geneProduct a wp:Protein . }
 ?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"))
 ?pathway dcterms:title ?pathwayname .
 }

 ?entry a :Entry .
 ?entry :gene / :recommendedName / rdfs:label ?gen .
 ?entry :isoform / :cellularComponent ?loc .
 values ?mitoloc {nextprot_cv:SL-0173 nextprot_cv:GO_0005739 } # SL and GO values for mitochondrion
 ?loc :term / :childOf ?mitoloc. # mitochondrion
 ?loc :evidence / :quality :GOLD .
 filter not exists {?loc :negativeEvidence ?negev} # No negative localization evidence
}
group by ?pathwayname
order by ?pathwayname
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v9("?entry")
  v8("?gen"):::projected 
  v11("?gene")
  v6("?geneProduct")
  v7("?genraw")
  v2("?loc")
  v10("?mitoloc")
  v3("?negev")
  v4("?organism")
  v8("?pathway")
  v1("?pathwayname"):::projected 
  a1((" "))
  a2((" "))
  a3((" "))
  a4((" "))
  a5((" "))
  c7(["wp:Protein"]):::iri 
  c10(["wp:Pathway"]):::iri 
  c6(["wp:GeneProduct"]):::iri 
  c13([":Entry"]):::iri 
  c22([":GOLD"]):::iri 
  f0[["not  "]]
  subgraph f0e0["Exists Clause"]
    e0v1 --":negativeEvidence"-->  e0v2
    e0v1("?loc"):::projected 
    e0v2("?negev"):::projected 
  end
  f0--EXISTS--> f0e0
  f0 --> v2
  f0 --> c1
  f0 --> v3
  v2 --":negativeEvidence"-->  v3
  subgraph s1["https://sparql.wikipathways.org/sparql"]
    style s1 stroke-width:4px;
    f1[["contains(str(?organism),'9606')"]]
    f1 --> v4
    f2[["not regex(?gen,'#91; a-z-#93;')"]]
    f2 --> v8
    subgraph union0[" Union "]
    subgraph union0l[" "]
      style union0l fill:#abf,stroke-dasharray: 3 3;
      v6 --"a"-->  c7
    end
    subgraph union0r[" "]
      style union0r fill:#abf,stroke-dasharray: 3 3;
      v6 --"a"-->  c6
    end
    union0r <== or ==> union0l
    end
    v6 --"rdfs:label"-->  v7
    bind3[/"concat('',?genraw)"/]
    v7 --o bind3
    bind3 --as--o v8
    v6 --"dcterms:isPartOf"-->  v8
    v8 --"a"-->  c10
    v8 --"wp:organism"-->  v4
    v8 --"dcterms:title"-->  v1
  end
  v9 --"a"-->  c13
  v9 --":gene"-->  a1
  a1 --":recommendedName"-->  a2
  a2 --"rdfs:label"-->  v8
  v9 --":isoform"-->  a3
  a3 --":cellularComponent"-->  v2
  bind4[/VALUES ?mitoloc/]
  bind4-->v10
  bind40([":terminology/SL-0173"])
  bind40 --> bind4
  bind41([":terminology/GO_0005739"])
  bind41 --> bind4
  v2 --":term"-->  a4
  a4 --":childOf"-->  v10
  v2 --":evidence"-->  a5
  a5 --":quality"-->  c22
  bind6[/"?gen"/]
  v8 --o bind6
  bind6 --as--o v11