@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#> .

ex:NXQ_00146 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Proteins having at least 2 proteotypic peptides of 7 or 8aa but no proteotypic peptide >= 9 aa"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX : <http://nextprot.org/rdf/>

SELECT DISTINCT ?entry WHERE {
?entry :isoform / :peptideMapping ?pm.
?pm :proteotypic true .
?pm :peptideName ?pepid .
#?pm :start ?pos1 ; :end ?pos2 .
#filter((?pos2 - ?pos1 + 1) >= 7) # This is not absolutely required for current query since 7 is the minimum length for accepted proteotypic peptides
filter not exists {
 ?entry :isoform / :peptideMapping ?pm2.
 ?pm2 :start ?p1 ; :end ?p2 .
 ?pm2 :proteotypic true .
 filter((?p2 - ?p1 + 1) >= 9)
 }
}
group by ?entry having(count (distinct ?pepid) >= 2)""" ;
    schema:keywords "peptide",
        "proteomics",
        "tutorial" ;
    schema:target <https://sparql.nextprot.org/sparql> .

