Created
July 20, 2009 20:34
-
-
Save egonw/150889 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var owl = rdf.createStore(); | |
rdf.importURL(owl, | |
"file:///home/egonw/var/Projects/SourceForge/git-svn/qsar/qsar-dicts/" + | |
"descriptor-algorithms.owl" | |
); | |
js.clear(); | |
// list all descriptor categories | |
var cats = rdf.sparql(owl, | |
"PREFIX qsar: <http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#> " + | |
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + | |
"SELECT ?id ?label ?definition WHERE { " + | |
" ?id qsar:isClassifiedAs qsar:descriptorCategories; " + | |
" rdfs:label ?label; " + | |
" qsar:definition ?definition. " + | |
"}" | |
); | |
// iterate over all categories child of the category 'descriptorCategories' | |
for (var i=0; i<cats.size(); i++) { | |
var cat = cats.get(i); | |
// the next follows the ?id ?label ?definition order in the SPARQL | |
var identifier = cat.get(0); | |
var label = cat.get(1); | |
var definition = cat.get(2); | |
js.print("Category: " + label + "\n"); | |
// list of descriptors for this category; it takes advantage from the fact | |
// that the identifier is namespace prefix, and we use the same here | |
var sparql = | |
"PREFIX qsar: <http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#> " + | |
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + | |
"SELECT ?s ?label WHERE { " + | |
" ?s ?p " + identifier + ";" + | |
" rdfs:label ?label." + | |
"}"; | |
var descriptors = rdf.sparql(owl, sparql); | |
if (descriptors != null) { | |
for (var j=0; j<descriptors.size(); j++) { | |
var descriptor = descriptors.get(j); | |
var descriptorID = descriptor.get(0); | |
var label = descriptor.get(1); | |
js.print(" " + descriptorID + " = " + label + "\n"); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment