[BIONT]

In the teleconference there was some interest in poking around my  
example code for doing sparql and I said I would send a pointer to it.

The code lives at http://svn.mumble.net:8080/svn/lsw/trunk

If you check it out (with svn co http://svn.mumble.net:8080/svn/lsw/ 
trunk) you will see README.txt with some information on running it.

What this is doing is described a bit at http://karma.med.harvard.edu/ 
wiki/Debugging_the_bug

Start it up:
./abcl
(load "start")

Some instructions will print out when you start it up. You might want  
to skip most of them and do just

(owl-load-combined)
(do-some-queries)

if you are only interested in the sparql aspect of things.
You should see something like the listing at the end of this message.

If anyone actually tries this and wants to work more with it I will  
be happy to spend more time documenting and helping out, give write  
access to the repository, etc.

Regards,
Alan

What small molecules are associated with KEGG id C00645?
---- Query (lisp) ----
(sparql '(:select (?mol) nil (?mol "bug:classifiedByKEGG" ?kegg)
           (?kegg "bug:hasID" "C00645"))
         :use-reasoner
         t)

---- Query (sparql) ----
SELECT ?mol
WHERE {
?mol <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#classifiedByKEGG> ?kegg.
?kegg <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasID> "C00645". }
---- Result ----

(("http://gcrg.ucsd.edu/ijr904/acmana")
("http://ecocyc.org/compound/n-acetyl-d-mannosamine"))
================================================================
What small molecules have the chemical formula c6h15o9p, and what are  
their names, cas, kegg ids?
---- Query (lisp) ----
(sparql '(:select (?name ?cas ?kegg) (:distinct t)
           (?formula "bug:hasFormula" "c6h15o9p")
           (?mol "bug:hasChemicalFormula" ?formula)
           (?mol "bug:hasName" ?name)
           (:optional (?mol "bug:definedByCAS" ?casf)
            (?casf "bug:hasID" ?cas))
           (:optional (?mol "bug:classifiedByKEGG" ?keggf)
            (?keggf "bug:hasID" ?kegg)))
         :use-reasoner
         t)

---- Query (sparql) ----
SELECT DISTINCT ?name ?cas ?kegg
WHERE {
?formula <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasFormula> "c6h15o9p".
?mol <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasChemicalFormula> ?formula.
?mol <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasName> ?name.
OPTIONAL {
?mol <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#definedByCAS> ?casf.
?casf <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasID> ?cas. }.
OPTIONAL {
?mol <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#classifiedByKEGG> ?keggf.
?keggf <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasID> ?kegg. }.}
---- Result ----
INFO: This is not an ABox query:  
org.mindswap.pellet.exceptions.UnsupportedQueryException: Nested  
query patterns are not supported

(("mannitol-1-phosphate" "15806-48-1" nil)
("Galactitol 1-phosphate" nil "C06311")
("galactitol-1-phosphate" nil nil)
("D-sorbitol 6-phosphate" "108392-12-7" "C01096")
("D-Sorbitol 6-phosphate" "108392-12-7" "C01096")
("D-Mannitol 1-phosphate" nil "C00644"))
================================================================
Which pairs (only show 10) of molecules have the same name? don't use  
reasoner here - it has a bug
---- Query (lisp) ----
(sparql '(:select (?mol1 ?mol2 ?name) (:limit 10)
           (?mol1 "bug:hasName" ?name) (?mol2 "bug:hasName" ?name)
           (:filter (not (equal ?mol1 ?mol2))))
         :use-reasoner
         nil)

---- Query (sparql) ----
SELECT ?mol1 ?mol2 ?name
WHERE {
?mol1 <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasName> ?name.
?mol2 <http://karma.med.harvard.edu/wiki/Debugging_the_bug/ 
bug.owl#hasName> ?name.
FILTER (!((?mol1 = ?mol2)))} LIMIT 10
---- Result ----

(("http://gcrg.ucsd.edu/ijr904/dxyl5p"
   "http://ecocyc.org/compound/deoxyxylulose-5p"
   "1-deoxy-D-xylulose 5-phosphate")
("http://ecocyc.org/compound/ctp" "http://gcrg.ucsd.edu/ijr904/ctp"

....

Received on Thursday, 9 March 2006 00:10:59 UTC