#MIILS2013 Practical: Bioclipse for RDF minting

3,171 views
3,062 views

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,171
On SlideShare
0
From Embeds
0
Number of Embeds
2,384
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

#MIILS2013 Practical: Bioclipse for RDF minting

  1. 1. Department of Bioinformatics - BiGCaT 1RDF creation with scripts(and Open PHACTS specs)Egon Willighagen (@egonwillighagen)17 June 2013, #MIILS2013, Leiden
  2. 2. Department of Bioinformatics - BiGCaT 2Scripting?• Reproducible• Electronic Lab Notebook– Put everything in a Git repository• Automates– Data set creation/conversion– Autogeneration of VoID headers
  3. 3. Department of Bioinformatics - BiGCaT 3RDF scripting in Bioclipse?• Access to Jena• Groovy or JavaScript• Domain extensionsTry:http://pele.farmbio.uu.se/jenkins/job/OpenTox_QSAR_DS/
  4. 4. Department of Bioinformatics - BiGCaT 4The Bioclipse Workbench
  5. 5. Department of Bioinformatics - BiGCaT 5Bioclipse: New project, new file• File New General Project→ → →– Enter a name– Finish• File New General File→ → →– Select project– Enter a name, e.g. test.n3– Finish
  6. 6. Department of Bioinformatics - BiGCaT 6
  7. 7. Department of Bioinformatics - BiGCaT 7RDF formats• Save files:– rdf.saveRDFN3(..)– rdf.saveRDFNTriple(..)– rdf.saveRDFXML(..)• As String:– rdf.asRDFN3(..)– rdf.asTurtle(..)
  8. 8. Department of Bioinformatics - BiGCaT 8
  9. 9. Department of Bioinformatics - BiGCaT 9Install RDFgraphvisualizer
  10. 10. Department of Bioinformatics - BiGCaT 10Install RDFgraphvisualizer
  11. 11. Department of Bioinformatics - BiGCaT 11Open with RDF Graph Viewer→
  12. 12. Department of Bioinformatics - BiGCaT 12JavaScript or Groovy ?Window →Show View →Other... →
  13. 13. Department of Bioinformatics - BiGCaT 13CSV files in Bioclipse
  14. 14. Department of Bioinformatics - BiGCaT 14CSV files in Bioclipse: path...Right click onProject →Properties
  15. 15. Department of Bioinformatics - BiGCaT 15CSV files in Groovyfilename ="/home/egonw/workspaces/dataman/Test/test.csv"line = 0new File(filename).splitEachLine(",") { fields ->line++if (line != 1) { // skip the headerprintln fieldsprintln fields[0]}}
  16. 16. Department of Bioinformatics - BiGCaT 16CSV files in Groovy[foo, 2, 3]foo[bar, 3, 4]bar
  17. 17. Department of Bioinformatics - BiGCaT 17Setting up and filling a triples stores = rdf.createInMemoryStore()rdf.addPrefix(s, "foo", "http://example.org/")rdf.addDataProperty(s,"http://example.org/foo","http://www.w3.org/2000/01/rdf-schema#label","Foo")rdf.addDataProperty(s,"http://example.org/bar","http://www.w3.org/2000/01/rdf-schema#label","Bar")rdf.addObjectProperty(s,"http://example.org/foo","http://example.org/interactsWith","http://example.org/bar")rdf.saveRDFN3(s, "/Test/csv.n3")
  18. 18. Department of Bioinformatics - BiGCaT 18csv.n3@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .@prefix owl: <http://www.w3.org/2002/07/owl#> .@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .@prefix foo: <http://example.org/> .foo:barrdfs:label "Bar" .foo:foordfs:label "Foo" ;foo:interactsWith foo:bar .
  19. 19. Department of Bioinformatics - BiGCaT 19Cleaning your codeexNS = "http://example.org/"rdfsNS = "http://www.w3.org/2000/01/rdf-schema#"s = rdf.createInMemoryStore()rdf.addPrefix(s, "foo", "http://example.org/")rdf.addDataProperty(s, exNS + "foo", rdfsNS + "label", "Foo" )rdf.addDataProperty(s, exNS + "bar", rdfsNS + "label", "Bar" )rdf.addObjectProperty(s, exNS + "foo", exNS + "interactsWith", exNS + "bar")rdf.saveRDFN3(s, "/Test/csv.n3")
  20. 20. Department of Bioinformatics - BiGCaT 20Help? → man rdf
  21. 21. Department of Bioinformatics - BiGCaT 21Other (Bioclipse) managersbioclipse browser cdk chemspider cmlds gist inchi jcp jcpglobal jmol jsmatrix molTable opentox opsin owlpellet pubchem qsar rdf signatures uiuserManager ws xmlAnd you can install more features.
  22. 22. Department of Bioinformatics - BiGCaT 22Pellet: an OWL reasonerexNS = "http://example.org/"owlNS = "http://www.w3.org/2002/07/owl#"rdfNS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"// s = rdf.createInMemoryStore()s = pellet.createInMemoryStore()rdf.addObjectProperty(s,exNS + "hasAncestor",rdfNS + "type",owlNS + "TransitiveProperty");rdf.addObjectProperty(s, exNS + "Elizabeth", exNS + "hasAncestor", exNS + "Carl");rdf.addObjectProperty(s, exNS + "Carl", exNS + "hasAncestor", exNS + "Nils");allAncestors ="SELECT ?ancestor { <" + exNS + "Elizabeth" + "> <" +exNS + "hasAncestor" + "> ?ancestor . }"rdf.sparql(s, allAncestors)
  23. 23. Department of Bioinformatics - BiGCaT 23OWL reasoning• regular rdf store[["ancestor"],["http://example.org/Carl"]]• pellet OWL store[["ancestor"],["http://example.org/Nils"],["http://example.org/Carl"]]
  24. 24. Department of Bioinformatics - BiGCaT 24SPARQL for unit testingresults = rdf.sparql(s, unitTest1)// expect 1 rowif (results.getRowCount() < 1) {println (“FAIL: too little data!”)}
  25. 25. Department of Bioinformatics - BiGCaT 25Share your script via myExperiment

×