@prefix ex: <https://sparql.uniprot.org/.well-known/sparql-examples/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:34 a sh:SPARQLExecutable,
        sh:SPARQLSelectExecutable ;
    rdfs:comment "Find the co-occurence count of topological domain comment text in UniProtKB entries"@en ;
    sh:prefixes _:sparql_examples_prefixes ;
    sh:select """PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX up: <http://purl.uniprot.org/core/>

SELECT 
    ?comment1 
    ?comment2 
    (COUNT(?comment1) AS ?count1)
WHERE
{
    ?protein a up:Protein ;
               up:annotation ?annotation1 , 
                             ?annotation2 . 
    ?annotation1 rdf:type up:Topological_Domain_Annotation ;
        rdfs:comment ?rawComment1 .
    ?annotation2 rdf:type up:Topological_Domain_Annotation ;
        rdfs:comment ?rawComment2 . 
    BIND(IF(contains(?rawComment1, ';'), 
            STRBEFORE(?rawComment1,';'), 
            ?rawComment1) AS ?comment1)
    BIND(IF(contains(?rawComment2, ';'), 
            STRBEFORE(?rawComment2,';'), 
            ?rawComment2) AS ?comment2)
    FILTER(?annotation1 != ?annotation2)
} 
GROUP BY ?comment1 ?comment2 
ORDER BY DESC(COUNT(?comment1))""" ;
    schema:keywords "transmembrane" , "topology" , "count" ;
    schema:target <https://sparql.uniprot.org/sparql/> .

