diff options
author | Martin Gütlein <martin.guetlein@gmail.com> | 2010-03-24 10:21:37 +0100 |
---|---|---|
committer | Martin Gütlein <martin.guetlein@gmail.com> | 2010-03-24 10:21:37 +0100 |
commit | 7c6b9a46e012a3e541f63d245c344e5876d7da5e (patch) | |
tree | 8fac33200a981bf965b6f7917409418a050c84a2 /lib/model.rb | |
parent | 54d1c336501dd34785ca29a3393a9fd347097482 (diff) | |
parent | 95f6ca7e8c02daea41ae00b85807cae245142092 (diff) |
resolved conflicts
Diffstat (limited to 'lib/model.rb')
-rw-r--r-- | lib/model.rb | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/lib/model.rb b/lib/model.rb index b4ef86c..8877b84 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -1,44 +1,47 @@ module OpenTox module Model + + class Generic + + attr_accessor :predicted_variables, :independent_variables, :dependent_variables, :activity_dataset_uri, :feature_dataset_uri, :effects, :activities, :p_values, :fingerprints, :features, :algorithm + + def self.find(uri) + owl = OpenTox::Owl.from_uri(uri) + @title = owl.title + @source = owl.source + @identifier = owl.identifier.sub(/^\[/,'').sub(/\]$/,'') + @uri = @identifier + @algorithm = owl.algorithm + @dependent_variables = owl.dependentVariables + @independent_variables = owl.independentVariables + @predicted_variables = owl.predictedVariables + end + + end - class Lazar - include Owl - - PREDICTION_FEATURE_MODIFIER = "_lazar_prediction" + class Lazar < Generic - # Create a new prediction model from a dataset def initialize - super - self.source = "http://github.com/helma/opentox-model" - self.algorithm = File.join(@@config[:services]["opentox-algorithm"],"lazar") - self.independentVariables = File.join(@@config[:services]["opentox-algorithm"],"fminer#BBRC_representative") # TODO read this from dataset + @source = "http://github.com/helma/opentox-model" + @algorithm = File.join(@@config[:services]["opentox-algorithm"],"lazar") + #@independent_variables = File.join(@@config[:services]["opentox-algorithm"],"fminer#BBRC_representative") + @features = [] + @effects = {} + @activities = {} + @p_values = {} + @fingerprints = {} end - def self.from_yaml(yaml) - yaml = YAML.load yaml - lazar = Lazar.new - lazar.title = "lazar model for #{yaml[:endpoint]}" - lazar.parameters = { - "Dataset URI" => { :scope => "mandatory", :value => "dataset_uri=#{yaml[:activity_dataset]}" }, - "Feature URI for dependent variable" => { :scope => "mandatory", :value => "feature_uri=#{yaml[:endpoint]}" }, - "Feature generation URI" => { :scope => "mandatory", :value => "feature_generation_uri=#{File.join(@@config[:services]["opentox-algorithm"],"fminer")}"} #TODO write to yaml - } - lazar.algorithm = File.join(@@config[:services]["opentox-algorithm"],"lazar") - lazar.trainingDataset = yaml[:activity_dataset] - lazar.dependentVariables = yaml[:endpoint] - lazar.predictedVariables = yaml[:endpoint] + PREDICTION_FEATURE_MODIFIER - lazar + def save + @features.uniq! + resource = RestClient::Resource.new(@@config[:services]["opentox-model"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) + resource.post(self.to_yaml, :content_type => "application/x-yaml").chomp.to_s end def self.find_all - RestClient.get(@@config[:services]["opentox-model"]).split("\n") + RestClient.get(@@config[:services]["opentox-model"]).chomp.split("\n") end - - def self.find(uri) - yaml = RestClient.get(uri, :accept => "application/x-yaml") - OpenTox::Model::Lazar.from_yaml(yaml) - end - +=begin # Predict a compound def predict(compound) @@ -48,12 +51,12 @@ module OpenTox end def self.base_uri - @@config[:services]["opentox-model"] + File.join @@config[:services]["opentox-model"],'lazar' end def self.create(data) resource = RestClient::Resource.new(@@config[:services]["opentox-model"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) - resource.post(data, :content_type => "application/x-yaml").to_s + resource.post(data, :content_type => "application/x-yaml").chomp.to_s end def delete @@ -103,8 +106,8 @@ module OpenTox me = @model.subject(RDF['type'],OT[self.owl_class]) @model.add me, OT['predictedVariables'], Redland::Uri.new(predictedVariables) # untyped individual comes from this line, why?? @model.add Redland::Uri.new(predictedVariables), RDF['type'], OT['Feature'] - end - + end +=end end end end |