summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2013-03-27 17:13:33 +0100
committerChristoph Helma <helma@in-silico.ch>2013-03-27 17:13:33 +0100
commit669137532e30d0601e0f47fa903b2c3cc275abba (patch)
treede389f24b6a7b4f55b81eaba5042317285291b21
parent3bb40e442ef7d206019a018ee4859b7de7582f83 (diff)
validation tests ok
-rw-r--r--lib/lazar.rb36
-rw-r--r--webapp/lazar.rb1
2 files changed, 19 insertions, 18 deletions
diff --git a/lib/lazar.rb b/lib/lazar.rb
index f731544..b85c13b 100644
--- a/lib/lazar.rb
+++ b/lib/lazar.rb
@@ -17,6 +17,7 @@ module OpenTox
params.each {|k,v|
self.class.class_eval { attr_accessor k.to_sym }
instance_variable_set "@#{k}", v
+ puts "#{k} => #{v}"
@prediction_dataset.parameters << {RDF::DC.title => k, RDF::OT.paramValue => v}
}
["cmpds", "fps", "acts", "n_prop", "q_prop", "neighbors"].each {|k|
@@ -24,21 +25,26 @@ module OpenTox
instance_variable_set("@#{k}", [])
}
+ puts "Loading #{@prediction_feature_uri}"
@prediction_feature = OpenTox::Feature.new(@prediction_feature_uri,@subjectid)
- # TODO: set feature type
- @predicted_variable = OpenTox::Feature.find_or_create({RDF::DC.title => "#{@prediction_feature.title} prediction", RDF.type => @prediction_feature[RDF.type]}, @subjectid)
- @predicted_confidence = OpenTox::Feature.find_or_create({RDF::DC.title => "#{@prediction_feature.title} confidence", RDF.type => [RDF::OT.Feature, RDF::OT.NumericFeature]}, @subjectid)
-
+ @predicted_variable = OpenTox::Feature.new @predicted_variable_uri, @subjectid
+ @predicted_confidence = OpenTox::Feature.new @predicted_confidence_uri, @subjectid
+ puts @predicted_variable.inspect
+ puts @predicted_confidence.inspect
+ puts "Setting metadata"
+ #@prediction_dataset.metadata = {
@prediction_dataset.metadata = {
RDF::DC.title => "Lazar prediction for #{@prediction_feature.title}",
RDF::DC.creator => @model_uri,
RDF::OT.hasSource => @model_uri,
RDF::OT.dependentVariables => @prediction_feature_uri,
- RDF::OT.predictedVariables => [@predicted_variable.uri,@predicted_confidence.uri]
+ RDF::OT.predictedVariables => [@predicted_variable_uri,@predicted_confidence_uri]
}
+ puts "Loading #{@training_dataset_uri}"
@training_dataset = OpenTox::Dataset.new(@training_dataset_uri,@subjectid)
+ puts "Loading #{@feature_dataset_uri}"
@feature_dataset = OpenTox::Dataset.new(@feature_dataset_uri, @subjectid)
bad_request_error "No features found in feature dataset #{@feature_dataset.uri}." if @feature_dataset.features.empty?
@@ -49,9 +55,10 @@ module OpenTox
prediction_feature_pos = @training_dataset.features.collect{|f| f.uri}.index @prediction_feature.uri
if @dataset_uri
- compounds = OpenTox::Dataset.find(@dataset_uri).compounds
+ puts "Loading #{@dataset_uri}"
+ compounds = OpenTox::Dataset.new(@dataset_uri,@subjectid).compounds
else
- compounds = [ OpenTox::Compound.new(@compound_uri) ]
+ compounds = [ OpenTox::Compound.new(@compound_uri,@subjectid) ]
end
compounds.each do |compound|
@@ -77,20 +84,12 @@ module OpenTox
#:lib => @model.lib
}
compound_fingerprints = OpenTox::Algorithm::FeatureValues.send( @feature_calculation_algorithm, compound_params, @subjectid )
- puts compound_fingerprints.inspect
@training_dataset.compounds.each_with_index { |cmpd, idx|
act = @training_dataset.data_entries[idx][prediction_feature_pos]
@acts << (@prediction_feature.feature_type=="classification" ? @prediction_feature.value_map.invert[act] : nil)
@n_prop << @feature_dataset.data_entries[idx]#.collect.to_a
@cmpds << cmpd.uri
}
- #puts "COMPOUNDS"
- #puts @n_prop.inspect
- puts @cmpds.inspect
- puts @fps.inspect
- puts @acts.inspect
- puts @n_prop.inspect
- puts @q_prop.inspect
@q_prop = @feature_dataset.features.collect { |f|
val = compound_fingerprints[f.title]
@@ -119,8 +118,8 @@ module OpenTox
end
- @prediction_dataset.add_data_entry compound, @predicted_variable, predicted_value
- @prediction_dataset.add_data_entry compound, @predicted_confidence, confidence_value
+ @prediction_dataset.add_data_entry compound, predicted_variable, predicted_value
+ @prediction_dataset.add_data_entry compound, predicted_confidence, confidence_value
if @compound_uri # add neighbors only for compound predictions
@neighbors.each do |neighbor|
@@ -158,6 +157,7 @@ module OpenTox
end
self[RDF::OT.trainingDataset] = training_dataset.uri
prediction_feature = OpenTox::Feature.new(params[:prediction_feature], @subjectid)
+ predicted_variable = OpenTox::Feature.find_or_create({RDF::DC.title => "#{prediction_feature.title} prediction", RDF.type => [RDF::OT.Feature, prediction_feature[RDF.type]]}, @subjectid)
self[RDF::DC.title] = prediction_feature.title
@parameters << {RDF::DC.title => "prediction_feature_uri", RDF::OT.paramValue => prediction_feature.uri}
self[RDF::OT.dependentVariables] = prediction_feature.uri
@@ -166,7 +166,7 @@ module OpenTox
@parameters << {RDF::DC.title => "prediction_algorithm", RDF::OT.paramValue => params[:prediction_algorithm]} if params[:prediction_algorithm]
confidence_feature = OpenTox::Feature.find_or_create({RDF::DC.title => "predicted_confidence", RDF.type => [RDF::OT.Feature, RDF::OT.NumericFeature]}, @subjectid)
- self[RDF::OT.predictedVariables] = [ prediction_feature.uri, confidence_feature.uri ]
+ self[RDF::OT.predictedVariables] = [ predicted_variable.uri, confidence_feature.uri ]
case prediction_feature.feature_type
when "classification"
@parameters << {RDF::DC.title => "prediction_algorithm", RDF::OT.paramValue => "weighted_majority_vote"} unless parameter_value "prediction_algorithm"
diff --git a/webapp/lazar.rb b/webapp/lazar.rb
index c40fc98..3700cd8 100644
--- a/webapp/lazar.rb
+++ b/webapp/lazar.rb
@@ -28,6 +28,7 @@ module OpenTox
# @param [optional,String] - further parameters for the feature generation service
# @return [text/uri-list] Task URI
post '/lazar/?' do
+ puts params.inspect
resource_not_found_error "Please provide a dataset_uri parameter." unless params[:dataset_uri]
resource_not_found_error "Dataset '#{params[:dataset_uri]}' not found." unless URI.accessible? params[:dataset_uri]
bad_request_error "Please provide a feature_generation_uri parameter." unless params[:feature_generation_uri]