summaryrefslogtreecommitdiff
path: root/application.rb
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2013-09-26 20:07:32 +0200
committergebele <gebele@in-silico.ch>2013-09-26 20:07:32 +0200
commit1ab8ed01b72ba501f175b0b1ef87ed62bbec8844 (patch)
tree0704aa45cbca8bd139e6360150626e5faac5c6d1 /application.rb
parent13ffab048630cc30a4af9e9113c1843ae5af0a09 (diff)
small edits for new model names
Diffstat (limited to 'application.rb')
-rw-r--r--application.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/application.rb b/application.rb
index 5cd5093..13d98cb 100644
--- a/application.rb
+++ b/application.rb
@@ -12,7 +12,7 @@ helpers do
# model uris must be manually added
@@models = []
CSV.foreach("./prediction_models.csv"){|uri| m = OpenTox::Model::Lazar.find uri[0]; @@models << m}
- #$logger.debug "model uris from csv file:\t#{@@models}\n"
+ $logger.debug "model uris from csv file:\t#{@@models}\n"
end
get '/?' do
@@ -55,7 +55,7 @@ get '/prediction/:model_uri/:type/:compound_uri/fingerprints/?' do
model = OpenTox::Model::Lazar.find params[:model_uri]
feature_dataset = OpenTox::Dataset.find model[RDF::OT.featureDataset]
@compound = OpenTox::Compound.new params[:compound_uri]
-
+ @significant_fragments = []
if @type =~ /classification/i
# collect all feature values with fingerprint
fingerprints = OpenTox::Algorithm::Descriptor.send("smarts_match", [@compound], feature_dataset.features.collect{ |f| f[RDF::DC.title]})[@compound.uri]
@@ -69,10 +69,16 @@ get '/prediction/:model_uri/:type/:compound_uri/fingerprints/?' do
@features = feature_dataset.features.collect{|f| f }
# search for each fingerprint in all features and collect feature values(smarts, pValue, effect)
- @significant_fragments = []
@fingerprint_values.each{ |fi, v| @features.each{ |f| @significant_fragments << [f[RDF::OT.effect].to_i, f[RDF::OT.smarts], f[RDF::OT.pValue]] if fi == f[RDF::OT.smarts] } }
else #regression
- @significant_fragments = []
+ feature_calc_algo = ""
+ model.parameters.each {|p|
+ if p[RDF::DC.title].to_s == "feature_calculation_algorithm"
+ feature_calc_algo = p[RDF::OT.paramValue].object
+ end
+ }
+ fingerprints = OpenTox::Algorithm::Descriptor.send( feature_calc_algo, [ @compound ], feature_dataset.features.collect{ |f| f[RDF::DC.title] } )
+ fingerprints.each{|x, h| h.each{|descriptor, value| @significant_fragments << [descriptor, [value]]}}
end
haml :significant_fragments, :layout => false
@@ -169,7 +175,7 @@ post '/predict/?' do
# selected model = model[0]
# compare selected with all models
@@models.each do |m|
- @prediction_models << m if m.title =~ /#{model[0]}/
+ @prediction_models << m if m.title =~ /#{model[0]}/i
end
end
@@ -205,4 +211,3 @@ get '/predict/stylesheets/:name.css' do
sass(:"stylesheets/#{params[:name]}", Compass.sass_engine_options )
end
-