@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_00293 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ;
  sh:prefixes _:sparql_examples_prefixes ;
  rdfs:comment '''Glycosylation sites annotated by GlyConnect from a list of publications (PMIDs)'''@en ;
  schema:keywords "federated", "glycosylation", "PTM", "publication", "sequence", "snorql-only" ;
  schema:target <https://sparql.nextprot.org/sparql> ;
  sh:select '''PREFIX : <http://nextprot.org/rdf/>
PREFIX cv: <http://nextprot.org/rdf/terminology/>

PREFIX faldo:<http://biohackathon.org/resource/faldo#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX glycan:<http://purl.jp/bio/12/glyco/glycan#>
PREFIX glyco:<http://purl.jp/bio/12/glyco/conjugate#>

select distinct ?entry ?isoNP ?position where {
  values ?pmid {"24884609" "10441114"} # pubmed ids, space- or linebreak-separated

  bind(IRI(concat("http://www.ncbi.nlm.nih.gov/pubmed/",?pmid)) as ?pubIRI)
  SERVICE <https://glyconnect.expasy.org/sparql> {
    ?ref_conjugate glyco:has_protein_part ?glycoprotein .
    ?glycoprotein glyco:glycosylated_at / faldo:location ?glycosite .
    ?glycosite faldo:reference ?isoform ; faldo:position ?position .
    ?ref_conjugate glycan:published_in / foaf:primaryTopicOf ?pubIRI .
  }
  BIND(IRI(replace(str(?isoform),"http://purl.uniprot.org/isoforms/","http://nextprot.org/rdf/isoform/NX_")) AS ?isoNP) .
  ?entry :isoform ?isoNP .
} order by ?entry ?position''' ;
  spex:federatesWith <https://glyconnect.expasy.org/sparql> .
