Skip to content

Instantly share code, notes, and snippets.

CONSTRUCT {?externalEnsemblId <skos:relatedMatch> ?dbPrimaryAcc .
?dbPrimaryAcc <DC.source> ?dbName .}
WHERE {
?xref a <xref> .
?xref <hasDbprimary_acc> ?dbPrimaryAcc .
?xref <hasDisplayLabel> ?dbDisplayLabel .
?xref <hasExternalDbId> ?externalDbId .
?xref <hasInternalEnsemblId> ?internalEnsemblId .
?externalDbId <hasDbName> ?dbName .
?internalEnsemblId <hasExternalEnsemblId> ?externalEnsemblId .
@andrawaag
andrawaag / countryEducationalInstitutes.sparql
Created July 3, 2013 13:51
Get the list of educationalInstitutes per country
SELECT DISTINCT ?Country count(?EducationalInstitute) as ?noInstitutes
WHERE {
?Country <http://dbpedia.org/property/gdpNominal> ?Nominalgdp .
?Country <http://dbpedia.org/property/gdpNominalYear> ?gdpNominalYear .
?Country <http://dbpedia.org/property/gdpPppPerCapita> ?gdpPppPerCapita .
?Country <http://dbpedia.org/property/gdpPpp> ?gdpPpp .
?EducationalInstitute <http://dbpedia.org/property/country> ?Country .
?EducationalInstitute <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/EducationalOrganization> .} ORDER BY ?noInstitutes
@andrawaag
andrawaag / getSparqlAsRDF.pl
Created July 11, 2013 10:50
Get all mouse pathways. This perl scripts returns the uri through identifiers.org, a link the rdf version of the pathway and a url for the wiki entry of the specific revision currently loading in the triple store of wikipathways
#!/usr/bin/perl
use LWP::Simple;
use URI::Escape;
my $sparql = "SELECT DISTINCT ?wpIdentifier ?pathway ?page
WHERE {
?pathway dc:title ?title .
?pathway wp:organism ?organism .
?pathway foaf:page ?page .
?pathway dc:identifier ?wpIdentifier .
@andrawaag
andrawaag / getSparqlAsCSV.pl
Created July 11, 2013 10:59
This perl scripts returns the results of a sparql query to return Pathway elements that don't contain no DataSource or Identifier
#!/usr/bin/perl
use LWP::Simple;
use URI::Escape;
my $sparql = "SELECT DISTINCT ?wpIdentifier ?elementneedsattention ?elementLabel
WHERE {
?pathway dc:title ?title .
?elementneedsattention a gpml:requiresCurationAttention .
?elementneedsattention dcterms:isPartOf ?pathway .
?elementneedsattention rdfs:label ?elementLabel .
@andrawaag
andrawaag / gpml
Created September 26, 2013 12:24
gpml language definition LaTeX listings package
% Language Definition for GPML
\usepackage{color}
\definecolor{gray}{rgb}{0.4,0.4,0.4}
\definecolor{darkblue}{rgb}{0.0,0.0,0.6}
\definecolor{cyan}{rgb}{0.0,0.6,0.6}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
showstringspaces=false,
curl "http://sparql.bioontology.org/sparql/?query=PREFIX+omv%3A+%3Chttp%3A%2F%2Fomv.ontoware.org%2F2005%2F05%2Fontology%23%3E%0D%0APREFIX+rdfs%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0D%0APREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0D%0ASELECT+DISTINCT+%3Fdisease+%3Flabel+%3Ftype+%0D%0AWHERE+%7B%0D%0A%09%0D%0A++++++++%3Fdisease+rdfs%3Alabel+%3Flabel+.%0D%0A++++++++%3Fdisease+rdf%3Atype+%3Chttp%3A%2F%2Fwww.w3.org%2F2004%2F02%2Fskos%2Fcore%23Concept%3E+.%0D%0A%7D%0D%0A%0D%0A++++++++&apikey=d3419539-f429-4450-9097-8dd123acadd0&format=txt
“ \
|grep name=\"disease\”\
|sed "s/<binding name=\"disease\"><uri>/</“\
|sed "s/<\/uri><\/binding>/>/“\
|grep EFO \
|for efo in `xargs`; \
do curl "http://sparql.wikipathways.org/?default-graph-uri=&query=PREFIX+identifiers%3A%3Chttp%3A%2F%2Fidentifiers.org%2Fensembl%2F%3E%0D%0APREFIX+atlas%3A+%3Chttp%3A%2F%2Frdf.ebi.ac.uk%2Fresource%2Fatlas%2F%3E%0D%0APREFIX+atlasterms%3A+%3Chttp%3A%2F%2Frdf.ebi.ac.uk%2Fterms%2Fatlas%2
library(SPARQL)
library(ggplot2)
library(rworldmap)
wdqs <- "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
query = "PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
@andrawaag
andrawaag / DifExInsullinSIgnalling.R
Last active October 4, 2015 21:29
Differentially expressed Genes in a pathway on Insulin Signaling in case of Diabetes Mellitus
library(SPARQL)
library(ggplot2)
wpSparql <- "http://sparql.wikipathways.org"
ebiSparql <- "https://www.ebi.ac.uk/rdf/services/atlas/sparql"
efoPathwaysQuery <- "PREFIX identifiers: <http://identifiers.org/ensembl/>
PREFIX atlas: <http://rdf.ebi.ac.uk/resource/atlas/>
PREFIX atlasterms: <http://rdf.ebi.ac.uk/terms/atlas/>
PREFIX efo: <http://www.ebi.ac.uk/efo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
@andrawaag
andrawaag / TuberculosisinWikidata.R
Last active December 7, 2015 14:51
Get a spatial map in R on Number of cases of Tuberculosis in Wikidata added the SWAT4LS tutorial
library(SPARQL)
library(ggplot2)
library(rworldmap)
wdqs <- "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
query <- "PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
@andrawaag
andrawaag / WIkidataMalariaCounts.R
Created December 7, 2015 14:54
Get a spatial map in R on Number of cases of Malaria in Wikidata added the SWAT4LS tutorial
library(SPARQL)
library(ggplot2)
library(rworldmap)
wdqs <- "https://query.wikidata.org/bigdata/namespace/wdq/sparql"
query <- "PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>