![Page 1: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/1.jpg)
Department of Bioinformatics - BiGCaT 1
RDF creation with scripts
(and Open PHACTS specs)
Egon Willighagen (@egonwillighagen)17 June 2013, #MIILS2013, Leiden
![Page 2: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/2.jpg)
Department of Bioinformatics - BiGCaT 2
Scripting?
• Reproducible• Electronic Lab Notebook
–Put everything in a Git repository
• Automates–Data set creation/conversion–Autogeneration of VoID headers
![Page 3: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/3.jpg)
Department of Bioinformatics - BiGCaT 3
RDF scripting in Bioclipse?
• Access to Jena• Groovy or JavaScript• Domain extensions
Try:
http://pele.farmbio.uu.se/jenkins/job/OpenTox_QSAR_DS/
![Page 4: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/4.jpg)
Department of Bioinformatics - BiGCaT 4
The Bioclipse Workbench
![Page 5: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/5.jpg)
Department of Bioinformatics - BiGCaT 5
Bioclipse: 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
![Page 6: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/6.jpg)
Department of Bioinformatics - BiGCaT 6
![Page 7: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/7.jpg)
Department of Bioinformatics - BiGCaT 7
RDF formats
• Save files:– rdf.saveRDFN3(..)– rdf.saveRDFNTriple(..)– rdf.saveRDFXML(..)
• As String:– rdf.asRDFN3(..)– rdf.asTurtle(..)
![Page 8: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/8.jpg)
Department of Bioinformatics - BiGCaT 8
![Page 9: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/9.jpg)
Department of Bioinformatics - BiGCaT 9
Install RDF graph visualizer
![Page 10: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/10.jpg)
Department of Bioinformatics - BiGCaT 10
Install RDF graph visualizer
![Page 11: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/11.jpg)
Department of Bioinformatics - BiGCaT 11
Open with RDF Graph Viewer→
![Page 12: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/12.jpg)
Department of Bioinformatics - BiGCaT 12
JavaScript or Groovy ?
Window → Show View → Other... →
![Page 13: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/13.jpg)
Department of Bioinformatics - BiGCaT 13
CSV files in Bioclipse
![Page 14: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/14.jpg)
Department of Bioinformatics - BiGCaT 14
CSV files in Bioclipse: path...
Right click on Project →Properties
![Page 15: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/15.jpg)
Department of Bioinformatics - BiGCaT 15
CSV files in Groovy
filename =
"/home/egonw/workspaces/dataman/Test/test.csv"
line = 0
new File(filename).splitEachLine(",") { fields ->
line++
if (line != 1) { // skip the header
println fields
println fields[0]
}
}
![Page 16: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/16.jpg)
Department of Bioinformatics - BiGCaT 16
CSV files in Groovy
[foo, 2, 3]
foo
[bar, 3, 4]
bar
![Page 17: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/17.jpg)
Department of Bioinformatics - BiGCaT 17
Setting up and filling a triples store
s = 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")
![Page 18: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/18.jpg)
Department of Bioinformatics - BiGCaT 18
csv.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:bar
rdfs:label "Bar" .
foo:foo
rdfs:label "Foo" ;
foo:interactsWith foo:bar .
![Page 19: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/19.jpg)
Department of Bioinformatics - BiGCaT 19
Cleaning your code
exNS = "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")
![Page 20: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/20.jpg)
Department of Bioinformatics - BiGCaT 20
Help? → man rdf
![Page 21: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/21.jpg)
Department of Bioinformatics - BiGCaT 21
Other (Bioclipse) managers
bioclipse browser cdk chemspider cml ds gist inchi jcp jcpglobal jmol js matrix molTable opentox opsin owl pellet pubchem qsar rdf signatures ui userManager ws xml
And you can install more features.
![Page 22: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/22.jpg)
Department of Bioinformatics - BiGCaT 22
Pellet: 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)
![Page 23: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/23.jpg)
Department of Bioinformatics - BiGCaT 23
OWL reasoning
• regular rdf store
[["ancestor"],
["http://example.org/Carl"]
]
• pellet OWL store
[["ancestor"],
["http://example.org/Nils"],
["http://example.org/Carl"]
]
![Page 24: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/24.jpg)
Department of Bioinformatics - BiGCaT 24
SPARQL for unit testing
results = rdf.sparql(s, unitTest1)
// expect 1 row
if (results.getRowCount() < 1) {
println (“FAIL: too little data!”)
}
![Page 25: #MIILS2013 Practical: Bioclipse for RDF minting](https://reader033.vdocuments.net/reader033/viewer/2022051612/54c673c04a7959f67d8b4622/html5/thumbnails/25.jpg)
Department of Bioinformatics - BiGCaT 25
Share your script via myExperiment