@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_00270 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Proteins belonging to Rett syndrome pathways, and their subcellular locations (GOLD)"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX : <http://nextprot.org/rdf/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wp: <http://vocabularies.wikipathways.org/wp#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

select ?entry (str(?gen) AS ?gene) ?pathwayname (group_concat(distinct str(?loclab); SEPARATOR = ",") as ?locs) WHERE {
 SERVICE <https://sparql.wikipathways.org/sparql> {

 {?geneProduct a wp:Protein}
 union
 {?geneProduct a wp:GeneProduct}

 ?geneProduct rdfs:label ?genraw .
 bind (concat( ""^^xsd:string, ?genraw) as ?gen).

 filter(!regex(?gen,"[ a-z-]")). # ensures official gene names for subsequent neXtprot matching
 ?geneProduct dcterms:isPartOf ?pathway .
 ?pathway a wp:Pathway .
 ?pathway wp:organism ?organism .
 filter(contains(str(?organism),"9606"))
 ?pathway dcterms:title ?pathwayname .
 filter(regex(?pathwayname,"rett","i")).
 }
 ?entry a :Entry .
 ?entry :gene / :recommendedName / rdfs:label ?gen .
 ?entry :isoform ?iso.
 ?iso :cellularComponent ?locannot .
 ?locannot :term ?locterm .
 ?locterm rdfs:label ?loclab .
 ?locannot :evidence ?locev .
 ?locev :quality :GOLD .
 filter not exists {?locannot :negativeEvidence ?locev .}
}
group by ?entry ?gen ?pathwayname
order by ?entry""" ;
    schema:keywords "disease",
        "federated query",
        "pathway",
        "subcellular location",
        "tutorial" ;
    schema:target <https://sparql.nextprot.org/sparql> ;
    spex:federatesWith <https://sparql.wikipathways.org/sparql> .

