sparql-examples

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

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

150

rq turtle/ttl

Protein aspect: cofunctional 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 ?species ?speciesLabel ?functions
WITH {
  SELECT ?protein (COUNT(?function) AS ?count)
         (GROUP_CONCAT(?function_label; separator=" // ") AS ?functions)
  WHERE {
    BIND(target: AS ?query_protein)
    ?query_protein wdt:P680 ?function .
    FILTER (?query_protein != ?protein)
    ?protein wdt:P680 ?function . 
    ?function rdfs:label ?function_label FILTER(lang(?function_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