@prefix ex: <https://sparql.metanetx.org/.well-known/sparql-examples/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:8 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Show the reaction equation for ATP synthase (reaction ATPS4m from BiGG). NB: there are two types of protons here, as MetaNetX distinguishes protons used for balancing (MNXM1) from those that are translocated (MNXM01)."@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX biggR: <https://identifiers.org/bigg.reaction:>
PREFIX mnx: <https://rdf.metanetx.org/schema/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

# Show the reaction equation for ATP synthase (reaction
# *ATPS4m* from BiGG). NB: there are two types of protons
# here, as MetaNetX distinguishes protons used for balancing
# (MNXM1) from those that are translocated (MNXM01).

SELECT ?chem ?chem_name ?comp ?comp_name $coef
WHERE{
    ?reaction mnx:reacXref biggR:ATPS4m .
    ?reaction ?side ?part .
    ?part mnx:chem ?chem ;
          mnx:comp ?comp ;
          mnx:coef ?c    .
    ?chem rdfs:comment ?chem_name .
    ?comp rdfs:comment ?comp_name .
    FILTER( ?side IN ( mnx:left , mnx:right ))
    BIND( IF( ?side = mnx:left, - ?c, ?c ) AS ?coef )
}""" ;
    schema:target <https://rdf.metanetx.org/sparql/> .

