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_00272

Proteins involved in coronaviruses/SARS-CoV-2 pathways with associated medical information

Use at

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 (str(?gen) AS ?gene) ?pathwayname (str(?discom) AS ?discom1) ?medsource WHERE {
 SERVICE <http://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"))

 ?pathway dcterms:title ?pathwayname .
 filter(regex(?pathwayname,"sars-cov-2","i")|| regex(?pathwayname,"corona","i") ).
 }

 ?entry a :Entry .
 ?entry :gene / :recommendedName / rdfs:label ?gen .
 ?entry :isoform ?iso.
 ?iso :medical ?med.
 ?med rdfs:comment ?discom.
 ?med :evidence/:assignedBy ?medsource.
}
order by ?entry
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v10("?discom"):::projected 
  v13("?discom1")
  v1("?entry"):::projected 
  v7("?gen"):::projected 
  v12("?gene")
  v5("?geneProduct")
  v6("?genraw")
  v8("?iso")
  v9("?med")
  v11("?medsource"):::projected 
  v3("?organism")
  v7("?pathway")
  v2("?pathwayname"):::projected 
  a1((" "))
  a2((" "))
  a3((" "))
  c8(["wp:Protein"]):::iri 
  c12(["wp:Pathway"]):::iri 
  c9(["wp:GeneProduct"]):::iri 
  c15([":Entry"]):::iri 
  subgraph s1["http://sparql.wikipathways.org/sparql"]
    style s1 stroke-width:4px;
    f0[["(regex(?pathwayname,'sars-cov-2','i') || regex(?pathwayname,'corona','i'))"]]
    f0 --> v2
    f1[["contains(str(?organism),'9606')"]]
    f1 --> v3
    f2[["not regex(?gen,'#91; a-z-#93;')"]]
    f2 --> v7
    subgraph union0[" Union "]
    subgraph union0l[" "]
      style union0l fill:#abf,stroke-dasharray: 3 3;
      v5 --"a"-->  c9
    end
    subgraph union0r[" "]
      style union0r fill:#abf,stroke-dasharray: 3 3;
      v5 --"a"-->  c8
    end
    union0r <== or ==> union0l
    end
    v5 --"rdfs:label"-->  v6
    bind3[/"concat('',?genraw)"/]
    v6 --o bind3
    bind3 --as--o v7
    v5 --"dcterms:isPartOf"-->  v7
    v7 --"a"-->  c12
    v7 --"wp:organism"-->  v3
    v7 --"dcterms:title"-->  v2
  end
  v1 --"a"-->  c15
  v1 --":gene"-->  a1
  a1 --":recommendedName"-->  a2
  a2 --"rdfs:label"-->  v7
  v1 --":isoform"-->  v8
  v8 --":medical"-->  v9
  v9 --"rdfs:comment"-->  v10
  v9 --":evidence"-->  a3
  a3 --":assignedBy"-->  v11
  bind4[/"str(?gen)"/]
  v7 --o bind4
  bind4 --as--o v12
  bind5[/"str(?discom)"/]
  v10 --o bind5
  bind5 --as--o v13