sparql-examples

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

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

19

Find distribution of oxidation reactions catalyzed by genes arranged into several Eukaryota-level orthologous groups annotated with IPR002328 across species in Alveolata, Stramenopiles, Liliopsida and Coleoptera via cooperation with both Uniprot SPARQL endpoint and RHEA SPARQL endpoint

Use at

PREFIX up: <http://purl.uniprot.org/core/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://purl.orthodb.org/>
PREFIX rh: <http://rdf.rhea-db.org/>
PREFIX interpro: <http://www.ebi.ac.uk/interpro/entry/>

SELECT ?og ?equation
    (group_concat (distinct ?clade_name; SEPARATOR="; ") as ?clades)
    (count(distinct ?taxon) as ?cnt_taxons)
    (count(distinct ?gene) as ?cnt_genes)
    (group_concat (distinct ?org_name; SEPARATOR="; ") as ?taxons)
WHERE {
    ?taxon a :Species; up:scientificName ?org_name ;
        rdfs:subClassOf+/up:scientificName ?clade_name.
    ?gene a :Gene ;
        up:organism/a ?taxon.
    ?gene rdfs:seeAlso ?xref.
    ?xref a :Uniprot.
    ?gene :memberOf ?og.
    ?og :xref/:xrefResource interpro:IPR002328 ;
        :ogBuiltAt/up:scientificName "Eukaryota".

    # join via uniprot ?xref
    SERVICE <https://sparql.uniprot.org/sparql> {
        ?xref a up:Protein ;
            up:annotation/up:catalyticActivity/up:catalyzedReaction ?rh .
    }

    # join via reaction ?rh
    SERVICE <https://sparql.rhea-db.org/sparql> {
        ?rh rdfs:subClassOf rh:Reaction ;
            rh:equation ?equation.
    }

    # restrict taxons to several clades
    VALUES ?clade_name {
        "Stramenopiles"
        "Alveolata"
        "Liliopsida"
        "Coleoptera"
    }
} GROUP BY ?equation ?og ORDER BY ?og ?equation
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v9("?clade_name"):::projected 
  v9("?clades")
  v11("?cnt_genes")
  v10("?cnt_taxons")
  v2("?equation"):::projected 
  v6("?gene"):::projected 
  v1("?og"):::projected 
  v4("?org_name"):::projected 
  v8("?rh")
  v3("?taxon"):::projected 
  v12("?taxons")
  v7("?xref")
  a1((" "))
  a2((" "))
  a3((" "))
  a4((" "))
  a5((" "))
  a6((" "))
  c5([":Gene"]):::iri 
  c12(["interpro:IPR002328"]):::iri 
  c8([":Uniprot"]):::iri 
  c14(["Eukaryota"]):::literal 
  c2([":Species"]):::iri 
  c21(["rh:Reaction"]):::iri 
  c16(["up:Protein"]):::iri 
  v3 --"a"-->  c2
  v3 --"up:scientificName"-->  v4
  v3 --"rdfs:subClassOf"-->  a1
  a1 --"up:scientificName"-->  v9
  v6 --"a"-->  c5
  v6 --"up:organism"-->  a2
  a2 --"a"-->  v3
  v6 --"rdfs:seeAlso"-->  v7
  v7 --"a"-->  c8
  v6 --":memberOf"-->  v1
  v1 --":xref"-->  a3
  a3 --":xrefResource"-->  c12
  v1 --":ogBuiltAt"-->  a4
  a4 --"up:scientificName"-->  c14
  subgraph s1["https://sparql.uniprot.org/sparql"]
    style s1 stroke-width:4px;
    v7 --"a"-->  c16
    v7 --"up:annotation"-->  a5
    a5 --"up:catalyticActivity"-->  a6
    a6 --"up:catalyzedReaction"-->  v8
  end
  subgraph s2["https://sparql.rhea-db.org/sparql"]
    style s2 stroke-width:4px;
    v8 --"rdfs:subClassOf"-->  c21
    v8 --"rh:equation"-->  v2
  end
  bind0[/VALUES ?clade_name/]
  bind0-->v9
  bind00(["Stramenopiles"])
  bind00 --> bind0
  bind01(["Alveolata"])
  bind01 --> bind0
  bind02(["Liliopsida"])
  bind02 --> bind0
  bind03(["Coleoptera"])
  bind03 --> bind0
  bind5[/"?clade_name"/]
  v9 --o bind5
  bind5 --as--o v9
  bind6[/"count(?taxon)"/]
  v3 --o bind6
  bind6 --as--o v10
  bind7[/"count(?gene)"/]
  v6 --o bind7
  bind7 --as--o v11
  bind8[/"?org_name"/]
  v4 --o bind8
  bind8 --as--o v12