@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ex: <https://sparql.rhea-db.org/.well-known/sparql-examples/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:65_Number_of_reaction_participants_per_reaction_side a sh:SPARQLExecutable,
    sh:SPARQLSelectExecutable;
  rdfs:comment "Distribution: number of reaction participants per reaction Side"@en ;
  sh:select """PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rh:<http://rdf.rhea-db.org/>

SELECT
  ?reaction
  ?reactionSide1
  (count(distinct ?participant1) as ?side1ParticipantCount)
  ?reactionSide2
  (count(distinct ?participant2) as ?side2ParticipantCount)
WHERE {
  ?reaction rdfs:subClassOf rh:Reaction .
  ?reaction rh:status rh:Approved .

  ?reaction rh:side ?reactionSide1 .
  ?reactionSide1 rh:contains ?participant1 .

  ?reaction rh:side ?reactionSide2 .
  ?reactionSide2 rh:contains ?participant2 .

  ?reactionSide1 rh:transformableTo ?reactionSide2
}
GROUP BY ?reaction ?reactionSide1 ?reactionSide2
ORDER BY ?reaction
""";
  schema:target <https://sparql.rhea-db.org/sparql> .
