sparql-examples

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

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

neXtProt/NXQ_00265

Retrieve all positional annotations at a given position on a neXtProt isoform

Use at

PREFIX : <http://nextprot.org/rdf/>
PREFIX isoform: <http://nextprot.org/rdf/isoform/>
PREFIX nextprot_cv: <http://nextprot.org/rdf/terminology/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?iso ?spos ?epos ?annot_type (str(?txt) as ?note) where
{
 values ?iso { isoform:NX_Q99728-1 }
 values ?poi {107} # position of interest

{
 ?iso :positionalAnnotation ?statement . optional {?statement rdfs:comment ?txt .}

 ?statement a ?annot_type .
 ?statement :start ?spos; :end ?epos .
}
 union

{
 ?iso :proteoform ?pf .
 ?pf :difference ?varmut; :phenotypicVariation ?phvar .
 ?varmut :start ?spos; :end ?epos.
 ?phvar :term ?phtype; :impactedObject /:term /rdfs:label ?ioTermlab .
 ?phvar a ?annot_type .
 ?phtype :childOf nextprot_cv:ME_0000002; rdfs:label ?effect . # children of impact
 bind (concat(CONCAT(?effect," "),?ioTermlab) as ?txt) }

 filter((?spos <= ?poi) && (?epos >= ?poi)) # select annotations encompassing the position of interest
} order by ?spos
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v7("?annot_type"):::projected 
  v13("?effect")
  v3("?epos"):::projected 
  v12("?ioTermlab")
  v4("?iso"):::projected 
  v14("?note")
  v8("?pf")
  v11("?phtype")
  v10("?phvar")
  v5("?poi")
  v1("?spos"):::projected 
  v5("?statement")
  v14("?txt"):::projected 
  v9("?varmut")
  a1((" "))
  a2((" "))
  c13([":terminology/ME_0000002"]):::iri 
  f0[["?spos <= ?poi?epos >= ?poi"]]
  f0 --> v1
  f0 --> v5
  f0 --> v3
  bind1[/VALUES ?iso/]
  bind1-->v4
  bind10([":isoform/NX_Q99728-1"])
  bind10 --> bind1
  bind2[/VALUES ?poi/]
  bind2-->v5
  bind20(["107^^xsd:integer"])
  bind20 --> bind2
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v4 --":proteoform"-->  v8
    v8 --":difference"-->  v9
    v8 --":phenotypicVariation"-->  v10
    v9 --":start"-->  v1
    v9 --":end"-->  v3
    v10 --":term"-->  v11
    v10 --":impactedObject"-->  a1
    a1 --":term"-->  a2
    a2 --"rdfs:label"-->  v12
    v10 --"a"-->  v7
    v11 --":childOf"-->  c13
    v11 --"rdfs:label"-->  v13
    bind3[/"concat(concat(?effect,' '),?ioTermlab)"/]
    v13 --o bind3
    v12 --o bind3
    bind3 --as--o v14
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v4 --":positionalAnnotation"-->  v5
    subgraph optional0["(optional)"]
    style optional0 fill:#bbf,stroke-dasharray: 5 5;
      v5 -."rdfs:comment".->  v14
    end
    v5 --"a"-->  v7
    v5 --":start"-->  v1
    v5 --":end"-->  v3
  end
  union0r <== or ==> union0l
  end
  bind4[/"str(?txt)"/]
  v14 --o bind4
  bind4 --as--o v14