@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#> .
@prefix spex:<https://purl.expasy.org/sparql-examples/ontology#> .

ex:NXQ_00276 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Diseases/phenotypes associated with coding variants and associated publications for a given gene"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX : <http://nextprot.org/rdf/>
PREFIX db: <http://nextprot.org/rdf/db/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
PREFIX sio: <http://semanticscience.org/resource/>
PREFIX so: <http://purl.obolibrary.org/obo/SO_>

SELECT DISTINCT ?entry (str(?umlsTerm) as ?umlsTermSTR) (str(?snpac) as ?varid) ?pos (str(?orgaa) as ?orgAA) (str(?varaa) as ?varAA) ?article WHERE {
 SERVICE <https://rdf.disgenet.org/sparql> {
 ?vda sio:SIO_000628 ?umls, ?variant .
 ?vda sio:SIO_000772 ?article .
 ?umls dcterms:title ?umlsTerm.
 {?umls a sio:SIO_010299 .} # disease
 union
 {?umls a sio:SIO_010056 .} # or phenotype
 ?variant a so:0001583 ; dcterms:title ?variantTitle . # Missense variant
 ?variant so:associated_with ?gene .
 ?gene a ncit:C16612; sio:SIO_010078 ?protein .
 ?gene sio:SIO_000205 ?gname.
 filter(contains(str(?gname),"HBB")) # Hemoglobin gene (NX_P68871)
 }

 BIND(IRI(replace(str(?protein),"purl","www")) AS ?unipage) .
 ?entry :swissprotPage ?unipage .
 ?entry :isoform ?iso .
 ?iso :swissprotDisplayed true .
 ?iso :variant ?var .
 ?var :evidence /:reference ?xref .
 ?xref :provenance db:dbSNP; :accession ?snpac .
 ?var :start ?pos ; :original ?orgaa; :variation ?varaa .
 filter(contains(?snpac,str(?variantTitle))) # matches the exact same variant Disgenet returned
}""" ;
    schema:keywords "disease",
        "federated query",
        "tutorial",
        "variant" ;
    schema:target <https://sparql.nextprot.org/sparql> ;
    spex:federatesWith <https://rdf.disgenet.org/sparql> .

