sparql-examples

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

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

17

Select the average number of cross-references to the PDB database of UniProtKB entries that have at least one cross-reference to the PDB database

Use at

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>

SELECT (AVG(?linksToPdbPerEntry) AS ?avgLinksToPdbPerEntry)
WHERE
{
	SELECT ?protein (COUNT(DISTINCT ?db) AS ?linksToPdbPerEntry)
	WHERE
	{
		?protein a up:Protein .
		?protein rdfs:seeAlso ?db .
		?db up:database <http://purl.uniprot.org/database/PDB> .
	}
	GROUP BY ?protein ORDER BY DESC(?linksToPdbPerEntry)
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?avgLinksToPdbPerEntry")
  v3("?db")
  v4("?linksToPdbPerEntry"):::projected 
  v2("?protein")
  c5([http://purl.uniprot.org/database/PDB]):::iri 
  c2(["up:Protein"]):::iri 
  v2 --"a"-->  c2
  v2 --"rdfs:seeAlso"-->  v3
  v3 --"up:database"-->  c5
  bind1[/"count(?db)"/]
  v3 --o bind1
  bind1 --as--o v4
  bind3[/"average(?linksToPdbPerEntry)"/]
  v4 --o bind3
  bind3 --as--o v4