sparql-examples

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

View the Project on GitHub ERDERA/sparql-examples

003

Getting the genetic material linked to more than 10 disorders..

Use at

PREFIX ordo: <http://www.orpha.net/ORDO/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

SELECT ?gene ?geneLab ?nbD
WHERE {
  # Subquery to calculate the count of diseases (?nbD) for each gene (?g)
  {
    SELECT ?g (COUNT(?d) AS ?nbD)
    WHERE {
      ?r owl:onProperty ?rel.
      ?g rdfs:label ?gLabel.
      ?g rdfs:subClassOf ?r.
      ?g rdfs:subClassOf ?class.
      ?class rdfs:subClassOf ?sc.
      FILTER (?sc = ordo:Orphanet_C010)
      ?r owl:someValuesFrom ?d.
    }
    GROUP BY ?g
  }
  # Filter genes with more than 10 diseases
  FILTER (?nbD > 10)

  # Additional bindings in the outer query
  BIND (?g AS ?gene)
  ?gene rdfs:label ?geneLab.
}
ORDER BY DESC(?nbD)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?class")
  v8("?d")
  v5("?g")
  v6("?gLabel")
  v9("?gene"):::projected 
  v10("?geneLab"):::projected 
  v9("?nbD"):::projected 
  v3("?r")
  v4("?rel")
  v2("?sc")
  f0[["?nbD > '10^^xsd:integer'"]]
  f0 --> v9
  f1[["?sc = http://www.orpha.net/ORDO/Orphanet_C010"]]
  f1 --> v2
  v3 --"owl:onProperty"-->  v4
  v5 --"rdfs:label"-->  v6
  v5 --"rdfs:subClassOf"-->  v3
  v5 --"rdfs:subClassOf"-->  v7
  v7 --"rdfs:subClassOf"-->  v2
  v3 --"owl:someValuesFrom"-->  v8
  bind3[/"count(?d)"/]
  v8 --o bind3
  bind3 --as--o v9
  bind4[/"?g"/]
  v5 --o bind4
  bind4 --as--o v9
  v9 --"rdfs:label"-->  v10