opentox-ruby-api-wrapper 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/owl.rb CHANGED
@@ -2,7 +2,7 @@ module OpenTox
2
2
 
3
3
  module Owl
4
4
 
5
- attr_reader :uri, :model
5
+ attr_reader :uri
6
6
 
7
7
  def initialize
8
8
 
@@ -10,41 +10,74 @@ module OpenTox
10
10
  @parser = Redland::Parser.new
11
11
  @serializer = Redland::Serializer.ntriples
12
12
 
13
- # explicit typing
14
- # this should come from http://opentox.org/data/documents/development/RDF%20files/OpenToxOntology/at_download/file (does not pass OWL-DL validation)
15
- @parser.parse_into_model(@model,"http://opentox.org/data/documents/development/RDF%20files/OpenToxOntology/at_download/file")
16
- =begin
17
- @model.add @uri, RDF['type'], OWL['Ontology']
18
- # annotation properties
19
- @model.add DC['source'], RDF['type'], OWL["AnnotationProperty"]
20
- @model.add DC['identifier'], RDF['type'], OWL["AnnotationProperty"]
21
- @model.add DC['title'], RDF['type'], OWL["AnnotationProperty"]
22
- # object properties
23
- @model.add OT['feature'], RDF['type'], OWL["ObjectProperty"]
24
- @model.add OT['compound'], RDF['type'], OWL["ObjectProperty"]
25
- @model.add OT['values'], RDF['type'], OWL["ObjectProperty"]
26
- @model.add OT['tuple'], RDF['type'], OWL["ObjectProperty"] # added by ch
27
- @model.add OT['parameters'], RDF['type'], OWL["ObjectProperty"]
28
- # datatype properties
29
- @model.add OT['value'], RDF['type'], OWL["DatatypeProperty"]
30
- @model.add OT['paramValue'], RDF['type'], OWL["DatatypeProperty"]
31
- @model.add OT['paramScope'], RDF['type'], OWL["DatatypeProperty"]
32
- @model.add OT['hasSource'], RDF['type'], OWL["DatatypeProperty"]
33
- # classes
34
- @model.add OT['Dataset'], RDF['type'], OWL["Class"]
35
- @model.add OT['FeatureValue'], RDF['type'], OWL["Class"]
36
- @model.add OT['Tuple'], RDF['type'], OWL["Class"] # added by ch
37
- @model.add OT['Feature'], RDF['type'], OWL["Class"]
38
- @model.add OT['Compound'], RDF['type'], OWL["Class"]
39
- @model.add OT['DataEntry'], RDF['type'], OWL["Class"]
40
- @model.add OT['Parameter'], RDF['type'], OWL["Class"]
41
- @model.add OT['Algorithm'], RDF['type'], OWL["Class"]
42
- =end
13
+ # read OT Ontology
14
+ #@parser.parse_into_model(@model,"http://opentox.org/data/documents/development/RDF%20files/OpenToxOntology/at_download/file")
15
+ @parser.parse_string_into_model(@model,File.read(File.join(File.dirname(__FILE__),"opentox.owl")),'/')
16
+ # reate an anonymous resource for metadata
17
+ # this has to be rewritten with an URI as soon as the resource has been saved at an definitive location
18
+ tmp = @model.create_resource
19
+ @model.add tmp, RDF['type'], OWL['Ontology']
20
+ @model.add tmp, RDF['type'], OT[self.owl_class]
21
+ end
22
+
23
+ def uri=(uri)
24
+ @uri = uri
25
+ uri = Redland::Uri.new(uri)
26
+ # rewrite uri
27
+ @model.subjects(RDF['type'],OT[self.owl_class]).each do |me|
28
+ @model.delete(me,RDF['type'],OT[self.owl_class])
29
+ @model.add(uri,RDF['type'],OT[self.owl_class])
30
+ id = @model.object(me, DC['identifier'])
31
+ @model.delete me, DC['identifier'], id
32
+ # find/replace metadata
33
+ @model.find(me, nil, nil) do |s,p,o|
34
+ @model.delete s,p,o
35
+ @model.add uri,p,o
36
+ end
37
+ @model.add uri, DC['identifier'], @uri
38
+ end
39
+ end
40
+
41
+ def title
42
+ # I have no idea, why 2 subjects are returned
43
+ # iterating over all subjects leads to memory allocation problems
44
+ # SPARQL queries also do not work
45
+ me = @model.subjects(RDF['type'],OT[self.owl_class])[1]
46
+ @model.object(me, DC['title']).to_s
47
+ end
48
+
49
+ def title=(title)
50
+ me = @model.subject(RDF['type'],OT[self.owl_class])
51
+ begin
52
+ t = @model.object(me, DC['title'])
53
+ @model.delete me, DC['title'], t
54
+ rescue
55
+ end
56
+ @model.add me, DC['title'], title
57
+ end
58
+
59
+ def source
60
+ me = @model.subject(RDF['type'],OT[self.owl_class])
61
+ @model.object(me, DC['source']).to_s unless me.nil?
62
+ end
63
+
64
+ def source=(source)
65
+ me = @model.subject(RDF['type'],OT[self.owl_class])
66
+ begin
67
+ t = @model.object(me, DC['source'])
68
+ @model.delete me, DC['source'], t
69
+ rescue
70
+ end
71
+ @model.add me, DC['source'], source
72
+ end
73
+
74
+ def identifier
75
+ me = @model.subject(RDF['type'],OT[self.owl_class])
76
+ @model.object(me, DC['identifier']).to_s unless me.nil?
43
77
  end
44
78
 
45
79
  def owl_class
46
- self.class.to_s.sub(/^OpenTox::/,'')
47
- #@model.subject RDF['type'], OT[self.class.to_s.sub(/^OpenTox::/,'')]
80
+ self.class.to_s.sub(/^OpenTox::/,'').sub(/::.*$/,'')
48
81
  end
49
82
 
50
83
  def read(uri)
@@ -61,19 +94,10 @@ module OpenTox
61
94
  @model.to_string
62
95
  end
63
96
 
64
- def uri=(uri)
65
- identifier = uri
66
- end
67
-
68
97
  def to_ntriples
69
98
  @serializer.model_to_string(Redland::Uri.new(@uri), @model)
70
99
  end
71
100
 
72
- def title
73
- #puts OT[self.owl_class]
74
- @model.object(OT[self.owl_class], DC['title']).to_s
75
- end
76
-
77
101
  def parameters=(params)
78
102
  params.each do |name, settings|
79
103
  parameter = @model.create_resource
@@ -84,15 +108,14 @@ module OpenTox
84
108
  end
85
109
  end
86
110
 
111
+ =begin
87
112
  def create_owl_statement(name,value)
88
113
  r = @model.create_resource
89
114
  dc_class = DC[name.gsub(/^[a-z]/) { |a| a.upcase }] # capitalize only the first letter
115
+ #puts "DC:" + name.gsub(/^[a-z]/) { |a| a.upcase }
90
116
  @model.add dc_class, RDF['type'], OWL["Class"]
91
117
  @model.add r, RDF['type'], dc_class
92
118
  @model.add r, DC[name], value
93
- #puts r
94
- #puts DC[name.gsub(/^[a-z]/) { |a| a.upcase }] # capitalize only the first letter
95
- #puts DC[name] # capitalize only the first letter
96
119
  end
97
120
 
98
121
  def method_missing(name, *args)
@@ -103,6 +126,7 @@ module OpenTox
103
126
  raise "No method #{name}"
104
127
  end
105
128
  end
129
+ =end
106
130
 
107
131
  end
108
132
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentox-ruby-api-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christoph Helma
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-16 00:00:00 +01:00
13
- default_executable: opentox-install-debian.sh
12
+ date: 2009-12-20 00:00:00 +01:00
13
+ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -96,6 +96,7 @@ description: Ruby wrapper for the OpenTox REST API (http://www.opentox.org)
96
96
  email: helma@in-silico.ch
97
97
  executables:
98
98
  - opentox-install-debian.sh
99
+ - yaml2owl.rb
99
100
  extensions: []
100
101
 
101
102
  extra_rdoc_files:
@@ -107,6 +108,7 @@ files:
107
108
  - Rakefile
108
109
  - VERSION
109
110
  - bin/opentox-install-debian.sh
111
+ - bin/yaml2owl.rb
110
112
  - lib/algorithm.rb
111
113
  - lib/compound.rb
112
114
  - lib/dataset.rb
@@ -115,6 +117,7 @@ files:
115
117
  - lib/helper.rb
116
118
  - lib/model.rb
117
119
  - lib/opentox-ruby-api-wrapper.rb
120
+ - lib/opentox.owl
118
121
  - lib/owl.rb
119
122
  - lib/spork.rb
120
123
  - lib/task.rb