From 7327b1632cdaafd2d49d1ba8703a962f3c0e00d6 Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 10 Jan 2011 17:05:07 +0100 Subject: A&A --- lib/model.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/model.rb') diff --git a/lib/model.rb b/lib/model.rb index 953bb6c..32f5604 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -67,8 +67,8 @@ module OpenTox # Find a lazar model # @param [String] uri Model URI # @return [OpenTox::Model::Lazar] lazar model - def self.find(uri) - YAML.load RestClientWrapper.get(uri,:accept => 'application/x-yaml') + def self.find(uri, subjectid=nil) + YAML.load RestClientWrapper.get(uri,{:accept => 'application/x-yaml', :subjectid => subjectid}) end # Create a new lazar model @@ -90,8 +90,8 @@ module OpenTox # Predict a dataset # @param [String] dataset_uri Dataset URI # @return [OpenTox::Dataset] Dataset with predictions - def predict_dataset(dataset_uri) - @prediction_dataset = Dataset.create + def predict_dataset(dataset_uri, subjectid=nil) + @prediction_dataset = Dataset.create(CONFIG[:services]["opentox-dataset"], subjectid) @prediction_dataset.add_metadata({ OT.hasSource => @uri, DC.creator => @uri, @@ -101,9 +101,9 @@ module OpenTox d = Dataset.new(dataset_uri) d.load_compounds d.compounds.each do |compound_uri| - predict(compound_uri,false) + predict(compound_uri,false,subjectid) end - @prediction_dataset.save + @prediction_dataset.save(subjectid) @prediction_dataset end @@ -129,7 +129,7 @@ module OpenTox } ) end - return @prediction_dataset if database_activity + return @prediction_dataset if database_activity(subjectid) neighbors prediction = eval("#{@prediction_algorithm}(@neighbors,{:similarity_algorithm => @similarity_algorithm, :p_values => @p_values})") @@ -245,11 +245,11 @@ module OpenTox # Find database activities and store them in @prediction_dataset # @return [Boolean] true if compound has databasse activities, false if not - def database_activity + def database_activity(subjectid) if @activities[@compound.uri] @activities[@compound.uri].each { |act| @prediction_dataset.add @compound.uri, @metadata[OT.dependentVariables], act } @prediction_dataset.add_metadata(OT.hasSource => @metadata[OT.trainingDataset]) - @prediction_dataset.save + @prediction_dataset.save(subjectid) true else false @@ -262,8 +262,8 @@ module OpenTox end # Delete model at model service - def delete - RestClientWrapper.delete @uri unless @uri == CONFIG[:services]["opentox-model"] + def delete(subjectid) + RestClientWrapper.delete(@uri, :subjectid => subjectid) unless @uri == CONFIG[:services]["opentox-model"] end end -- cgit v1.2.3 From ecdd0347a347bd2ac5fa9e6a41ec7475b007309d Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 10 Jan 2011 17:47:09 +0100 Subject: A&A extent --- lib/model.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/model.rb') diff --git a/lib/model.rb b/lib/model.rb index 32f5604..7aa3f5c 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -60,8 +60,8 @@ module OpenTox # Get URIs of all lazar models # @return [Array] List of lazar model URIs - def self.all - RestClientWrapper.get(CONFIG[:services]["opentox-model"]).to_s.split("\n") + def self.all(subjectid=nil) + RestClientWrapper.get(CONFIG[:services]["opentox-model"], :subjectid => subjectid).to_s.split("\n") end # Find a lazar model @@ -77,7 +77,7 @@ module OpenTox def self.create(params) lazar_algorithm = OpenTox::Algorithm::Generic.new File.join( CONFIG[:services]["opentox-algorithm"],"lazar") model_uri = lazar_algorithm.run(params) - OpenTox::Model::Lazar.find(model_uri) + OpenTox::Model::Lazar.find(model_uri, params[:subjectid]) end # Get a parameter value @@ -98,7 +98,7 @@ module OpenTox DC.title => URI.decode(File.basename( @metadata[OT.dependentVariables] )), OT.parameters => [{DC.title => "dataset_uri", OT.paramValue => dataset_uri}] }) - d = Dataset.new(dataset_uri) + d = Dataset.new(dataset_uri,subjectid) d.load_compounds d.compounds.each do |compound_uri| predict(compound_uri,false,subjectid) -- cgit v1.2.3 From 2aafed7543287c420a5aa2e751b8c74ad771d14c Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 13 Jan 2011 12:01:19 +0100 Subject: A&A for GET requests --- lib/model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/model.rb') diff --git a/lib/model.rb b/lib/model.rb index 7aa3f5c..6ef4af2 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -99,7 +99,7 @@ module OpenTox OT.parameters => [{DC.title => "dataset_uri", OT.paramValue => dataset_uri}] }) d = Dataset.new(dataset_uri,subjectid) - d.load_compounds + d.load_compounds(subjectid) d.compounds.each do |compound_uri| predict(compound_uri,false,subjectid) end -- cgit v1.2.3