@prefix ex:<https://purl.expasy.org/sparql-examples/neXtProt/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:NXQ_00265 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Retrieve all positional annotations at a given position on a neXtProt isoform"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """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""" ;
    schema:keywords "isoforms",
        "sequence",
        "tutorial" ;
    schema:target <https://sparql.nextprot.org/sparql> .

