Child pages
  • BEL Sparql queries
Skip to end of metadata
Go to start of metadata
Uniprot Examples
Prefixes
prefix bel: <http://www.selventa.com/bel/>
prefix belv: <http://www.selventa.com/vocabulary/>
prefix anno: <http://www.selventa.com/bel/annotation/>
prefix namespace: <http://www.selventa.com/bel/namespace/>
prefix hgnc: <http://www.selventa.com/bel/namespace/hgnc-approved-symbols/>
prefix mgi: <http://www.selventa.com/bel/namespace/mgi-approved-symbols/>
prefix anatomy: <http://www.selventa.com/bel/annotation/anatomy/>
prefix skos: <http://www.w3.org/2004/02/skos/core#> 
prefix go: <http://www.geneontology.org/dtds/go.dtd#>
prefix obo: <http://purl.obolibrary.org/obo/>
 
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

 

Construct an rdf of all statement containing AKT1.
Construct an rdf of all statements containing AKT1
# select statements

prefix bel: <http://www.selventa.com/bel/>
prefix belv: <http://www.selventa.com/vocabulary/>
prefix hgnc: <http://www.selventa.com/bel/entity/hgnc-approved-symbols/>

construct{
  ?statement belv:hasSubject ?sub .
  ?statement belv:hasObject ?obj .
  ?statement belv:hasRelationship ?rel .
} where {
  {
    ?statement belv:hasSubject ?sub .
    ?statement belv:hasObject ?obj .
    ?sub belv:hasChild* ?sub .
    ?sub belv:hasConcept hgnc:AKT1 .
  }
  UNION
  {
    ?statement belv:hasObject ?obj .
    ?statement belv:hasSubject ?sub .
    ?obj belv:hasChild* ?obj .
    ?obj belv:hasConcept hgnc:AKT1 .
  }

  ?statement belv:hasRelationship ?rel .
  ?statement belv:hasEvidence ?e .
  ?e belv:hasEvidenceText ?text .
  ?e belv:hasCitation ?pmid .
}

# select all evidence
prefix hgnc: <http://www.selventa.com/bel/entity/hgnc-approved-symbols/>

construct{
  ?statement belv:hasSubject ?sub .
  ?statement belv:hasObject ?obj .
  ?statement belv:hasRelationship ?rel .
  ?statement belv:hasEvidence ?e .
  ?e         belv:hasEvidenceText ?text .
  ?e         belv:hasCitation ?pmid .
  ?e         belv:hasAnnotation ?ann .
} where {
  {
    ?statement belv:hasSubject ?sub .
    ?statement belv:hasObject ?obj .
    ?sub belv:hasChild* ?sub .
    ?sub belv:hasConcept hgnc:AKT1 .
  }
  UNION
  {
    ?statement belv:hasObject ?obj .
    ?statement belv:hasSubject ?sub .
    ?obj belv:hasChild* ?obj .
    ?obj belv:hasConcept hgnc:AKT1 .
  }

  ?statement belv:hasRelationship ?rel .
  ?statement belv:hasEvidence ?e .
  ?e belv:hasEvidenceText ?text .
  ?e belv:hasCitation ?pmid .
  ?e belv:hasAnnotation ?ann .
}

Frequency of all predicates
select ?pred (count(*) as ?freq)
where {
  ?sub ?pred ?obj .
}
group by ?pred
order by desc(?freq)
Number of unique citations/pmids
select (COUNT(DISTINCT ?pmid) as ?count)
where {
    
    ?e belv:hasCitation ?pmid .

}
Construct triples with hgnc ATR activityActivity abundance as subject, directlyIncreases as relationship, and any modified protein abundance as object
prefix hgnc: <http://www.selventa.com/bel/namespace/hgnc-approved-symbols/>

CONSTRUCT {?s belv:directlyIncreases ?o }

where {
    ?statement belv:hasSubject ?s .
    ?s belv:hasChild* ?innerterm .
    ?s a belv:AbundanceActivity .
    ?statement belv:hasObject ?o .
    ?o a belv:ModifiedProteinAbundance .
    ?statement belv:hasRelationship belv:directlyIncreases .
    ?innerterm belv:hasConcept hgnc:ATR .

 
}
Find Statements with an Anatomy annotation
Find Statements with Anatomy Annotation
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix anno: <http://www.selventa.com/bel/annotation/>

select ?s ?a
where {
  ?e belv:hasAnnotation ?a .
  ?a skos:inScheme anno:anatomy .
  ?e belv:hasStatement ?s .
  }

Find statements annotated with Anatomy = lung
find statements annotated with Anatomy = lung
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix anatomy: <http://www.selventa.com/bel/annotation/anatomy/>

select ?s ?a
where {
  ?e belv:hasAnnotation anatomy:lung .
  ?e belv:hasStatement ?s .
  }

insert "fibroblast of lung" cell annotation when evidence annotated with separate "lung" and "fibroblast" annotations
insert {
  ?ev belv:hasAnnotation <http://www.selventa.com/bel/annotation/cell/fibroblast%20of%20lung>
} where {
  ?a1 rdfs:label "fibroblast"^^xsd:string .
  ?a2 rdfs:label "lung"^^xsd:string .
  ?anno1 rdfs:seeAlso ?a1 .
  ?anno2 rdfs:seeAlso ?a2 .
  ?stmt belv:hasEvidence ?ev .
  ?stmt rdfs:label ?lbl .
  ?ev belv:hasAnnotation ?anno1 .
  ?ev belv:hasAnnotation ?anno2
}

select (
  count(?stmt) as ?c
)
where {
  ?stmt belv:hasEvidence ?ev .
  ?ev belv:hasAnnotation <http://www.selventa.com/bel/annotation/cell/fibroblast%20of%20lung>
}
find statements w/ evidence, orthologous to Human
# find all statements orthologous to human
prefix species: <http://www.selventa.com/bel/annotation/species-taxonomy-id/>
construct {
  ?ostmt a belv:Statement .
  ?ostmt belv:hasSubject ?osub .
  ?ostmt belv:hasObject ?oobj .
  ?ostmt belv:hasRelationship ?orel .
  ?ostmt belv:hasEvidence ?oev .
  ?ostmt rdfs:label ?olbl .
  ?oev belv:hasAnnotation ?oanno .
  ?oev belv:hasEvidenceText ?oevtxt .
  ?oev belv:hasCitation ?ocitation .
} where {
  ?stmt a belv:Statement .
  ?stmt belv:hasEvidence ?ev .
  ?ev belv:hasAnnotation species:9606 .
  ?stmt belv:hasSubject ?sub .
  ?stmt belv:hasObject ?obj .
  {
    ?sub belv:hasConcept ?subconcept .
    ?subconcept belv:orthologousMatch ?subortho .
    ?osub belv:hasConcept ?subortho .
    ?obj belv:hasConcept ?objconcept .
    ?objconcept belv:orthologousMatch ?objortho .
    ?oobj belv:hasConcept ?objortho .
    ?ostmt belv:hasSubject ?osub .
    ?ostmt belv:hasObject ?oobj .
  } UNION {
    ?sub belv:hasChild* ?subinner .
    ?subinner belv:hasConcept ?subconcept .
    ?subconcept belv:orthologousMatch ?subortho .
    ?osub belv:hasConcept ?subortho .
    ?obj belv:hasChild* ?objinner .
    ?objinner belv:hasConcept ?objconcept .
    ?objconcept belv:orthologousMatch ?objortho .
    ?oobj belv:hasConcept ?objortho .
    ?ostmt belv:hasSubject ?osub .
    ?ostmt belv:hasObject ?oobj .
  }
  ?ostmt belv:hasEvidence ?oev .
  ?ostmt rdfs:label ?olbl .
  ?oev belv:hasAnnotation ?oanno .
  ?oev belv:hasEvidenceText ?oevtxt .
  ?oev belv:hasCitation ?ocitation .
}

# only find orthologous statements to "p(HGNC:TNF) -> r(HGNC:C3)"
prefix species: <http://www.selventa.com/bel/annotation/species-taxonomy-id/>
construct {
  ?ostmt a belv:Statement .
  ?ostmt belv:hasSubject ?osub .
  ?ostmt belv:hasObject ?oobj .
  ?ostmt belv:hasRelationship ?orel .
  ?ostmt belv:hasEvidence ?oev .
  ?ostmt rdfs:label ?olbl .
  ?oev belv:hasAnnotation ?oanno .
  ?oev belv:hasEvidenceText ?oevtxt .
  ?oev belv:hasCitation ?ocitation .
} where {
  ?stmt a belv:Statement .
  ?stmt rdfs:label "p(HGNC:TNF) -> r(HGNC:C3)" .
  ?stmt belv:hasEvidence ?ev .
  ?ev belv:hasAnnotation species:9606 .
  ?stmt belv:hasSubject ?sub .
  ?stmt belv:hasObject ?obj .
  {
    ?sub belv:hasConcept ?subconcept .
    ?subconcept belv:orthologousMatch ?subortho .
    ?osub belv:hasConcept ?subortho .
    ?obj belv:hasConcept ?objconcept .
    ?objconcept belv:orthologousMatch ?objortho .
    ?oobj belv:hasConcept ?objortho .
    ?ostmt belv:hasSubject ?osub .
    ?ostmt belv:hasObject ?oobj .
  } UNION {
    ?sub belv:hasChild* ?subinner .
    ?subinner belv:hasConcept ?subconcept .
    ?subconcept belv:orthologousMatch ?subortho .
    ?osub belv:hasConcept ?subortho .
    
    ?obj belv:hasChild* ?objinner .
    ?objinner belv:hasConcept ?objconcept .
    ?objconcept belv:orthologousMatch ?objortho .
    ?oobj belv:hasConcept ?objortho .
    
    ?ostmt belv:hasSubject ?osub .
    ?ostmt belv:hasObject ?oobj .
  }
  ?ostmt belv:hasEvidence ?oev .
  ?ostmt rdfs:label ?olbl .
  ?oev belv:hasAnnotation ?oanno .
  ?oev belv:hasEvidenceText ?oevtxt .
  ?oev belv:hasCitation ?ocitation .
}
number of distinct evidence with annotation
select (count(distinct ?ev) as ?count)
where {
  ?stmt a belv:Statement .
  ?stmt belv:hasEvidence ?ev .
  ?ev belv:hasAnnotation ?anno .
  ?anno skos:inScheme <http://www.selventa.com/bel/annotation/species-taxonomy-id> .
}
Count distinct Pubmed ID's
# Count distinct Pubmed ID's used
@prefix bel: <http://www.selventa.com/bel/> .
@prefix belv: <http://www.selventa.com/vocabulary/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
SELECT
	(COUNT(DISTINCT ?o) AS ?citations)
WHERE
{
	?s <http://www.selventa.com/vocabulary/hasCitation> ?o .
	FILTER regex(str(?o),'pubmed')
}
See what classes are actually used in KB
SELECT DISTINCT ?class
WHERE {
?instance a ?class .
}
ORDER by ?class

 

Get orthologs of hgnc TP53
#get orthologs of hgnc "TP53"

prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix namespace: <http://www.selventa.com/bel/namespace/>
prefix hgnc: <http://www.selventa.com/bel/namespace/hgnc-approved-symbols/>
prefix mgi: <http://www.selventa.com/bel/namespace/mgi-approved-symbols/>

select ?scheme ?orthologlabel
where {
  ?hgnc skos:inScheme namespace:hgnc-approved-symbols .
  ?hgnc skos:prefLabel "TP53" .
  ?hgnc belv:orthologousMatch ?ortholog .
  ?ortholog skos:prefLabel ?orthologlabel .
  ?ortholog skos:inScheme ?scheme .
 
            }
statements with subclasses of Thiazolidenediones as subject, and human RNA abundance as Object
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix namespace: <http://www.selventa.com/bel/namespace/>

select ?subject ?object
where {
   ?id rdfs:label "thiazolidenediones"^^xsd:string .
   ?child rdfs:subClassOf* ?id .
   ?subjectconcept rdfs:seeAlso ?child .
   ?subjectconcept skos:exactMatch ?moreconcepts .
   ?statement belv:hasSubject ?subject .
   ?statement belv:hasObject ?object .
   ?object a belv:RNAAbundance .
   ?object belv:hasConcept ?objectconcept .
   ?objectconcept skos:inScheme namespace:hgnc-approved-symbols .
   ?subject belv:hasConcept ?moreconcepts.
      }

 

Make ortholog table
#get orthology table
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix namespace: <http://www.selventa.com/bel/namespace/>
prefix hgnc: <http://www.selventa.com/bel/namespace/hgnc-approved-symbols/>
prefix mgi: <http://www.selventa.com/bel/namespace/mgi-approved-symbols/>

select ?label ?mouseorthologlabel ?ratorthologlabel
where {
  ?hgnc skos:inScheme namespace:hgnc-approved-symbols .
  ?hgnc skos:prefLabel ?label .
  optional {?hgnc belv:orthologousMatch ?mouseortholog .
  ?mouseortholog skos:prefLabel ?mouseorthologlabel .
  ?mouseortholog skos:inScheme namespace:mgi-approved-symbols .}
  optional {?hgnc belv:orthologousMatch ?ratortholog .
  ?ratortholog skos:prefLabel ?ratorthologlabel .
  ?ratortholog skos:inScheme namespace:rgd-approved-symbols . }
 
            }
Example of alternative property path query
SELECT ?ancestor
{
   ?ancestor (ex:motherOf|ex:fatherOf)+ <#me>
}

 

Find narrower annotation terms (lung)

prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix anatomy: <http://www.selventa.com/bel/annotation/anatomy/>
prefix obo: <http://purl.obolibrary.org/obo/>
prefix belv: <http://www.selventa.com/vocabulary/>

select distinct ?anno
where {
  ?term rdfs:label ?lbl .
  {
    ?others rdfs:subClassOf ?term .
  } UNION {
    ?o2 rdfs:subClassOf ?term .
    ?others rdfs:subClassOf ?o2 .
  } UNION {
    ?term rdfs:subClassOf ?related .
    ?related owl:someValuesFrom ?others .
  }
  ?other rdfs:label ?olbl .
  ?anno a skos:Concept .
  ?anno rdfs:seeAlso ?others .
  #?e belv:hasAnnotation ?anno .
  #?s belv:hasEvidence ?e .
  FILTER (?lbl in ("fibroblast of lung"^^xsd:string, "epithelial cell of lung"^^xsd:string)) .
}

get fibroblast statements

prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix belv: <http://www.selventa.com/vocabulary/>

select distinct ?s ?r ?o ?anno
where {
  ?term rdfs:label "fibroblast"^^xsd:string .
  ?childterm rdfs:subClassOf ?term .
  ?childterm rdfs:label ?childlabel .
  {?anno rdfs:seeAlso ?childterm} UNION 
  {?anno rdfs:seeAlso ?term}.
  ?ev belv:hasAnnotation ?anno .
  ?statement belv:hasEvidence ?ev .
  ?statement belv:hasSubject ?s .
  ?statement belv:hasRelationship ?r .
  ?statement belv:hasObject ?o .
  }

statements involving "cell death"

prefix belv: <http://www.selventa.com/vocabulary/>
prefix skos: <http://www.w3.org/2004/02/skos/core#> 
prefix go: <http://www.geneontology.org/dtds/go.dtd#>

 construct {
  ?stmt rdfs:label ?lbl .
  ?stmt belv:hasSubject ?sub .
  ?stmt belv:hasObject ?obj .
  ?stmt belv:hasEvidence ?ev .
  ?ev belv:hasAnnotation ?anno .
  ?ev belv:hasEvidenceText ?evtxt .
  ?ev belv:hasCitation ?citation .
} where {
  ?deathterm go:name "cell death".
  ?term go:name ?name.
  {
    ?term go:is_a ?deathterm .
  } UNION {
    ?i1   go:is_a ?deathterm .
    ?term go:is_a ?i1 .
  } UNION {
    ?i1   go:is_a ?deathterm .
    ?i2   go:is_a ?i1 .
    ?term go:is_a ?i2 .
  }
  {
    ?idconcept rdfs:seeAlso ?term .
  } UNION {
    ?idconcept rdfs:seeAlso ?deathterm .
  }
  ?concept skos:exactMatch ?idconcept .
  ?belterm belv:hasConcept ?concept .
  {
    ?stmt belv:hasSubject ?belterm .
  } UNION {
    ?stmt belv:hasObject ?belterm .
  }
  ?stmt belv:hasEvidence ?ev .
  ?stmt rdfs:label ?lbl .
  ?stmt belv:hasSubject ?sub .
  ?stmt belv:hasSubject ?obj .
  ?ev belv:hasAnnotation ?anno .
  ?ev belv:hasEvidenceText ?evtxt .
  ?ev belv:hasCitation ?citation .
}

CDKN1A

prefix belv: <http://www.selventa.com/vocabulary/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>

construct {
  ?stmt belv:hasEvidence ?citation .
  ?citation belv:hasKeyword ?keyword .
} where {
  ?stmt a belv:Statement .
  ?stmt belv:hasSubject|belv:hasObject ?term .
  ?stmt belv:hasEvidence ?ev .
  ?ev belv:hasCitation ?citation .
  ?citation <http://bio2rdf.org/pubmed_vocabulary:keyword> ?keyword .
  {
    # AKT1 in outer term
    ?term belv:hasConcept ?concept .
    ?concept skos:prefLabel "CDKN1A" .
  } UNION {
    # AKT1 in first child term
    ?term belv:hasChild ?c1 .
    ?c1 belv:hasConcept ?concept .
    ?concept skos:prefLabel "CDKN1A" .
  } UNION {
    # AKT1 in second child term
    ?term belv:hasChild ?c1 .
    ?c1 belv:hasChild ?c2 .
    ?c2 belv:hasConcept ?concept .
    ?concept skos:prefLabel "CDKN1A" .
  } UNION {
    # AKT1 in third child term
    ?term belv:hasChild ?c1 .
    ?c1 belv:hasChild ?c2 .
    ?c2 belv:hasChild ?c3 .
    ?c3 belv:hasConcept ?concept .
    ?concept skos:prefLabel "CDKN1A" .
  }
}

get keywords for pmids attached to statements

prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix belv: <http://www.selventa.com/vocabulary/>

select DISTINCT *
where {
  ?pmid a <http://bio2rdf.org/pubmed_vocabulary:PubMedRecord> . 
  ?pmid <http://bio2rdf.org/pubmed_vocabulary:keyword> ?kw .
  ?e belv:hasCitation ?pmid .
          }

get Swissprot names and associated diseases

Uniprot query
PREFIX up:<http://purl.uniprot.org/core/> 
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> 
PREFIX skos:<http://www.w3.org/2004/02/skos/core#> 
PREFIX owl:<http://www.w3.org/2002/07/owl#> 
PREFIX bibo:<http://purl.org/ontology/bibo/> 
PREFIX dc:<http://purl.org/dc/terms/> 
PREFIX xsd:<http://www.w3.org/2001/XMLSchema#> 

SELECT ?name ?diseasename
WHERE
{
  ?protein a up:Protein .
  ?protein up:organism <http://purl.uniprot.org/taxonomy/9606> .
  ?protein up:mnemonic ?name .
  ?protein up:annotation ?annotation .
  ?annotation a up:Disease_Annotation .
  ?annotation up:disease ?disease .
  ?disease skos:prefLabel ?diseasename .
} 
ORDER by ?disease

find human proteins classified by keyword "Secreted"

Uniprot query
PREFIX up:<http://purl.uniprot.org/core/> 
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> 
PREFIX skos:<http://www.w3.org/2004/02/skos/core#> 


SELECT DISTINCT ?name 
WHERE
{
  ?protein a up:Protein .
  ?protein up:classifiedWith ?kw .
?protein up:mnemonic ?name .
?kw skos:prefLabel "Secreted" .
?protein up:organism <http://purl.uniprot.org/taxonomy/9606> .
  }

get knowledge around a specific disease (e.g. CDS)

prefix up:<http://purl.uniprot.org/core/>
prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>
prefix skos:<http://www.w3.org/2004/02/skos/core#>
prefix owl:<http://www.w3.org/2002/07/owl#>
prefix bibo:<http://purl.org/ontology/bibo/>
prefix dc:<http://purl.org/dc/terms/>
prefix xsd:<http://www.w3.org/2001/XMLSchema#>
prefix belv:<http://www.selventa.com/vocabulary/>
 
select ?subject ?rel ?object
where
{
  ?stmt a belv:Statement .
  ?stmt belv:hasSubject ?subject .
  ?stmt belv:hasObject ?object .
  ?stmt belv:hasRelationship ?rel .
  {
    ?subject belv:hasConcept ?concept .
  } union {
    ?object belv:hasConcept ?concept .
  } union {
    ?subject belv:hasChild ?c1 .
    ?c1 belv:hasConcept ?concept .
  } union {
    ?object belv:hasChild ?c1 .
    ?c1 belv:hasConcept ?concept .
  } union {
    ?subject belv:hasChild ?c1 .
    ?c1 belv:hasChild ?c2 .
    ?c2 belv:hasConcept ?concept .
  } union {
    ?object belv:hasChild ?c1 .
    ?c1 belv:hasChild ?c2 .
    ?c2 belv:hasConcept ?concept .
  }
  ?concept skos:exactMatch ?sprot .
  ?sprot skos:inScheme <http://www.selventa.com/bel/namespace/swissprot-accession-numbers> .
  ?sprot rdfs:seeAlso ?protein .
  ?protein a up:Protein .
  ?protein up:organism <http://purl.uniprot.org/taxonomy/9606> .
  ?protein up:mnemonic ?name .
  ?protein up:annotation ?annotation .
  ?annotation a up:Disease_Annotation .
  ?annotation up:disease ?disease .
  ?disease <http://purl.uniprot.org/core/mnemonic> "CDS" .
  ?disease skos:prefLabel ?diseasename .
}

construct directlyIncreases statements given complex(child1, child2) and child1 increases child2

prefix belv: <http://www.selventa.com/vocabulary/>

construct {?child1 belv:directlyIncreases ?child2}
where {?term a belv:ComplexAbundance .
      ?term belv:hasChild ?child1 .
      ?child1 a belv:ProteinAbundance .
       ?term belv:hasChild ?child2 .
      ?child2 a belv:ProteinAbundance .
       ?st belv:hasSubject ?child1 .
       ?st belv:hasObject ?child2 .
       ?st belv:hasRelationship belv:increases .
     
      }

  • No labels