sparql-examples

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

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

9

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

Use at

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)
FROM <https://rdf.metanetx.org/> 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
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?chem"):::projected 
  v6("?comp"):::projected 
  v10("?count_chem")
  v11("?count_comp")
  v12("?count_pept")
  v9("?count_reac")
  v2("?gpr")
  v1("?mnet"):::projected 
  v4("?part")
  v7("?pept"):::projected 
  v3("?reac"):::projected 
  v8("?taxon"):::projected 
  a1((" "))
  c2(["mnx:MNET"]):::iri 
  v1 --"a"-->  c2
  v1 --"mnx:gpr"-->  v2
  v2 --"mnx:reac"-->  v3
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v3 --"mnx:right"-->  v4
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v3 --"mnx:left"-->  v4
  end
  union0r <== or ==> union0l
  end
  v4 --"mnx:chem"-->  v5
  v4 --"mnx:comp"-->  v6
  v2 --"mnx:cata"-->  a1
  a1 --"mnx:pept"-->  v7
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v1 -."mnx:taxid".->  v8
  end
  bind4[/"count(?reac)"/]
  v3 --o bind4
  bind4 --as--o v9
  bind5[/"count(?chem)"/]
  v5 --o bind5
  bind5 --as--o v10
  bind6[/"count(?comp)"/]
  v6 --o bind6
  bind6 --as--o v11
  bind7[/"count(?pept)"/]
  v7 --o bind7
  bind7 --as--o v12