@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_00091 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ;
  sh:prefixes _:sparql_examples_prefixes ;
  rdfs:comment '''Proteins which are targets of drugs for cardiac therapy'''@en ;
  schema:keywords "drug", "federated query" ;
  schema:target <https://sparql.nextprot.org/sparql> ;
  sh:select '''PREFIX : <http://nextprot.org/rdf/>
PREFIX cv: <http://nextprot.org/rdf/terminology/>

select distinct ?entry where {
  service <http://drugbank.bio2rdf.org/sparql> {
    select distinct ?uniprot WHERE {
	?drug <http://bio2rdf.org/drugbank_vocabulary:target> ?drugTarget .
	?drug <http://bio2rdf.org/drugbank_vocabulary:x-atc> ?atcCode.
    ?drugTarget <http://bio2rdf.org/drugbank_vocabulary:x-uniprot> ?uniprot .
	filter(!contains(str(?uniprot),"_"))
	filter(contains(str(?atcCode), "atc:C01" )) # ATC starting with C01 means therapeutic subgroup for cardiac therapy
    }
  }
  BIND (IRI(CONCAT("http://nextprot.org/rdf/entry/NX_",substr(str(?uniprot),28,6))) as ?entry) # cast drugbank id to neXtprot entry
}''' ;
  spex:federatesWith <http://drugbank.bio2rdf.org/sparql> .
