sparql-examples

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

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

19

Find all natural variant annotations if associated via an evidence tag to an article with a PubMed identifier

Use at

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX up: <http://purl.uniprot.org/core/>

SELECT 
    ?accession
    ?annotation_acc 
    ?pubmed
WHERE
{
        ?protein a up:Protein ;
            up:annotation ?annotation .
        ?annotation a up:Natural_Variant_Annotation .
        ?linkToEvidence rdf:object ?annotation ;
                        up:attribution ?attribution .
        ?attribution up:source ?source .
        ?source a up:Journal_Citation .
  BIND(SUBSTR(STR(?protein),33) AS ?accession)
  BIND(IF(CONTAINS(STR(?annotation), "#SIP"), SUBSTR(STR(?annotation),33), SUBSTR(STR(?annotation),36))AS?annotation_acc)
  BIND(SUBSTR(STR(?source),35) AS ?pubmed)
}
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v6("?accession"):::projected 
  v2("?annotation")
  v7("?annotation_acc"):::projected 
  v4("?attribution")
  v3("?linkToEvidence")
  v1("?protein")
  v8("?pubmed"):::projected 
  v5("?source")
  c8(["up:Journal_Citation"]):::iri 
  c4(["up:Natural_Variant_Annotation"]):::iri 
  c2(["up:Protein"]):::iri 
  v1 --"a"-->  c2
  v1 --"up:annotation"-->  v2
  v2 --"a"-->  c4
  v3 --"rdf:object"-->  v2
  v3 --"up:attribution"-->  v4
  v4 --"up:source"-->  v5
  v5 --"a"-->  c8
  bind0[/"substring(str(?protein),'33^^xsd:integer')"/]
  v1 --o bind0
  bind0 --as--o v6
  bind1[/"if(contains(str(?annotation),'#SIP'),substring(str(?annotation),'33^^xsd:integer'),substring(str(?annotation),'36^^xsd:integer'))"/]
  v2 --o bind1
  bind1 --as--o v7
  bind2[/"substring(str(?source),'35^^xsd:integer')"/]
  v5 --o bind2
  bind2 --as--o v8