sparql-examples

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

View the Project on GitHub ytirlet/sparql-examples

M67_protein_to_taxon

rq turtle/ttl

Protein to taxon

Use at

PREFIX up: <http://purl.uniprot.org/core/>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT
 ?protein ?organism
WHERE {
 {
   BIND(?taxon AS ?organism)
   ?protein up:organism ?organism .
 } UNION {
   ?protein up:organism ?organism .
   ?organism rdfs:subClassOf ?taxon .
 }
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v1("?organism"):::projected 
  v2("?protein"):::projected 
  v3("?taxon")
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v2 --"up:organism"-->  v1
    v1 --"rdfs:subClassOf"-->  v3
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    bind0[/"?taxon"/]
    v3 --o bind0
    bind0 --as--o v1
    v2 --"up:organism"-->  v1
  end
  union0r <== or ==> union0l
  end