@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:9 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "List all GEMs currently in the MetaNetX repository, with their numbers of reactions, chemical, compartments and genes/proteins."@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX mnx: <https://rdf.metanetx.org/schema/>

# List all GEMs currently in the MetaNetX repository, with
# their numbers of reactions, chemical, compartments and
# genes/proteins.

SELECT ?mnet ?taxon
    (COUNT( DISTINCT ?reac) AS ?count_reac)
    (COUNT( DISTINCT ?chem) AS ?count_chem)
    (COUNT( DISTINCT ?comp) AS ?count_comp)
    (COUNT( DISTINCT ?pept) AS ?count_pept)
WHERE{
    ?mnet a mnx:MNET .
    ?mnet mnx:gpr  ?gpr .
    ?gpr  mnx:reac ?reac .
    ?reac mnx:left|mnx:right ?part .
    ?part mnx:chem ?chem;
          mnx:comp ?comp.
    ?gpr mnx:cata/mnx:pept ?pept .
    OPTIONAL{ ?mnet mnx:taxid ?taxon }
} GROUP BY ?mnet ?taxon""" ;
    schema:target <https://rdf.metanetx.org/sparql/> .

