@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_00254 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Proteins with associated pathways in WikiPathways"@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 DISTINCT ?entry ?gen ?pathwayname 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")) # Human proteins
 ?pathway dcterms:title ?pathwayname .
 }
 ?entry a :Entry .
 ?entry :gene / :recommendedName / rdfs:label ?gen .
}
order by ?pathwayname""" ;
    schema:keywords "federated query",
        "pathway",
        "tutorial" ;
    schema:target <https://sparql.nextprot.org/sparql> ;
    spex:federatesWith <https://sparql.wikipathways.org/sparql> .

