Monday, August 17, 2009

Bioclipse and SPARQL end points

Last week, there was a very interesting thread on the DBPedia mailing list, on using Java for doing remote SPARQL queries. This was one of the features still missing in bioclipse.rdf. Richard Cyganiak replied pointing the code in Jena which conveniently does this and which bioclipse.rdf is already using anyway. Next, Fred Durao even gave a full code example relieving me from any further research, resulting in sparqlRemote() now implemented in the rdf manager:
> rdf.sparqlRemote(
"http://dbpedia.org/sparql",
"select distinct ?Concept where{[] a ?Concept } LIMIT 10"
);
[[http://dbpedia.org/ontology/Place], [http://dbpedia.org/ontology/Area],
[http://dbpedia.org/ontology/City], [http://dbpedia.org/ontology/River],
[http://dbpedia.org/ontology/Road], [http://dbpedia.org/ontology/Lake],
[http://dbpedia.org/ontology/LunarCrater],
[http://dbpedia.org/ontology/ShoppingMall], [http://dbpedia.org/ontology/Park],
[http://dbpedia.org/ontology/SiteOfSpecialScientificInterest]]
I reported earlier two example SPARQL queries for chemistry, which can now be rewritten as Bioclipse scripts:

var sparql = "\
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
PREFIX dbpedia: <http://dbpedia.org/ontology/> \
PREFIX dbprop: <http://dbpedia.org/property/> \
\
SELECT DISTINCT ?compound ?smiles WHERE { \
?compound a dbpedia:ChemicalCompound . \
?compound dbprop:section ?section . \
?section dbprop:smiles ?smiles . \
} ORDER BY ?compound LIMIT 10 OFFSET 0 \
";
rdf.sparqlRemote("http://dbpedia.org/sparql", sparql);
and

var sparql = "\
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \
PREFIX dbpedia: <http://dbpedia.org/ontology/> \
PREFIX dbprop: <http://dbpedia.org/property/> \
\
SELECT DISTINCT ?compound ?inchi WHERE { \
?compound a dbpedia:ChemicalCompound . \
?compound dbprop:section ?section . \
?section dbprop:inchi ?inchi . \
} ORDER BY ?compound LIMIT 10 OFFSET 0 \
";
rdf.sparqlRemote("http://dbpedia.org/sparql", sparql);

No comments:

Post a Comment