sparql-examples

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

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

126_count_venom_related_proteins

rq turtle/ttl

Count the number of entries that are annotated to be related to venomous activity in selected taxonomic groups

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/>
PREFIX location: <http://purl.uniprot.org/locations/>
SELECT
  (COUNT(DISTINCT ?protein) AS ?proteins)
  ?grouping
  ?groupingScientificName
WHERE
{
  VALUES ?grouping {
    taxon:6103 #sea anemones
    taxon:8570 #snakes
    taxon:6855 #scorpions
    taxon:6893 #Araneae
    taxon:50557 #Insecta
    taxon:37797 #Conoidea
  }
  ?grouping up:scientificName ?groupingScientificName .
  ?taxon rdfs:subClassOf ?grouping.
  ?protein up:organism ?taxon .
  {
    ?protein up:annotation ?tsa .
    ?tsa a up:Tissue_Specificity_Annotation ;
           rdfs:comment ?tsac .
     FILTER(REGEX(?tsac, 'venom', 'i'))
  } UNION {
   ?protein up:annotation ?scla .
   # location:177 is nematocyst
   ?scla a up:Subcellular_Location_Annotation ;
          up:locatedIn/up:cellularComponent location:177 .
  }
}
GROUP BY ?grouping ?groupingScientificName
ORDER BY ?proteins
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?grouping"):::projected 
  v3("?groupingScientificName"):::projected 
  v5("?protein"):::projected 
  v9("?proteins")
  v8("?scla")
  v4("?taxon")
  v7("?tsa")
  v6("?tsac")
  a1((" "))
  c8(["up:Tissue_Specificity_Annotation"]):::iri 
  c10(["up:Subcellular_Location_Annotation"]):::iri 
  c13([http://purl.uniprot.org/locations/177]):::iri 
  bind0[/VALUES ?grouping/]
  bind0-->v2
  bind00(["taxon:6103"])
  bind00 --> bind0
  bind01(["taxon:8570"])
  bind01 --> bind0
  bind02(["taxon:6855"])
  bind02 --> bind0
  bind03(["taxon:6893"])
  bind03 --> bind0
  bind04(["taxon:50557"])
  bind04 --> bind0
  bind05(["taxon:37797"])
  bind05 --> bind0
  v2 --"up:scientificName"-->  v3
  v4 --"rdfs:subClassOf"-->  v2
  v5 --"up:organism"-->  v4
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v5 --"up:annotation"-->  v8
    v8 --"a"-->  c10
    v8 --"up:locatedIn"-->  a1
    a1 --"up:cellularComponent"-->  c13
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    f1[["regex(?tsac,'venom','i')"]]
    f1 --> v6
    v5 --"up:annotation"-->  v7
    v7 --"a"-->  c8
    v7 --"rdfs:comment"-->  v6
  end
  union0r <== or ==> union0l
  end
  bind3[/"count(?protein)"/]
  v5 --o bind3
  bind3 --as--o v9