From be07d3be0cc3236a22a47f0905c99f96508c9587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20G=C3=BCtlein?= Date: Thu, 7 Jan 2010 08:56:18 +0100 Subject: minor changes: no nil classification, fix create datasets (no my librdf version) --- lib/dataset.rb | 17 +++++++++-------- lib/model.rb | 27 +++++++++++++++------------ opentox-ruby-api-wrapper.gemspec | 15 ++++++++------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/lib/dataset.rb b/lib/dataset.rb index 30f9644..0e7df13 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -47,8 +47,9 @@ module OpenTox @model.add tuple, OT['complexValue'], complex_value @model.add complex_value, RDF['type'], OT["FeatureValue"] @model.add complex_value, OT['feature'], f - @model.add complex_value, OT['value'], value.to_s - end + @model.add complex_value, OT['value'], value.to_s + end + tuple end @@ -77,7 +78,7 @@ module OpenTox end def self.create(data, content_type = 'application/rdf+xml') - uri = RestClient.post @@config[:services]["opentox-dataset"], data, :content_type => content_type + uri = RestClient.post @@config[:services]["opentox-dataset"], data, :content_type => content_type dataset = Dataset.new dataset.read uri.to_s dataset @@ -85,9 +86,10 @@ module OpenTox def self.find(uri) begin - RestClient.get uri, :accept => 'application/rdf+xml' # check if the resource is available - dataset = Dataset.new - dataset.read uri.to_s + data = RestClient.get uri, :accept => 'application/rdf+xml' # check if the resource is available + dataset = Dataset.new + dataset.rdf= data + dataset rescue nil @@ -222,8 +224,7 @@ module OpenTox :source => self.source, :identifier => self.identifier, :compounds => self.compounds.collect{|c| c.to_s.to_s.sub(/^\[(.*)\]$/,'\1')}, - :features => self.features.collect{|f| f.to_s }, - :data_entries => self.data_entries, + :features => self.features.collect{|f| f.to_s } }.to_yaml end diff --git a/lib/model.rb b/lib/model.rb index 2f4525a..cd35f09 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -1,6 +1,6 @@ module OpenTox module Model - + class Lazar include Owl @@ -87,25 +87,28 @@ module OpenTox end end end - end - + end + conf = conf/neighbors.size if conf > 0.0 classification = true elsif conf < 0.0 classification = false end - + compound = @dataset.find_or_create_compound(compound_uri) feature = @dataset.find_or_create_feature(@lazar[:endpoint]) - tuple = @dataset.create_tuple(feature,{ 'lazar#classification' => classification, 'lazar#confidence' => conf}) - @dataset.add_tuple compound,tuple - @predictions[compound_uri] = { @lazar[:endpoint] => { :lazar_prediction => { - :classification => classification, - :confidence => conf, - :neighbors => neighbors, - :features => compound_matches - } } } + + if (classification != nil) + tuple = @dataset.create_tuple(feature,{ 'lazar#classification' => classification, 'lazar#confidence' => conf}) + @dataset.add_tuple compound,tuple + @predictions[compound_uri] = { @lazar[:endpoint] => { :lazar_prediction => { + :classification => classification, + :confidence => conf, + :neighbors => neighbors, + :features => compound_matches + } } } + end end def self.base_uri diff --git a/opentox-ruby-api-wrapper.gemspec b/opentox-ruby-api-wrapper.gemspec index 41335e9..389b08a 100644 --- a/opentox-ruby-api-wrapper.gemspec +++ b/opentox-ruby-api-wrapper.gemspec @@ -1,6 +1,6 @@ # Generated by jeweler -# DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# DO NOT EDIT THIS FILE +# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` # -*- encoding: utf-8 -*- Gem::Specification.new do |s| @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Christoph Helma"] - s.date = %q{2009-12-20} + s.date = %q{2009-12-21} s.description = %q{Ruby wrapper for the OpenTox REST API (http://www.opentox.org)} s.email = %q{helma@in-silico.ch} s.executables = ["opentox-install-debian.sh", "yaml2owl.rb"] @@ -28,7 +28,6 @@ Gem::Specification.new do |s| "lib/compound.rb", "lib/dataset.rb", "lib/environment.rb", - "lib/feature.rb", "lib/helper.rb", "lib/model.rb", "lib/opentox-ruby-api-wrapper.rb", @@ -39,18 +38,21 @@ Gem::Specification.new do |s| "lib/tasks/opentox.rb", "lib/tasks/redis.rb", "lib/templates/config.ru", + "lib/templates/config.ru", + "lib/templates/config.yaml", "lib/templates/config.yaml", "lib/utils.rb" ] + s.has_rdoc = true s.homepage = %q{http://github.com/helma/opentox-ruby-api-wrapper} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.5} + s.rubygems_version = %q{1.3.1} s.summary = %q{Ruby wrapper for the OpenTox REST API} if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 + s.specification_version = 2 if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then s.add_runtime_dependency(%q, [">= 0"]) @@ -82,4 +84,3 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0"]) end end - -- cgit v1.2.3