sparql-examples

A set of SPARQL examples that are used in different SIB resources

View the Project on GitHub sib-swiss/sparql-examples

34

rq turtle/ttl

Find the co-occurence count of topological domain comment text in UniProtKB entries

Use at

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))
a
up:annotation
up:annotation
a
rdfs:comment
a
rdfs:comment
as
as
as
as
?_anon_e0f437e1f1c14be7b52a20c8a3b97c821329
?annotation1
?annotation2
?comment1
?comment2
?count1
?protein
?rawComment1
?rawComment2
up:Topological_Domain_Annotation
up:Protein
?annotation1 != ?annotation2
if(contains(?rawComment1,';'),substring-before(?rawComment1,';'),?rawComment1)
if(contains(?rawComment2,';'),substring-before(?rawComment2,';'),?rawComment2)
count(?comment1)
count(?comment1)