sparql-examples

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

View the Project on GitHub BiGCAT-UM/sparql-examples

151

rq turtle/ttl

Protein aspect: cointeracting proteins

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q21109365>

SELECT
  ?count
  ?protein ?proteinLabel (CONCAT("/protein/", SUBSTR(STR(?protein), 32)) AS ?proteinUrl)
  ?species ?speciesLabel (CONCAT("/taxon/", SUBSTR(STR(?species), 32)) AS ?speciesUrl)
  ?chemicals
WITH {
  SELECT
    (COUNT(?chemical) AS ?count)
    ?protein
    (GROUP_CONCAT(?chemical_label; separator=" // ") AS ?chemicals)
  WHERE {
    target: wdt:P129 ?chemical .
    FILTER (target: != ?protein)
    ?protein wdt:P129 ?chemical . 
    ?chemical rdfs:label ?chemical_label FILTER(lang(?chemical_label) = "en")
  }
  GROUP BY ?protein
} AS %result 
WHERE {
  INCLUDE %result
  OPTIONAL { ?protein wdt:P703 ?species . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
ORDER BY DESC(?count)
LIMIT 500

graph TD