sparql-examples

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

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

68_Select_reaction_participants_that_appear_in_only_one_reaction

rq turtle/ttl

Select reaction participants that appear in only one reaction

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>

SELECT
  ?compound
  ?compoundAc
  ?compoundName
WHERE {
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction rh:status rh:Approved .
  ?reaction rh:side ?reactionSide .
  ?reactionSide rh:contains ?participant .
  ?participant rh:compound ?compound .
  ?compound rh:name ?compoundName .
  ?compound rh:accession ?compoundAc .
}
GROUP BY ?compound ?compoundName ?compoundAc
HAVING (count(distinct ?reaction) = 1)
ORDER BY ?compoundAc
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?_anon_3b93fb9548914f3581febfeabf3844491212")
  v5("?compound"):::projected 
  v1("?compoundAc"):::projected 
  v6("?compoundName"):::projected 
  v4("?participant")
  v2("?reaction")
  v3("?reactionSide")
  a1((" "))
  c5(["rh:Approved"]):::iri 
  c3(["rh:Reaction"]):::iri 
  f0[[" = '1^^xsd:integer'"]]
  f0 --> a1
  v2 --"rdfs:subClassOf"-->  c3
  v2 --"rh:status"-->  c5
  v2 --"rh:side"-->  v3
  v3 --"rh:contains"-->  v4
  v4 --"rh:compound"-->  v5
  v5 --"rh:name"-->  v6
  v5 --"rh:accession"-->  v1
  bind2[/"count(?reaction)"/]
  v2 --o bind2
  bind2 --as--o v7