summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.de>2010-01-07 12:22:47 +0100
committerChristoph Helma <helma@in-silico.de>2010-01-07 12:22:47 +0100
commitc4d68eb599a6b563ac9967d3884ea31b0d619e38 (patch)
tree7fae9829ab42e04e39e34635b604ea8932c333bd /lib
parentf178a17d3318082dfa923582715b39d72bd07c32 (diff)
parentbe07d3be0cc3236a22a47f0905c99f96508c9587 (diff)
find method fixed
Diffstat (limited to 'lib')
-rw-r--r--lib/algorithm.rb9
-rw-r--r--lib/compound.rb8
-rw-r--r--lib/dataset.rb16
-rw-r--r--lib/model.rb27
-rw-r--r--lib/owl.rb2
5 files changed, 39 insertions, 23 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
diff --git a/lib/owl.rb b/lib/owl.rb
index d9da563..9cb73f2 100644
--- a/lib/owl.rb
+++ b/lib/owl.rb
@@ -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