@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_00253 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Human pathways in which at least one protein is mitochondrial GOLD"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX : <http://nextprot.org/rdf/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX nextprot_cv: <http://nextprot.org/rdf/terminology/>
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 ?pathwayname (group_concat(distinct ?gen ; SEPARATOR = ',') as ?gene) WHERE {
 SERVICE <https://sparql.wikipathways.org/sparql> {

 { ?geneProduct a wp:GeneProduct . }
 union
 { ?geneProduct a wp:Protein . }
 ?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 .
 }

 ?entry a :Entry .
 ?entry :gene / :recommendedName / rdfs:label ?gen .
 ?entry :isoform / :cellularComponent ?loc .
 values ?mitoloc {nextprot_cv:SL-0173 nextprot_cv:GO_0005739 } # SL and GO values for mitochondrion
 ?loc :term / :childOf ?mitoloc. # mitochondrion
 ?loc :evidence / :quality :GOLD .
 filter not exists {?loc :negativeEvidence ?negev} # No negative localization evidence
}
group by ?pathwayname
order by ?pathwayname""" ;
    schema:keywords "federated query",
        "pathway",
        "quality",
        "subcellular location",
        "tutorial" ;
    schema:target <https://sparql.nextprot.org/sparql> ;
    spex:federatesWith <https://sparql.wikipathways.org/sparql> .

