@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_09410 a sh:SPARQLExecutable, sh:SPARQLSelectExecutable ;
  sh:prefixes _:sparql_examples_prefixes ;
  rdfs:comment '''Check there are no entries with a PTM on a non-proteotypic peptide (excluding PTMs with evidence from UniProt)'''@en ;
  schema:keywords "QC", "mass spectrometry", "peptide", "PTM", "proteomics" ;
  schema:target <https://sparql.nextprot.org/sparql> ;
  sh:select '''PREFIX : <http://nextprot.org/rdf/>
PREFIX cv: <http://nextprot.org/rdf/terminology/>
PREFIX source: <http://nextprot.org/rdf/source/>

select distinct ?entry where {
    ?entry :isoform ?iso.
    ?iso :swissprotDisplayed true .
    ?iso :ptm ?ptm .
    ?ptm :start ?pos.
    filter not exists { ?ptm :evidence / :assignedBy source:Uniprot. } # <-added clause
    ?iso :peptideMapping ?pm .
    ?pm :proteotypic false ; :start ?p1 ; :end ?p2 .
    filter(?pos >= ?p1 && ?pos <= ?p2)
    filter not exists {
      ?iso :peptideMapping ?pm2 .
      ?pm2 :proteotypic true ; :start ?p21 ; :end ?p22 .
      filter(?pos >= ?p21 && ?pos <= ?p22)
      }
}
order by ?entry''' .
