diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-02-19 11:28:29 +0100 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-02-19 11:28:29 +0100 |
commit | e77fd138b4de5e467ded21ef075828e2b04e7928 (patch) | |
tree | bfbf27fae3084681110e3bd32c30792f0b3df250 | |
parent | 299552130b7deb821f7de544f153a9ebf00929db (diff) |
add subject-id to to-html, minor changes
-rwxr-xr-x | application.rb | 2 | ||||
-rwxr-xr-x | lib/ot_predictions.rb | 1 | ||||
-rwxr-xr-x | reach_reports/reach_application.rb | 6 | ||||
-rwxr-xr-x | reach_reports/reach_test.rb | 17 | ||||
-rwxr-xr-x | report/report_application.rb | 6 | ||||
-rwxr-xr-x | test/test_examples.rb | 5 | ||||
-rw-r--r-- | test/unit_test.rb | 12 | ||||
-rwxr-xr-x | validation/validation_application.rb | 22 | ||||
-rwxr-xr-x | validation/validation_test.rb | 67 |
9 files changed, 97 insertions, 41 deletions
diff --git a/application.rb b/application.rb index c18b05e..f543167 100755 --- a/application.rb +++ b/application.rb @@ -19,7 +19,7 @@ get '/examples/?' do if request.env['HTTP_ACCEPT'] =~ /text\/html/ content_type "text/html" - OpenTox.text_to_html Example.transform_example + OpenTox.text_to_html Example.transform_example,@subjectid else content_type "text/plain" Example.transform_example diff --git a/lib/ot_predictions.rb b/lib/ot_predictions.rb index 9b1ee51..116b4db 100755 --- a/lib/ot_predictions.rb +++ b/lib/ot_predictions.rb @@ -51,7 +51,6 @@ module Lib "available features are: "+test_target_dataset.features.inspect if test_target_dataset.features.keys.index(prediction_feature)==nil end - test_dataset.load_all(subjectid) @compounds = test_dataset.compounds LOGGER.debug "test dataset size: "+@compounds.size.to_s raise "test dataset is empty "+test_dataset_uri.to_s unless @compounds.size>0 diff --git a/reach_reports/reach_application.rb b/reach_reports/reach_application.rb index 293a5ac..fc670fd 100755 --- a/reach_reports/reach_application.rb +++ b/reach_reports/reach_application.rb @@ -24,7 +24,7 @@ get '/reach_report' do "Validation reporting: "+url_for("/report",:full) description = "A list of all suported REACH reporting types." - OpenTox.text_to_html uri_list,related_links,description + OpenTox.text_to_html uri_list,related_links,description, @subjectid else content_type "text/uri-list" uri_list @@ -51,7 +51,7 @@ get '/reach_report/:type' do when /(?i)QPRF/ #TODO end - OpenTox.text_to_html ReachReports.list_reports(type),related_links,description,post_params + OpenTox.text_to_html ReachReports.list_reports(type),@subjectid,related_links,description,post_params else content_type "text/uri-list" ReachReports.list_reports(type) @@ -98,7 +98,7 @@ get '/reach_report/:type/:id' do "All "+type+" reports: "+url_for("/reach_report/"+type,:full) description = "A QMRF report." - OpenTox.text_to_html rep.to_yaml,related_links,description + OpenTox.text_to_html rep.to_yaml,@subjectid,related_links,description when /application\/x-yaml|\*\/\*|^$/ # matches 'application/x-yaml', '*/*', '' content_type "application/x-yaml" rep.to_yaml diff --git a/reach_reports/reach_test.rb b/reach_reports/reach_test.rb index 47e5158..87addfa 100755 --- a/reach_reports/reach_test.rb +++ b/reach_reports/reach_test.rb @@ -20,10 +20,10 @@ LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S " LOGGER.formatter = Logger::Formatter.new if AA_SERVER - TEST_USER = "mgtest" - TEST_PW = "mgpasswd" -# TEST_USER = "guest" -# TEST_PW = "guest" + #TEST_USER = "mgtest" + #TEST_PW = "mgpasswd" + TEST_USER = "guest" + TEST_PW = "guest" SUBJECTID = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) raise "could not log in" unless SUBJECTID puts "logged in: "+SUBJECTID.to_s @@ -148,7 +148,10 @@ class ReachTest < Test::Unit::TestCase #model_uri = "http://local-ot/majority/class/model/58" - model_uri = "http://local-ot/model/104" + + #model_uri = "http://local-ot/model/104" + model_uri = "http://local-ot/majority/class/model/125" + # m = OpenTox::Model::Generic.find(model_uri) # puts m.metadata[OT.algorithm] if m @@ -156,12 +159,14 @@ class ReachTest < Test::Unit::TestCase # puts a.metadata.inspect # exit + puts SUBJECTID + # model_uri = "http://local-ot/model/1" #http://local-ot/majority/class/model/15 #model_uri = "http://local-ot/majority/class/model/15" # model_uri = "http://local-ot/majority/class/model/91" #model_uri = "http://apps.ideaconsult.net:8080/ambit2/model/2" - post '/reach_report/qmrf', {:model_uri=>model_uri}, {:subjectid => SUBJECTID} #http://local-ot/model/1" + post '/reach_report/qmrf',{:model_uri=>model_uri, :subjectid => SUBJECTID} #http://local-ot/model/1" ##post '/reach_report/qprf',:compound_uri=>"http://local-ot/compound/XYZ" uri = last_response.body puts "task: "+uri.to_s diff --git a/report/report_application.rb b/report/report_application.rb index ab3d91b..5a47063 100755 --- a/report/report_application.rb +++ b/report/report_application.rb @@ -38,7 +38,7 @@ get '/report/?' do description = "A list of all report types." content_type "text/html" - OpenTox.text_to_html rs.get_report_types,related_links,description + OpenTox.text_to_html rs.get_report_types,@subjectid,related_links,description else content_type "text/uri-list" rs.get_report_types @@ -58,7 +58,7 @@ get '/report/:report_type' do "A list of all "+params[:report_type]+" reports. To create a report, use the POST method." post_params = [[:validation_uris]] content_type "text/html" - OpenTox.text_to_html rs.get_all_reports(params[:report_type], params),related_links,description,post_params + OpenTox.text_to_html rs.get_all_reports(params[:report_type], params),@subjectid,related_links,description,post_params else content_type "text/uri-list" rs.get_all_reports(params[:report_type], params) @@ -89,8 +89,6 @@ get '/report/:type/:id' do result = body(File.new(report)) end end - - response.set_cookie("subjectid", @subjectid) end #OpenTox::Authorization.whitelist( Regexp.new("/report/.*/[0-9]+/.*"),"GET") diff --git a/test/test_examples.rb b/test/test_examples.rb index 53f1f81..503bc13 100755 --- a/test/test_examples.rb +++ b/test/test_examples.rb @@ -381,8 +381,9 @@ module ValidationExamples class AmbitModelValidation < ModelValidation def initialize - @model_uri = "https://ambit.uni-plovdiv.bg:8443/ambit2/model/29139" - @test_dataset_uri = "https://ambit.uni-plovdiv.bg:8443/ambit2/dataset/R401560" + @model_uri = "https://ambit.uni-plovdiv.bg:8443/ambit2/model/39319" + #@model_uri = "https://ambit.uni-plovdiv.bg:8443/ambit2/model/29139" + @test_dataset_uri = "https://ambit.uni-plovdiv.bg:8443/ambit2/dataset/R401577?max=3" end end diff --git a/test/unit_test.rb b/test/unit_test.rb index 26fc17e..11b0759 100644 --- a/test/unit_test.rb +++ b/test/unit_test.rb @@ -97,7 +97,7 @@ class ValidationTest < Test::Unit::TestCase end def test_crossvalidation_report - #@@cv = OpenTox::Crossvalidation.find("http://local-ot/validation/crossvalidation/47", @@subjectid) + #@@cv = OpenTox::Crossvalidation.find("http://local-ot/validation/crossvalidation/48", @@subjectid) puts "test_crossvalidation_report" assert defined?@@cv,"no crossvalidation defined" @@ -117,12 +117,12 @@ class ValidationTest < Test::Unit::TestCase OpenTox::CrossvalidationReport.find(report.uri) end end - report_uri = OpenTox::CrossvalidationReport.find(report.uri,@@subjectid) - assert report_uri.uri? + report = OpenTox::CrossvalidationReport.find(report.uri,@@subjectid) + assert report.uri.uri? report2 = OpenTox::CrossvalidationReport.find_for_crossvalidation(@@cv.uri,@@subjectid) - assert_equal report_uri,report2.uri - report3 = @@cv.find_or_create_report(@@subjectid) - assert_equal report_uri,report3.uri + assert_equal report.uri,report2.uri + report3_uri = @@cv.find_or_create_report(@@subjectid) + assert_equal report.uri,report3_uri @report = report2 end diff --git a/validation/validation_application.rb b/validation/validation_application.rb index 9b517cf..e07acf0 100755 --- a/validation/validation_application.rb +++ b/validation/validation_application.rb @@ -22,7 +22,7 @@ get '/crossvalidation/?' do "Use the POST method to perform a crossvalidation." post_params = [[:dataset_uri,:algorithm_uri,:prediction_feature,[:num_folds,10],[:random_seed,1],[:stratified,false],[:algorithm_params,""]]] content_type "text/html" - OpenTox.text_to_html uri_list,related_links,description,post_params + OpenTox.text_to_html uri_list,@subjectid,related_links,description,post_params else content_type "text/uri-list" uri_list @@ -101,7 +101,7 @@ get '/crossvalidation/:id' do description = "A crossvalidation resource." content_type "text/html" - OpenTox.text_to_html crossvalidation.to_yaml,related_links,description + OpenTox.text_to_html crossvalidation.to_yaml,@subjectid,related_links,description when /application\/x-yaml|\*\/\*/ content_type "application/x-yaml" crossvalidation.to_yaml @@ -139,7 +139,7 @@ get '/crossvalidation/:id/statistics' do description = "The averaged statistics for the crossvalidation." content_type "text/html" - OpenTox.text_to_html v.to_yaml,related_links,description + OpenTox.text_to_html v.to_yaml,@subjectid,related_links,description else content_type "application/x-yaml" v.to_yaml @@ -196,7 +196,7 @@ get '/crossvalidation/:id/predictions' do related_links = "All crossvalidations: "+url_for("/crossvalidation",:full)+"\n"+ "Correspoding crossvalidation: "+url_for("/crossvalidation/"+params[:id],:full) - OpenTox.text_to_html p, related_links, description + OpenTox.text_to_html p,@subjectid, related_links, description else content_type "text/x-yaml" p @@ -226,7 +226,7 @@ get '/?' do "A validation web service for the OpenTox project ( http://opentox.org ).\n"+ "In the root directory (this is where you are now), a list of all validation resources is returned." content_type "text/html" - OpenTox.text_to_html uri_list,related_links,description + OpenTox.text_to_html uri_list,@subjectid,related_links,description else content_type "text/uri-list" uri_list @@ -274,7 +274,7 @@ get '/test_set_validation' do "To perform a test-set-validation use the POST method." post_params = [[:model_uri, :test_dataset_uri, [:test_target_dataset_uri,"same-as-test_dataset_uri"], [:prediction_feature, "dependent-variable-of-model"]]] content_type "text/html" - OpenTox.text_to_html uri_list,related_links,description,post_params + OpenTox.text_to_html uri_list,@subjectid,related_links,description,post_params else content_type "text/uri-list" uri_list @@ -323,7 +323,7 @@ get '/training_test_validation' do :prediction_feature, [:algorithm_params, ""]]] content_type "text/html" - OpenTox.text_to_html uri_list,related_links,description,post_params + OpenTox.text_to_html uri_list,@subjectid,related_links,description,post_params else content_type "text/uri-list" uri_list @@ -371,7 +371,7 @@ get '/bootstrapping' do [:algorithm_params, ""], [:random_seed, 1]]] content_type "text/html" - OpenTox.text_to_html uri_list,related_links,description,post_params + OpenTox.text_to_html uri_list,@subjectid,related_links,description,post_params else content_type "text/uri-list" uri_list @@ -423,7 +423,7 @@ get '/training_test_split' do [:random_seed, 1], [:split_ratio, 0.66]]] content_type "text/html" - OpenTox.text_to_html uri_list,related_links,description,post_params + OpenTox.text_to_html uri_list,@subjectid,related_links,description,post_params else content_type "text/uri-list" uri_list @@ -502,7 +502,7 @@ get '/:id/predictions' do related_links = "All validations: "+url_for("/",:full)+"\n"+ "Correspoding validation: "+url_for("/"+params[:id],:full) - OpenTox.text_to_html p.to_array.to_yaml, related_links, description + OpenTox.text_to_html p.to_array.to_yaml,@subjectid, related_links, description else content_type "text/x-yaml" p.to_array.to_yaml @@ -548,7 +548,7 @@ get '/:id' do "Get validation predictions: "+url_for("/"+params[:id]+"/predictions",:full)+"\n"+ "All validations: "+url_for("/",:full)+"\n"+ "All validation reports: "+url_for("/report/validation",:full) - OpenTox.text_to_html validation.to_yaml,related_links,description + OpenTox.text_to_html validation.to_yaml,@subjectid,related_links,description else #default is yaml content_type "application/x-yaml" validation.to_yaml diff --git a/validation/validation_test.rb b/validation/validation_test.rb index e39dbeb..3f10ca2 100755 --- a/validation/validation_test.rb +++ b/validation/validation_test.rb @@ -20,10 +20,10 @@ LOGGER.datetime_format = "%Y-%m-%d %H:%M:%S " LOGGER.formatter = Logger::Formatter.new if AA_SERVER - #TEST_USER = "mgtest" - #TEST_PW = "mgpasswd" - TEST_USER = "guest" - TEST_PW = "guest" + TEST_USER = "mgtest" + TEST_PW = "mgpasswd" + #TEST_USER = "guest" + #TEST_PW = "guest" SUBJECTID = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) raise "could not log in" unless SUBJECTID puts "logged in: "+SUBJECTID.to_s @@ -60,6 +60,10 @@ class ValidationTest < Test::Unit::TestCase begin $test_case = self +# prediction_feature = "https://ambit.uni-plovdiv.bg:8443/ambit2/feature/26221" +# puts OpenTox::Feature.find(prediction_feature).domain.inspect +# exit + # begin # #OpenTox::RestClientWrapper.get "http://local-ot/validation/runtime-error",{:accept => "application/rdf+xml"} # puts OpenTox::RestClientWrapper.post "http://opentox.ntua.gr:4000/model/0d8a9a27-3481-4450-bca1-d420a791de9d", @@ -151,12 +155,61 @@ class ValidationTest < Test::Unit::TestCase # val = wait_for_task(uri) # puts val # get "/"+val.split("/")[-1] - + +# post "/validate_datasets",{ +# :test_dataset_uri=>"http://opentox.informatik.uni-freiburg.de/dataset/409", +# :prediction_dataset_uri=>"http://opentox.informatik.uni-freiburg.de/dataset/410", +# :test_target_dataset_uri=>"https://ambit.uni-plovdiv.bg:8443/ambit2/dataset/R401560", +# :prediction_feature=>"https://ambit.uni-plovdiv.bg:8443/ambit2/feature/22190", +# :predicted_feature=>"https://ambit.uni-plovdiv.bg:8443/ambit2/feature/218304", +# :regression=>"true", +# :subjectid=>SUBJECTID} +# #:model_uri=>"http://local-ot/model/31"} +# #:regression=>"true"} +# # :classification=>"true"} +# uri = last_response.body +# val = wait_for_task(uri) +# puts val +# #get "/"+val.split("/")[-1] + + + + #ambit_service = "https://ambit.uni-plovdiv.bg:8443/ambit2" + #https%3A%2F%2Fambit.uni-plovdiv.bg%3A8443%2Fambit2 + +# post "/validate_datasets",{ +# :test_dataset_uri=>ambit_service+"/dataset/R401577?max=50", +# :prediction_dataset_uri=>ambit_service+"/dataset/R401577?max=50&feature_uris[]="+CGI.escape(ambit_service)+"%2Fmodel%2F35194%2Fpredicted", +# #:test_target_dataset_uri=>ambit_service+"/dataset/R401560", +# :prediction_feature=>ambit_service+"/feature/26221", +# :predicted_feature=>ambit_service+"/feature/218699", +# :classification=>"true", +# :subjectid=>SUBJECTID} +# #:model_uri=>"http://local-ot/model/31"} +# #:regression=>"true"} +# # :classification=>"true"} +# uri = last_response.body +# val = wait_for_task(uri) +# puts val +# #get "/"+val.split("/")[-1] + + # d = OpenTox::Dataset.find("https://ambit.uni-plovdiv.bg:8443/ambit2/dataset/R545",SUBJECTID) # puts d.compounds.inspect # exit + +# f = File.new("data/ambit-dataset.rdf") +# d = ValidationExamples::Util.upload_dataset(f, SUBJECTID) +# puts d + +# d = OpenTox::Dataset.find("https://ambit.uni-plovdiv.bg:8443/ambit2/dataset/R401560",SUBJECTID) +# #puts d.compounds.to_yaml +# #puts d.features.keys.to_yaml +# puts d.to_yaml +# d2 = d.split(d.compounds[0..5], d.features.keys[0..1], {}, SUBJECTID) +# puts d2.to_yaml - run_test("21a")#,:validation_uri=>"http://local-ot/validation/253") #,"http://local-ot/validation/28")#,"http://local-ot/validation/394"); + run_test("1b")#,:validation_uri=>"http://local-ot/validation/253") #,"http://local-ot/validation/28")#,"http://local-ot/validation/394"); #run_test("3b",:validation_uri=>"http://local-ot/validation/crossvalidation/45") #,{:dataset_uri => "http://local-ot/dataset/773", :prediction_feature => "http://local-ot/dataset/773/feature/Hamster%20Carcinogenicity"}) @@ -175,7 +228,7 @@ class ValidationTest < Test::Unit::TestCase #puts OpenTox::Authorization.list_policy_uris(SUBJECTID).inspect -# run_test("16b") #,{:dataset_uri => "http://local-ot/dataset/313", :prediction_feature => "http://local-ot/dataset/313/feature/repdose_classification"}) + #run_test("19d") #,{:dataset_uri => "http://local-ot/dataset/313", :prediction_feature => "http://local-ot/dataset/313/feature/repdose_classification"}) # model = OpenTox::Model::Generic.find("http://local-ot/majority/class/model/58") # OpenTox::QMRFReport.create(model) |