sparql-examples

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

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

87_taxonomy_with_at_least_one_swissprot

Find taxon records for which one reviewed UniProtKB/Swiss-Prot entry exists. We might expect species, strains, subspecies and isolates in the taxon list.

Use at

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


SELECT
    DISTINCT
         ?taxid
         ?scientificName
         ?domain
         ?domainName
WHERE {
  ?uniprot a up:Protein .
  # reviewed entries
  ?uniprot up:reviewed true .
  ?uniprot up:organism ?taxid . 
  ?taxid up:scientificName ?scientificName .
    
  VALUES ?domain { taxon:2 # bacteria
                   taxon:2157 # archaea
                   taxon:2759 # eukaryota
                   taxon:10239 #viruses
                 } .
  ?taxid rdfs:subClassOf ?domain .
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v4("?domain"):::projected 
  v3("?scientificName"):::projected 
  v2("?taxid"):::projected 
  v1("?uniprot")
  c4(["true^^xsd:boolean"]):::literal 
  c2(["up:Protein"]):::iri 
  v1 --"a"-->  c2
  v1 --"up:reviewed"-->  c4
  v1 --"up:organism"-->  v2
  v2 --"up:scientificName"-->  v3
  bind0[/VALUES ?domain/]
  bind0-->v4
  bind00(["taxon:2"])
  bind00 --> bind0
  bind01(["taxon:2157"])
  bind01 --> bind0
  bind02(["taxon:2759"])
  bind02 --> bind0
  bind03(["taxon:10239"])
  bind03 --> bind0
  v2 --"rdfs:subClassOf"-->  v4