diff options
author | Christoph Helma <helma@in-silico.de> | 2010-01-07 12:22:47 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.de> | 2010-01-07 12:22:47 +0100 |
commit | c4d68eb599a6b563ac9967d3884ea31b0d619e38 (patch) | |
tree | 7fae9829ab42e04e39e34635b604ea8932c333bd | |
parent | f178a17d3318082dfa923582715b39d72bd07c32 (diff) | |
parent | be07d3be0cc3236a22a47f0905c99f96508c9587 (diff) |
find method fixed
-rw-r--r-- | lib/algorithm.rb | 9 | ||||
-rw-r--r-- | lib/compound.rb | 8 | ||||
-rw-r--r-- | lib/dataset.rb | 16 | ||||
-rw-r--r-- | lib/model.rb | 27 | ||||
-rw-r--r-- | lib/owl.rb | 2 | ||||
-rw-r--r-- | opentox-ruby-api-wrapper.gemspec | 12 |
6 files changed, 46 insertions, 28 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb index 7fe08fa..9918110 100644 --- a/lib/algorithm.rb +++ b/lib/algorithm.rb @@ -1,7 +1,7 @@ module OpenTox module Algorithm - class Fminer #< OpenTox + class Fminer include Owl def initialize @@ -20,7 +20,7 @@ module OpenTox end end - class Lazar #< OpenTox + class Lazar include Owl def initialize @@ -37,6 +37,11 @@ module OpenTox { :scope => "mandatory", :value => "feature_generation_uri" } } end + + def self.create_model(params) + @uri = RestClient.post File.join(@@config[:services]["opentox-algorithm"], "lazar"), :dataset_uri => params[:dataset_uri], :feature_uri => params[:feature_uri], :feature_generation_uri => File.join(@@config[:services]["opentox-algorithm"], "fminer") + end + end class Similarity diff --git a/lib/compound.rb b/lib/compound.rb index 9e1cee7..4385a7d 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -34,6 +34,14 @@ module OpenTox obconversion(@inchi,'inchi','sdf') end + def image + RestClient.get("#{@@cactus_uri}#{@inchi}/image") + end + + def image_uri + "#{@@cactus_uri}#{@inchi}/image" + end + # Matchs a smarts string def match?(smarts) obconversion = OpenBabel::OBConversion.new diff --git a/lib/dataset.rb b/lib/dataset.rb index 4d05e73..ad69038 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,9 @@ module OpenTox def self.find(uri) begin - dataset = Dataset.new - data = RestClient.get uri, :accept => 'application/rdf+xml' # check if the resource is available - dataset.rdf = data + dataset = Dataset.new + data = RestClient.get uri, :accept => 'application/rdf+xml' # check if the resource is available + dataset.rdf = data dataset rescue nil @@ -222,8 +223,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 @@ -12,7 +12,7 @@ module OpenTox # read OT Ontology #@parser.parse_into_model(@model,"http://opentox.org/data/documents/development/RDF%20files/OpenToxOntology/at_download/file") - @parser.parse_string_into_model(@model,File.read(File.join(File.dirname(__FILE__),"opentox.owl")),'/') + #@parser.parse_string_into_model(@model,File.read(File.join(File.dirname(__FILE__),"opentox.owl")),'/') # reate an anonymous resource for metadata # this has to be rewritten with an URI as soon as the resource has been saved at an definitive location tmp = @model.create_resource diff --git a/opentox-ruby-api-wrapper.gemspec b/opentox-ruby-api-wrapper.gemspec index eef00e9..424bae9 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| @@ -38,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<rest-client>, [">= 0"]) @@ -81,4 +84,3 @@ Gem::Specification.new do |s| s.add_dependency(%q<cucumber>, [">= 0"]) end end - |