sparql-examples

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

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

128_distinct_rhea_in_different_taxons_grouped_by_eco

rq turtle/ttl

Count of unique Rhea reactions/Evidence code pairs annotated in different taxa in Swiss-Prot

Use at


PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>
PREFIX taxon: <http://purl.uniprot.org/taxonomy/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT
  (COUNT(DISTINCT ?rhea) as ?uniqueRheaCount)
  ?taxon
  ?taxonName
  ?eco
WHERE
{
   #Select taxa
   VALUES (?taxon)
   {
     (taxon:9606)  # Homo sapiens
     (taxon:7742)  # Vertebrata
     (taxon:33208) # Metazoa
     (taxon:33090) # Viridiplantae
     (taxon:4751)  # Fungi
     (taxon:2)     # Bacteria
     (taxon:2157)  # Archaea
     (taxon:10239) # Viruses
   }
  ?taxon up:scientificName ?taxonName .
  GRAPH <http://sparql.uniprot.org/taxonomy>{
     ?subc rdfs:subClassOf ?taxon .
   }
  GRAPH <http://sparql.uniprot.org/uniprot>{
    {
      ?protein up:organism ?subc .
    } UNION {
      # Only useful in the Homo sapiens case
      ?protein up:organism ?taxon .
    }
    ?protein up:reviewed true .
    ?protein up:annotation ?annot .
    ?annot up:catalyticActivity ?caa .
    ?caa up:catalyzedReaction ?rhea .
    [] rdf:subject ?annot ;
       rdf:object ?caa ;
       up:attribution/up:evidence ?eco
  }
}
GROUP BY ?taxon ?taxonName ?eco
ORDER BY ?taxonName ?eco
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v6("?annot")
  v7("?caa")
  v2("?eco"):::projected 
  v5("?protein")
  v8("?rhea"):::projected 
  v4("?subc")
  v3("?taxon"):::projected 
  v1("?taxonName"):::projected 
  v9("?uniqueRheaCount")
  a1((" "))
  a2((" "))
  c7(["true^^xsd:boolean"]):::literal 
  bind0[/VALUES ?taxon/]
  bind0-->v3
  bind00(["taxon:9606"])
  bind00 --> bind0
  bind01(["taxon:7742"])
  bind01 --> bind0
  bind02(["taxon:33208"])
  bind02 --> bind0
  bind03(["taxon:33090"])
  bind03 --> bind0
  bind04(["taxon:4751"])
  bind04 --> bind0
  bind05(["taxon:2"])
  bind05 --> bind0
  bind06(["taxon:2157"])
  bind06 --> bind0
  bind07(["taxon:10239"])
  bind07 --> bind0
  v3 --"up:scientificName"-->  v1
  v4 --"rdfs:subClassOf"-->  v3
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v5 --"up:organism"-->  v3
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v5 --"up:organism"-->  v4
  end
  union0r <== or ==> union0l
  end
  v5 --"up:reviewed"-->  c7
  v5 --"up:annotation"-->  v6
  v6 --"up:catalyticActivity"-->  v7
  v7 --"up:catalyzedReaction"-->  v8
  a1 --"rdf:subject"-->  v6
  a1 --"rdf:object"-->  v7
  a1 --"up:attribution"-->  a2
  a2 --"up:evidence"-->  v2
  bind2[/"count(?rhea)"/]
  v8 --o bind2
  bind2 --as--o v9