From 3bb6365594d168281019bdec303e70c123414ce4 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 4 Apr 2011 18:51:11 +0200 Subject: OT.isA substituted by RDF.type, identification of feature_types by RDF.type --- fminer.rb | 76 +++++++++++++++++++++++++++++++++++++++--------------------- last-utils | 2 +- lazar.rb | 74 +++++++++++++++++++++++++++++++++------------------------- libfminer | 2 +- openbabel.rb | 2 +- 5 files changed, 95 insertions(+), 61 deletions(-) diff --git a/fminer.rb b/fminer.rb index 0b18c01..92326b6 100644 --- a/fminer.rb +++ b/fminer.rb @@ -23,7 +23,7 @@ get "/fminer/bbrc/?" do DC.title => 'fminer backbone refinement class representatives', DC.creator => "andreas@maunz.de, helma@in-silico.ch", DC.contributor => "vorgrimmlerdavid@gmx.de", - OT.isA => OTA.PatternMiningSupervised, + RDF.type => [OTA.PatternMiningSupervised], OT.parameters => [ { DC.description => "Dataset URI", OT.paramScope => "mandatory", DC.title => "dataset_uri" }, { DC.description => "Feature URI for dependent variable", OT.paramScope => "mandatory", DC.title => "prediction_feature" }, @@ -44,7 +44,7 @@ get "/fminer/last/?" do DC.title => 'fminer latent structure class representatives', DC.creator => "andreas@maunz.de, helma@in-silico.ch", DC.contributor => "vorgrimmlerdavid@gmx.de", - OT.isA => OTA.PatternMiningSupervised, + RDF.type => [OTA.PatternMiningSupervised], OT.parameters => [ { DC.description => "Dataset URI", OT.paramScope => "mandatory", DC.title => "dataset_uri" }, { DC.description => "Feature URI for dependent variable", OT.paramScope => "mandatory", DC.title => "prediction_feature" }, @@ -70,7 +70,7 @@ post '/fminer/bbrc/?' do halt 404, "Please submit a dataset_uri." unless params[:dataset_uri] and !params[:dataset_uri].nil? halt 404, "Please submit a prediction_feature." unless params[:prediction_feature] and !params[:prediction_feature].nil? - prediction_feature = params[:prediction_feature] + prediction_feature = OpenTox::Feature.find params[:prediction_feature] training_dataset = OpenTox::Dataset.find "#{params[:dataset_uri]}", @subjectid halt 404, "No feature #{params[:prediction_feature]} in dataset #{params[:dataset_uri]}" unless training_dataset.features and training_dataset.features.include?(params[:prediction_feature]) @@ -88,6 +88,11 @@ post '/fminer/bbrc/?' do @@bbrc.SetBackbone(eval params[:backbone]) if params[:backbone] and ( params[:backbone] == "true" or params[:backbone] == "false" ) # convert string to boolean @@bbrc.SetChisqSig(params[:min_chisq_significance]) if params[:min_chisq_significance] @@bbrc.SetConsoleOut(false) + if prediction_feature.feature_type == "regression" + @@bbrc.SetRegression(true) + else + @training_classes = training_dataset.feature_classes(prediction_feature.uri) + end feature_dataset = OpenTox::Dataset.new(nil, @subjectid) feature_dataset.add_metadata({ @@ -119,21 +124,30 @@ post '/fminer/bbrc/?' do next end entry.each do |feature,values| - if feature == prediction_feature + if feature == prediction_feature.uri values.each do |value| if value.nil? LOGGER.warn "No #{feature} activiity for #{compound.to_s}." else - case value.to_s - when "true" - nr_active += 1 - activity = 1 - when "false" - nr_inactive += 1 - activity = 0 - else + if prediction_feature.feature_type == "classification" + case value.to_s + when "true" + nr_active += 1 + activity = 1 + when "false" + nr_inactive += 1 + activity = 0 + when /#{@training_classes.last}/ + nr_active += 1 + activity = 1 + when /#{@training_classes.first}/ + nr_inactive += 1 + activity = 0 + else + LOGGER.warn "Unknown class \"#{value.to_s}\"." + end + elsif prediction_feature.feature_type == "regression" activity = value.to_f - @@bbrc.SetRegression(true) end begin @@bbrc.AddCompound(smiles,id) @@ -192,7 +206,7 @@ post '/fminer/bbrc/?' do features << smarts metadata = { OT.hasSource => url_for('/fminer/bbrc', :full), - OT.isA => OT.Substructure, + RDF.type => [OT.Substructure], OT.smarts => smarts, OT.pValue => p_value.to_f, OT.effect => effect, @@ -283,23 +297,31 @@ post '/fminer/last/?' do if value.nil? LOGGER.warn "No #{feature} activiity for #{compound.to_s}." else - case value.to_s - when "true" - nr_active += 1 - activity = 1 - when "false" - nr_inactive += 1 - activity = 0 - else + if prediction_feature.feature_type == "classification" + case value.to_s + when "true" + nr_active += 1 + activity = 1 + when "false" + nr_inactive += 1 + activity = 0 + when /#{@training_classes.last}/ + nr_active += 1 + activity = 1 + when /#{@training_classes.first}/ + nr_inactive += 1 + activity = 0 + else + LOGGER.warn "Unknown class \"#{value.to_s}." + end + elsif prediction_feature.feature_type == "regression" activity = value.to_f - @@last.SetRegression(true) end begin - @@last.AddCompound(smiles,id) - @@last.AddActivity(activity, id) + @@bbrc.AddCompound(smiles,id) + @@bbrc.AddActivity(activity, id) all_activities[id]=activity # DV: insert global information compounds[id] = compound - smi[id] = smiles # AM LAST: changed this to store SMILES. id += 1 rescue LOGGER.warn "Could not add " + smiles + "\t" + value.to_s + " to fminer" @@ -340,7 +362,7 @@ post '/fminer/last/?' do unless features.include? smarts features << smarts metadata = { - OT.isA => OT.Substructure, + RDF.type => [OT.Substructure], OT.hasSource => feature_dataset.uri, OT.smarts => smarts, OT.pValue => p_value.to_f, diff --git a/last-utils b/last-utils index daafa32..75bea76 160000 --- a/last-utils +++ b/last-utils @@ -1 +1 @@ -Subproject commit daafa32e330b27111df6dc7193a6ed72fae2be45 +Subproject commit 75bea7645601fd296aa68c6678ee9b0a49a7b918 diff --git a/lazar.rb b/lazar.rb index 2f3ec28..af2740b 100644 --- a/lazar.rb +++ b/lazar.rb @@ -35,17 +35,17 @@ post '/lazar/?' do halt 404, "Dataset #{dataset_uri} not found." unless training_activities = OpenTox::Dataset.new(dataset_uri) training_activities.load_all(@subjectid) - prediction_feature = params[:prediction_feature] - unless prediction_feature # try to read prediction_feature from dataset + prediction_feature = OpenTox::Feature.find(params[:prediction_feature],@subjectid) + unless params[:prediction_feature] # try to read prediction_feature from dataset halt 404, "#{training_activities.features.size} features in dataset #{dataset_uri}. Please provide a prediction_feature parameter." unless training_activities.features.size == 1 - prediction_feature = training_activities.features.keys.first - params[:prediction_feature] = prediction_feature + prediction_feature = OpenTox::Feature.find(training_activities.features.keys.first,@subjectid) + #params[:prediction_feature] = prediction_feature end feature_generation_uri = @@feature_generation_default unless feature_generation_uri = params[:feature_generation_uri] - halt 404, "No feature #{prediction_feature} in dataset #{params[:dataset_uri]}. (features: "+ - training_activities.features.inspect+")" unless training_activities.features and training_activities.features.include?(prediction_feature) + halt 404, "No feature #{prediction_feature.uri} in dataset #{params[:dataset_uri]}. (features: "+ + training_activities.features.inspect+")" unless training_activities.features and training_activities.features.include?(prediction_feature.uri) task = OpenTox::Task.create("Create lazar model",url_for('/lazar',:full)) do |task| @@ -55,7 +55,7 @@ post '/lazar/?' do if params[:feature_dataset_uri] feature_dataset_uri = params[:feature_dataset_uri] training_features = OpenTox::Dataset.new(feature_dataset_uri) - case training_features.feature_type + case prediction_feature.feature_type when "classification" lazar.similarity_algorithm = "Similarity.tanimoto" when "regression" @@ -77,21 +77,23 @@ post '/lazar/?' do halt 404, "Dataset #{feature_dataset_uri} not found." if training_features.nil? # sorted features for index lookups - lazar.features = training_features.features.sort if training_features.feature_type == "regression" + lazar.features = training_features.features.sort if prediction_feature.feature_type == "regression" training_features.data_entries.each do |compound,entry| lazar.fingerprints[compound] = [] unless lazar.fingerprints[compound] entry.keys.each do |feature| if feature_generation_uri.match(/fminer/) - smarts = training_features.features[feature][OT.smarts] - lazar.fingerprints[compound] << smarts - unless lazar.features.include? smarts - lazar.features << smarts - lazar.p_values[smarts] = training_features.features[feature][OT.pValue] - lazar.effects[smarts] = training_features.features[feature][OT.effect] + if training_features.features[feature] + smarts = training_features.features[feature][OT.smarts] + lazar.fingerprints[compound] << smarts + unless lazar.features.include? smarts + lazar.features << smarts + lazar.p_values[smarts] = training_features.features[feature][OT.pValue] + lazar.effects[smarts] = training_features.features[feature][OT.effect] + end end else - case training_features.feature_type + case prediction_feature.feature_type when "classification" # fingerprints are sets if entry[feature].flatten.size == 1 @@ -107,43 +109,53 @@ post '/lazar/?' do else LOGGER.warn "More than one entry (#{entry[feature].inspect}) for compound #{compound}, feature #{feature}" end + lazar.prediction_algorithm = "Neighbors.local_svm_regression" end end end end + @training_classes = training_activities.feature_classes(prediction_feature.uri) if prediction_feature.feature_type == "classification" + training_activities.data_entries.each do |compound,entry| lazar.activities[compound] = [] unless lazar.activities[compound] - unless entry[params[:prediction_feature]].empty? - entry[params[:prediction_feature]].each do |value| - case value.to_s - when "true" - lazar.activities[compound] << true - when "false" - lazar.activities[compound] << false - else + unless entry[prediction_feature.uri].empty? + entry[prediction_feature.uri].each do |value| + if prediction_feature.feature_type == "classification" + case value.to_s + when "true" + lazar.activities[compound] << true + when "false" + lazar.activities[compound] << false + when /#{@training_classes.last}/ + lazar.activities[compound] << true + when /#{@training_classes.first}/ + lazar.activities[compound] << false + else + LOGGER.warn "Unknown class \"#{value.to_s}\"." + end + elsif prediction_feature.feature_type == "regression" halt 404, "0 values not allowed in training dataset. log10 is calculated internally." if value.to_f == 0 lazar.activities[compound] << value.to_f - lazar.prediction_algorithm = "Neighbors.local_svm_regression" end end end end - lazar.metadata[DC.title] = "lazar model for #{URI.decode(File.basename(prediction_feature))}" + lazar.metadata[DC.title] = "lazar model for #{URI.decode(File.basename(prediction_feature.uri))}" # TODO: fix dependentVariable - lazar.metadata[OT.dependentVariables] = params[:prediction_feature] + lazar.metadata[OT.dependentVariables] = prediction_feature.uri lazar.metadata[OT.trainingDataset] = dataset_uri lazar.metadata[OT.featureDataset] = feature_dataset_uri - if training_activities.feature_type.to_s == "classification" - lazar.metadata[OT.isA] = OTA.ClassificationLazySingleTarget - elsif training_activities.feature_type.to_s == "regression" - lazar.metadata[OT.isA] = OTA.RegressionLazySingleTarget + if prediction_feature.feature_type == "classification" + lazar.metadata[RDF.type] = [OTA.ClassificationLazySingleTarget] + elsif prediction_feature.feature_type == "regression" + lazar.metadata[RDF.type] = [OTA.RegressionLazySingleTarget] end lazar.metadata[OT.parameters] = [ {DC.title => "dataset_uri", OT.paramValue => dataset_uri}, - {DC.title => "prediction_feature", OT.paramValue => prediction_feature}, + {DC.title => "prediction_feature", OT.paramValue => prediction_feature.uri}, {DC.title => "feature_generation_uri", OT.paramValue => feature_generation_uri} ] diff --git a/libfminer b/libfminer index 01b8e50..d51f5e7 160000 --- a/libfminer +++ b/libfminer @@ -1 +1 @@ -Subproject commit 01b8e50e8e6fb3ce29fc8bf0a65a8c6f6af94b3f +Subproject commit d51f5e784ce0f5b7ef1c47c52ea55d1c874ec2e6 diff --git a/openbabel.rb b/openbabel.rb index 3a873c0..1644455 100644 --- a/openbabel.rb +++ b/openbabel.rb @@ -44,7 +44,7 @@ get '/openbabel/:property' do DC.title => params[:property], DC.creator => "helma@in-silico.ch", DC.description => description, - OT.isA => OTA.DescriptorCalculation, + RDF.type => [OTA.DescriptorCalculation], } response['Content-Type'] = 'application/rdf+xml' algorithm.to_rdfxml -- cgit v1.2.3 From 459458aaacda3b5a0e053ff5cd4a4a97e89186e4 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 5 Apr 2011 19:07:54 +0200 Subject: regression lazar and feature_type fixed --- fminer.rb | 12 ++++++++---- lazar.rb | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fminer.rb b/fminer.rb index 92326b6..ff192ca 100644 --- a/fminer.rb +++ b/fminer.rb @@ -71,7 +71,6 @@ post '/fminer/bbrc/?' do halt 404, "Please submit a dataset_uri." unless params[:dataset_uri] and !params[:dataset_uri].nil? halt 404, "Please submit a prediction_feature." unless params[:prediction_feature] and !params[:prediction_feature].nil? prediction_feature = OpenTox::Feature.find params[:prediction_feature] - training_dataset = OpenTox::Dataset.find "#{params[:dataset_uri]}", @subjectid halt 404, "No feature #{params[:prediction_feature]} in dataset #{params[:dataset_uri]}" unless training_dataset.features and training_dataset.features.include?(params[:prediction_feature]) @@ -243,7 +242,7 @@ post '/fminer/last/?' do halt 404, "Please submit a dataset_uri." unless params[:dataset_uri] and !params[:dataset_uri].nil? halt 404, "Please submit a prediction_feature." unless params[:prediction_feature] and !params[:prediction_feature].nil? - prediction_feature = params[:prediction_feature] + prediction_feature = OpenTox::Feature.find params[:prediction_feature] training_dataset = OpenTox::Dataset.new "#{params[:dataset_uri]}", @subjectid training_dataset.load_all(@subjectid) halt 404, "No feature #{params[:prediction_feature]} in dataset #{params[:dataset_uri]}" unless training_dataset.features and training_dataset.features.include?(params[:prediction_feature]) @@ -260,8 +259,13 @@ post '/fminer/last/?' do @@last.SetType(1) if params[:feature_type] == "paths" @@last.SetMaxHops(params[:hops]) if params[:hops] @@last.SetConsoleOut(false) + if prediction_feature.feature_type == "regression" + @@bbrc.SetRegression(true) + else + @training_classes = training_dataset.feature_classes(prediction_feature.uri) + end - feature_dataset = OpenTox::Dataset.new + feature_dataset = OpenTox::Dataset.new(nil, @subjectid) feature_dataset.add_metadata({ DC.title => "LAST representatives for " + training_dataset.metadata[DC.title].to_s, DC.creator => url_for('/fminer/last',:full), @@ -292,7 +296,7 @@ post '/fminer/last/?' do next end entry.each do |feature,values| - if feature == prediction_feature + if feature == prediction_feature.uri values.each do |value| if value.nil? LOGGER.warn "No #{feature} activiity for #{compound.to_s}." diff --git a/lazar.rb b/lazar.rb index af2740b..c2deb26 100644 --- a/lazar.rb +++ b/lazar.rb @@ -39,7 +39,7 @@ post '/lazar/?' do unless params[:prediction_feature] # try to read prediction_feature from dataset halt 404, "#{training_activities.features.size} features in dataset #{dataset_uri}. Please provide a prediction_feature parameter." unless training_activities.features.size == 1 prediction_feature = OpenTox::Feature.find(training_activities.features.keys.first,@subjectid) - #params[:prediction_feature] = prediction_feature + params[:prediction_feature] = prediction_feature.uri # pass to feature mining service end feature_generation_uri = @@feature_generation_default unless feature_generation_uri = params[:feature_generation_uri] @@ -77,12 +77,12 @@ post '/lazar/?' do halt 404, "Dataset #{feature_dataset_uri} not found." if training_features.nil? # sorted features for index lookups - lazar.features = training_features.features.sort if prediction_feature.feature_type == "regression" + lazar.features = training_features.features.sort if prediction_feature.feature_type == "regression" and lazar.feature_calculation_algorithm != "Substructure.match" training_features.data_entries.each do |compound,entry| lazar.fingerprints[compound] = [] unless lazar.fingerprints[compound] entry.keys.each do |feature| - if feature_generation_uri.match(/fminer/) + if lazar.feature_calculation_algorithm == "Substructure.match" if training_features.features[feature] smarts = training_features.features[feature][OT.smarts] lazar.fingerprints[compound] << smarts @@ -109,13 +109,13 @@ post '/lazar/?' do else LOGGER.warn "More than one entry (#{entry[feature].inspect}) for compound #{compound}, feature #{feature}" end - lazar.prediction_algorithm = "Neighbors.local_svm_regression" end end end end @training_classes = training_activities.feature_classes(prediction_feature.uri) if prediction_feature.feature_type == "classification" + lazar.prediction_algorithm = "Neighbors.local_svm_regression" if prediction_feature.feature_type == "regression" training_activities.data_entries.each do |compound,entry| lazar.activities[compound] = [] unless lazar.activities[compound] -- cgit v1.2.3 From f51e42b1bf600f0dfe5efe634174309983dab821 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 6 Apr 2011 09:45:36 +0200 Subject: A&A add subjectid to feature_type calls --- lazar.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lazar.rb b/lazar.rb index 2f3ec28..637b623 100644 --- a/lazar.rb +++ b/lazar.rb @@ -55,7 +55,7 @@ post '/lazar/?' do if params[:feature_dataset_uri] feature_dataset_uri = params[:feature_dataset_uri] training_features = OpenTox::Dataset.new(feature_dataset_uri) - case training_features.feature_type + case training_features.feature_type(@subjectid) when "classification" lazar.similarity_algorithm = "Similarity.tanimoto" when "regression" @@ -77,7 +77,7 @@ post '/lazar/?' do halt 404, "Dataset #{feature_dataset_uri} not found." if training_features.nil? # sorted features for index lookups - lazar.features = training_features.features.sort if training_features.feature_type == "regression" + lazar.features = training_features.features.sort if training_features.feature_type(@subjectid) == "regression" training_features.data_entries.each do |compound,entry| lazar.fingerprints[compound] = [] unless lazar.fingerprints[compound] @@ -91,7 +91,7 @@ post '/lazar/?' do lazar.effects[smarts] = training_features.features[feature][OT.effect] end else - case training_features.feature_type + case training_features.feature_type(@subjectid) when "classification" # fingerprints are sets if entry[feature].flatten.size == 1 @@ -135,9 +135,9 @@ post '/lazar/?' do lazar.metadata[OT.dependentVariables] = params[:prediction_feature] lazar.metadata[OT.trainingDataset] = dataset_uri lazar.metadata[OT.featureDataset] = feature_dataset_uri - if training_activities.feature_type.to_s == "classification" + if training_activities.feature_type(@subjectid).to_s == "classification" lazar.metadata[OT.isA] = OTA.ClassificationLazySingleTarget - elsif training_activities.feature_type.to_s == "regression" + elsif training_activities.feature_type(@subjectid).to_s == "regression" lazar.metadata[OT.isA] = OTA.RegressionLazySingleTarget end -- cgit v1.2.3 From a68a4564c29d915cc5e97d8563372131ada882ce Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 7 Apr 2011 09:55:58 +0200 Subject: remove subjectid for method OpenTox::Feature.feature_type --- lazar.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lazar.rb b/lazar.rb index a45886c..fa65b84 100644 --- a/lazar.rb +++ b/lazar.rb @@ -78,7 +78,7 @@ post '/lazar/?' do # sorted features for index lookups - lazar.features = training_features.features.sort if prediction_feature.feature_type(@subjectid) == "regression" and lazar.feature_calculation_algorithm != "Substructure.match" + lazar.features = training_features.features.sort if prediction_feature.feature_type == "regression" and lazar.feature_calculation_algorithm != "Substructure.match" training_features.data_entries.each do |compound,entry| lazar.fingerprints[compound] = [] unless lazar.fingerprints[compound] @@ -149,9 +149,9 @@ post '/lazar/?' do lazar.metadata[OT.trainingDataset] = dataset_uri lazar.metadata[OT.featureDataset] = feature_dataset_uri - if prediction_feature.feature_type(@subjectid) == "classification" + if prediction_feature.feature_type == "classification" lazar.metadata[RDF.type] = [OTA.ClassificationLazySingleTarget] - elsif prediction_feature.feature_type(@subjectid) == "regression" + elsif prediction_feature.feature_type == "regression" lazar.metadata[RDF.type] = [OTA.RegressionLazySingleTarget] end -- cgit v1.2.3 From 205d9cd79bf4090a49784307e2596e3220606702 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 8 Apr 2011 15:39:48 +0200 Subject: A&A fixes --- fminer.rb | 4 ++-- lazar.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fminer.rb b/fminer.rb index ff192ca..972f9ba 100644 --- a/fminer.rb +++ b/fminer.rb @@ -70,7 +70,7 @@ post '/fminer/bbrc/?' do halt 404, "Please submit a dataset_uri." unless params[:dataset_uri] and !params[:dataset_uri].nil? halt 404, "Please submit a prediction_feature." unless params[:prediction_feature] and !params[:prediction_feature].nil? - prediction_feature = OpenTox::Feature.find params[:prediction_feature] + prediction_feature = OpenTox::Feature.find params[:prediction_feature], @subjectid training_dataset = OpenTox::Dataset.find "#{params[:dataset_uri]}", @subjectid halt 404, "No feature #{params[:prediction_feature]} in dataset #{params[:dataset_uri]}" unless training_dataset.features and training_dataset.features.include?(params[:prediction_feature]) @@ -90,7 +90,7 @@ post '/fminer/bbrc/?' do if prediction_feature.feature_type == "regression" @@bbrc.SetRegression(true) else - @training_classes = training_dataset.feature_classes(prediction_feature.uri) + @training_classes = training_dataset.feature_classes(prediction_feature.uri, @subjectid) end feature_dataset = OpenTox::Dataset.new(nil, @subjectid) diff --git a/lazar.rb b/lazar.rb index fa65b84..e9fa264 100644 --- a/lazar.rb +++ b/lazar.rb @@ -115,7 +115,7 @@ post '/lazar/?' do end end - @training_classes = training_activities.feature_classes(prediction_feature.uri) if prediction_feature.feature_type == "classification" + @training_classes = training_activities.feature_classes(prediction_feature.uri, @subjectid) if prediction_feature.feature_type == "classification" lazar.prediction_algorithm = "Neighbors.local_svm_regression" if prediction_feature.feature_type == "regression" training_activities.data_entries.each do |compound,entry| -- cgit v1.2.3 From 662b7bab33bdcebdddbf7579211395a22317dc9d Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 28 Apr 2011 11:19:12 +0200 Subject: add subjectid --- fminer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fminer.rb b/fminer.rb index 972f9ba..c37dc93 100644 --- a/fminer.rb +++ b/fminer.rb @@ -242,7 +242,7 @@ post '/fminer/last/?' do halt 404, "Please submit a dataset_uri." unless params[:dataset_uri] and !params[:dataset_uri].nil? halt 404, "Please submit a prediction_feature." unless params[:prediction_feature] and !params[:prediction_feature].nil? - prediction_feature = OpenTox::Feature.find params[:prediction_feature] + prediction_feature = OpenTox::Feature.find params[:prediction_feature], @subjectid training_dataset = OpenTox::Dataset.new "#{params[:dataset_uri]}", @subjectid training_dataset.load_all(@subjectid) halt 404, "No feature #{params[:prediction_feature]} in dataset #{params[:dataset_uri]}" unless training_dataset.features and training_dataset.features.include?(params[:prediction_feature]) -- cgit v1.2.3 From ab8d03b9d9904aeb19e461a5d9bbaf03ae43bf2e Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 28 Apr 2011 11:21:01 +0200 Subject: fix bbrc to last --- fminer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fminer.rb b/fminer.rb index 8654c25..5ff952d 100644 --- a/fminer.rb +++ b/fminer.rb @@ -328,8 +328,8 @@ post '/fminer/last/?' do activity = value.to_f end begin - @@bbrc.AddCompound(smiles,id) - @@bbrc.AddActivity(activity, id) + @@last.AddCompound(smiles,id) + @@last.AddActivity(activity, id) all_activities[id]=activity # DV: insert global information compounds[id] = compound id += 1 -- cgit v1.2.3 From 84a08182ce116ebb874e97d367cc724126e2c163 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 4 May 2011 13:00:26 +0200 Subject: Fixed bug: Copy/Paste error (line 266), params[:min_chisq_significance] to_f --- fminer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fminer.rb b/fminer.rb index 5ff952d..2fb6008 100644 --- a/fminer.rb +++ b/fminer.rb @@ -88,7 +88,7 @@ post '/fminer/bbrc/?' do @@bbrc.SetMinfreq(minfreq) @@bbrc.SetType(1) if params[:feature_type] == "paths" @@bbrc.SetBackbone(eval params[:backbone]) if params[:backbone] and ( params[:backbone] == "true" or params[:backbone] == "false" ) # convert string to boolean - @@bbrc.SetChisqSig(params[:min_chisq_significance]) if params[:min_chisq_significance] + @@bbrc.SetChisqSig(params[:min_chisq_significance].to_f) if params[:min_chisq_significance] @@bbrc.SetConsoleOut(false) if prediction_feature.feature_type == "regression" @@bbrc.SetRegression(true) @@ -266,7 +266,7 @@ post '/fminer/last/?' do @@last.SetMaxHops(params[:hops]) if params[:hops] @@last.SetConsoleOut(false) if prediction_feature.feature_type == "regression" - @@bbrc.SetRegression(true) + @@last.SetRegression(true) else @training_classes = training_dataset.feature_classes(prediction_feature.uri) end @@ -359,7 +359,7 @@ post '/fminer/last/?' do end lu = LU.new # AM LAST: uses last-utils here - dom=lu.read(xml) # AM LAST: parse GraphML (needs hpricot, @ch: to be included in wrapper!) + dom=lu.read(xml) # AM LAST: parse GraphML smarts=lu.smarts_rb(dom,'nls') # AM LAST: converts patterns to LAST-SMARTS using msa variant (see last-pm.maunz.de) instances=lu.match_rb(smi,smarts) # AM LAST: creates instantiations instances.each do |smarts, ids| -- cgit v1.2.3 From 5b48b8b34d90d890caf4692b9f7440c18069f113 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 4 May 2011 14:02:42 +0200 Subject: fminer uses paths for regression --- lazar.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lazar.rb b/lazar.rb index e9fa264..31d64cb 100644 --- a/lazar.rb +++ b/lazar.rb @@ -69,6 +69,9 @@ post '/lazar/?' do halt 404, "External feature generation services not yet supported" end params[:subjectid] = @subjectid + if training_features.feature_type(@subjectid) == "regression" && feature_generation_uri.match(/fminer/) + params[:feature_type] = "paths" + end feature_dataset_uri = OpenTox::Algorithm::Generic.new(feature_generation_uri).run(params).to_s training_features = OpenTox::Dataset.new(feature_dataset_uri) end -- cgit v1.2.3 From 7eedae4359f7ba6c787ef115c3f70ff88e8ace93 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 4 May 2011 14:32:21 +0200 Subject: fix for previous commit (regression type) --- lazar.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lazar.rb b/lazar.rb index 31d64cb..45123f0 100644 --- a/lazar.rb +++ b/lazar.rb @@ -69,7 +69,8 @@ post '/lazar/?' do halt 404, "External feature generation services not yet supported" end params[:subjectid] = @subjectid - if training_features.feature_type(@subjectid) == "regression" && feature_generation_uri.match(/fminer/) + prediction_feature = OpenTox::Feature.find params[:prediction_feature], @subjectid + if prediction_feature.feature_type == "regression" && feature_generation_uri.match(/fminer/) params[:feature_type] = "paths" end feature_dataset_uri = OpenTox::Algorithm::Generic.new(feature_generation_uri).run(params).to_s -- cgit v1.2.3 From a54a9284f463b38aa5fb91ad84873e2a5ed3061b Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Thu, 5 May 2011 09:15:07 +0200 Subject: Added log10 to fminer activity values (regression) --- fminer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fminer.rb b/fminer.rb index 2fb6008..d706063 100644 --- a/fminer.rb +++ b/fminer.rb @@ -149,7 +149,7 @@ post '/fminer/bbrc/?' do LOGGER.warn "Unknown class \"#{value.to_s}\"." end elsif prediction_feature.feature_type == "regression" - activity = value.to_f + activity = Math.log10(value.to_f) end begin @@bbrc.AddCompound(smiles,id) -- cgit v1.2.3 From 22f93cc18d80ef206992abb9cb830540702ada88 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 6 May 2011 10:46:13 +0200 Subject: prediction_feature is object not uri --- lazar.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lazar.rb b/lazar.rb index 68d2fa9..45123f0 100644 --- a/lazar.rb +++ b/lazar.rb @@ -73,7 +73,6 @@ post '/lazar/?' do if prediction_feature.feature_type == "regression" && feature_generation_uri.match(/fminer/) params[:feature_type] = "paths" end - prediction_feature = prediction_feature.uri #hotfix this will change in future version see development branch 2011/04/06 mr feature_dataset_uri = OpenTox::Algorithm::Generic.new(feature_generation_uri).run(params).to_s training_features = OpenTox::Dataset.new(feature_dataset_uri) end -- cgit v1.2.3 From 5b9783ef4eee9a15e801c5781848d5bc9e488110 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Wed, 11 May 2011 01:37:47 -0700 Subject: Hotfix: p_value and SMARTS matching --- fminer.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fminer.rb b/fminer.rb index d706063..e0a0054 100644 --- a/fminer.rb +++ b/fminer.rb @@ -288,7 +288,7 @@ post '/fminer/last/?' do smi = [] # AM LAST: needed for matching the patterns back nr_active=0 nr_inactive=0 - all_activities = Hash.new# DV: for effect calculation in regression part + all_activities = Hash.new #DV: for effect calculation (class and regr) training_dataset.data_entries.each do |compound,entry| begin @@ -332,6 +332,7 @@ post '/fminer/last/?' do @@last.AddActivity(activity, id) all_activities[id]=activity # DV: insert global information compounds[id] = compound + smi[id] = smiles # AM LAST: changed this to store SMILES. id += 1 rescue LOGGER.warn "Could not add " + smiles + "\t" + value.to_s + " to fminer" @@ -342,8 +343,6 @@ post '/fminer/last/?' do end end - g_array=all_activities.values # DV: calculation of global median for effect calculation - g_median=OpenTox::Algorithm.median(g_array) raise "No compounds in dataset #{training_dataset.uri}" if compounds.size==0 @@ -375,7 +374,7 @@ post '/fminer/last/?' do RDF.type => [OT.Substructure], OT.hasSource => feature_dataset.uri, OT.smarts => smarts, - OT.pValue => p_value.to_f, + OT.pValue => p_value.to_f.abs, OT.effect => effect, OT.parameters => [ { DC.title => "dataset_uri", OT.paramValue => params[:dataset_uri] }, -- cgit v1.2.3 From 313d1077e1e3c10c4e50cea6b5cf03162115c697 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 16 May 2011 16:27:54 +0200 Subject: Fixed taking logs (only for exclusively non-negative values) --- fminer.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fminer.rb b/fminer.rb index e0a0054..35e1bad 100644 --- a/fminer.rb +++ b/fminer.rb @@ -125,6 +125,18 @@ post '/fminer/bbrc/?' do LOGGER.warn "Cannot find smiles for #{compound.to_s}." next end + + # AM: take log if appropriate + take_logs=true + entry.each do |feature,values| + values.each do |value| + if prediction_feature.feature_type == "regression" + if (! value.nil?) && (value.to_f < 0) + take_logs=false + end + end + end + end entry.each do |feature,values| if feature == prediction_feature.uri values.each do |value| @@ -149,7 +161,7 @@ post '/fminer/bbrc/?' do LOGGER.warn "Unknown class \"#{value.to_s}\"." end elsif prediction_feature.feature_type == "regression" - activity = Math.log10(value.to_f) + activity= take_logs ? Math.log10(value.to_f) : value.to_f end begin @@bbrc.AddCompound(smiles,id) -- cgit v1.2.3 From aec620e1e1df60dc4fa75470916fb7d624366aaa Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 23 May 2011 13:22:55 +0200 Subject: configure new version requested opentox-ruby gem --- application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.rb b/application.rb index e36643b..55a8ea4 100644 --- a/application.rb +++ b/application.rb @@ -3,7 +3,7 @@ require 'rubygems' require File.join(File.expand_path(File.dirname(__FILE__)), 'libfminer/libbbrc/bbrc') # has to be included before openbabel, otherwise we have strange SWIG overloading problems require File.join(File.expand_path(File.dirname(__FILE__)), 'libfminer/liblast/last') # has to be included before openbabel, otherwise we have strange SWIG overloading problems require File.join(File.expand_path(File.dirname(__FILE__)), 'last-utils/lu.rb') # AM LAST -gem "opentox-ruby", "~> 1" +gem "opentox-ruby", "~> 2" require 'opentox-ruby' #require 'smarts.rb' -- cgit v1.2.3