diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-03-03 12:57:43 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-03-03 12:57:43 +0100 |
commit | 8b46f5a4f389d7cd54f6e8b38025d275f9d3ed1b (patch) | |
tree | 3d786b2f371db0f097abf11438def17beac820cf | |
parent | 5f243f1e9e0a8e12cd8a2267bcec3140d21bf445 (diff) | |
parent | d5378ac285f200a9a75b52030856c77f4697325f (diff) |
Merge branch 'development' of github.com:helma/opentox-validation into development
Conflicts:
application.rb
example.rb
report/report_persistance.rb
-rw-r--r-- | Rakefile | 20 | ||||
-rw-r--r-- | application.rb | 2 | ||||
-rw-r--r-- | db/migrate/002_init_reports.rb | 4 | ||||
-rw-r--r-- | example.rb | 16 | ||||
-rw-r--r-- | lib/validation_db.rb | 10 | ||||
-rw-r--r-- | nightly/nightly.rb | 4 | ||||
-rw-r--r-- | report/environment.rb | 10 | ||||
-rw-r--r-- | report/report_test.rb | 10 | ||||
-rw-r--r-- | test/test_examples.rb | 28 | ||||
-rw-r--r-- | test/test_examples_util.rb | 8 |
10 files changed, 56 insertions, 56 deletions
@@ -40,8 +40,8 @@ task :load_config do config_dir = File.join(basedir, "config") config_file = File.join(config_dir, "#{ENV['RACK_ENV']}.yaml") if File.exist?(config_file) - @@config = YAML.load_file(config_file) - raise "could not load config, config file: "+config_file.to_s unless @@config + CONFIG = YAML.load_file(config_file) + raise "could not load config, config file: "+config_file.to_s unless CONFIG end puts "config loaded" end @@ -49,14 +49,14 @@ end # USER VERSION 0 instead #desc "Clear database" #task :clear_db => :load_config do -# if @@config[:database][:adapter]=="mysql" +# if CONFIG[:database][:adapter]=="mysql" # clear = nil # IO.popen("locate clear_mysql.sh"){ |f| clear=f.gets.chomp("\n") } # raise "clear_mysql.sh not found" unless clear -# cmd = clear+" "+@@config[:database][:username]+" "+@@config[:database][:password]+" "+@@config[:database][:database] +# cmd = clear+" "+CONFIG[:database][:username]+" "+CONFIG[:database][:password]+" "+CONFIG[:database][:database] # IO.popen(cmd){ |f| puts f.gets } # else -# raise "clear not implemented for database-type: "+@@config[:database][:adapter] +# raise "clear not implemented for database-type: "+CONFIG[:database][:adapter] # end #end @@ -64,11 +64,11 @@ desc "Migrate the database through scripts in db/migrate. Target specific versio task :migrate => :load_config do require 'active_record' ActiveRecord::Base.establish_connection( - :adapter => @@config[:database][:adapter], - :host => @@config[:database][:host], - :database => @@config[:database][:database], - :username => @@config[:database][:username], - :password => @@config[:database][:password] + :adapter => CONFIG[:database][:adapter], + :host => CONFIG[:database][:host], + :database => CONFIG[:database][:database], + :username => CONFIG[:database][:username], + :password => CONFIG[:database][:password] ) ActiveRecord::Base.logger = Logger.new($stdout) ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : 2 ) diff --git a/application.rb b/application.rb index a8ae5a8..f7208a4 100644 --- a/application.rb +++ b/application.rb @@ -1,6 +1,6 @@ require 'rubygems' gem 'opentox-ruby-api-wrapper', '= 1.6.0' -[ 'sinatra', 'sinatra/url_for', 'opentox-ruby-api-wrapper' ].each do |lib| +[ 'sinatra', 'sinatra/url_for', 'opentox-ruby-api-wrapper', 'logger' ].each do |lib| require lib end diff --git a/db/migrate/002_init_reports.rb b/db/migrate/002_init_reports.rb index 8029223..dcf44a1 100644 --- a/db/migrate/002_init_reports.rb +++ b/db/migrate/002_init_reports.rb @@ -22,9 +22,9 @@ class InitReports < ActiveRecord::Migration def self.down drop_table :report_datum if table_exists? :report_datum - if @@config[:reports] and @@config[:reports][:report_dir] + if CONFIG[:reports] and CONFIG[:reports][:report_dir] ["validation", "crossvalidation", "algorithm_comparison"].each do |t| - dir = File.join(@@config[:reports][:report_dir],t) + dir = File.join(CONFIG[:reports][:report_dir],t) if File.exist?(dir) puts "deleting dir "+dir.to_s FileUtils.rm_rf(dir) @@ -5,7 +5,7 @@ class Example @@file=File.new("data/hamster_carcinogenicity.yaml","r") @@file_type="text/x-yaml" - @@model=File.join @@config[:services]["opentox-model"],"1" + @@model=File.join CONFIG[:services]["opentox-model"],"1" @@feature= URI.encode("http://localhost/toxmodel/feature#Hamster%20Carcinogenicity%20(DSSTOX/CPDB)") @@predicted_feature= URI.encode("http://localhost/toxmodel/feature#Hamster%20Carcinogenicity%20(DSSTOX/CPDB)_lazar_classification") @@alg = File.join @@config[:services]["opentox-algorithm"],"lazar" @@ -28,7 +28,7 @@ class Example end file.close - sub = { "validation_service" => @@config[:services]["opentox-validation"].chomp("/"), + sub = { "validation_service" => CONFIG[:services]["opentox-validation"].chomp("/"), "validation_id" => "1", "model_uri" => @@model, "dataset_uri" => @@data, @@ -61,17 +61,17 @@ class Example ActiveRecord::Migrator.migrate('db/migrate', 1 ) ActiveRecord::Migrator.migrate('db/migrate', 2 ) - #delete_all(@@config[:services]["opentox-dataset"]) - log OpenTox::RestClientWrapper.delete @@config[:services]["opentox-dataset"] + #delete_all(CONFIG[:services]["opentox-dataset"]) + log OpenTox::RestClientWrapper.delete CONFIG[:services]["opentox-dataset"] log "upload dataset" halt 400,"File not found: "+@@file.path.to_s unless File.exist?(@@file.path) data = File.read(@@file.path) - data_uri = OpenTox::RestClientWrapper.post(@@config[:services]["opentox-dataset"],{:content_type => @@file_type},data).chomp("\n") + data_uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"],{:content_type => @@file_type},data).chomp("\n") log "train-test-validation" - #delete_all(@@config[:services]["opentox-model"]) - OpenTox::RestClientWrapper.delete @@config[:services]["opentox-model"] + #delete_all(CONFIG[:services]["opentox-model"]) + OpenTox::RestClientWrapper.delete CONFIG[:services]["opentox-model"] split_params = Validation::Util.train_test_dataset_split(data_uri, URI.decode(@@feature), 0.9, 1) v = Validation::Validation.new :training_dataset_uri => split_params[:training_dataset_uri], @@ -87,7 +87,7 @@ class Example cv.perform_cv( @@alg_params ) log "create validation report" - rep = Reports::ReportService.new(File.join(@@config[:services]["opentox-validation"],"report")) + rep = Reports::ReportService.new(File.join(CONFIG[:services]["opentox-validation"],"report")) rep.delete_all_reports("validation") rep.create_report("validation",v.validation_uri) diff --git a/lib/validation_db.rb b/lib/validation_db.rb index 1152abf..7afab90 100644 --- a/lib/validation_db.rb +++ b/lib/validation_db.rb @@ -6,11 +6,11 @@ require "lib/merge.rb" unless ActiveRecord::Base.connected? ActiveRecord::Base.establish_connection( - :adapter => @@config[:database][:adapter], - :host => @@config[:database][:host], - :database => @@config[:database][:database], - :username => @@config[:database][:username], - :password => @@config[:database][:password] + :adapter => CONFIG[:database][:adapter], + :host => CONFIG[:database][:host], + :database => CONFIG[:database][:database], + :username => CONFIG[:database][:username], + :password => CONFIG[:database][:password] ) ActiveRecord::Base.logger = Logger.new("/dev/null") end diff --git a/nightly/nightly.rb b/nightly/nightly.rb index f402691..f68691e 100644 --- a/nightly/nightly.rb +++ b/nightly/nightly.rb @@ -98,7 +98,7 @@ class Nightly end #benchmarks.collect{|b| b.uris}.join(",") - File.join(@@config[:services]["opentox-validation"],"nightly") + File.join(CONFIG[:services]["opentox-validation"],"nightly") end if defined?(halt) halt 202,task_uri @@ -219,4 +219,4 @@ class Nightly end end -end
\ No newline at end of file +end diff --git a/report/environment.rb b/report/environment.rb index 714cebe..04221de 100644 --- a/report/environment.rb +++ b/report/environment.rb @@ -8,11 +8,11 @@ gem 'ruby-plot', '= 0.0.2' unless ActiveRecord::Base.connected? ActiveRecord::Base.establish_connection( - :adapter => @@config[:database][:adapter], - :host => @@config[:database][:host], - :database => @@config[:database][:database], - :username => @@config[:database][:username], - :password => @@config[:database][:password] + :adapter => CONFIG[:database][:adapter], + :host => CONFIG[:database][:host], + :database => CONFIG[:database][:database], + :username => CONFIG[:database][:username], + :password => CONFIG[:database][:password] ) ActiveRecord::Base.logger = Logger.new("/dev/null") end diff --git a/report/report_test.rb b/report/report_test.rb index 1c838bf..2920fd3 100644 --- a/report/report_test.rb +++ b/report/report_test.rb @@ -119,12 +119,12 @@ end #class Reports::ReportServiceTest < Test::Unit::TestCase # include Lib::TestUtil # -# WS_VAL = @@config[:services]["opentox-validation"] -# WS_DATA=@@config[:services]["opentox-dataset"] +# WS_VAL = CONFIG[:services]["opentox-validation"] +# WS_DATA=CONFIG[:services]["opentox-dataset"] # FILE=File.new("data/hamster_carcinogenicity.owl","r") # -# WS_CLASS_ALG=File.join(@@config[:services]["opentox-algorithm"],"lazar") -# WS_FEATURE_ALG=File.join(@@config[:services]["opentox-algorithm"],"fminer") +# WS_CLASS_ALG=File.join(CONFIG[:services]["opentox-algorithm"],"lazar") +# WS_FEATURE_ALG=File.join(CONFIG[:services]["opentox-algorithm"],"fminer") # # #WS_CLASS_ALG_2="localhost:4008/algorithm" # #WS_FEATURE_ALG_2=nil @@ -334,4 +334,4 @@ end # # end # -#end
\ No newline at end of file +#end diff --git a/test/test_examples.rb b/test/test_examples.rb index bbe6ddd..34a9f67 100644 --- a/test/test_examples.rb +++ b/test/test_examples.rb @@ -67,15 +67,15 @@ module ValidationExamples class LazarHamsterSplit < HamsterSplit def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-algorithm"],"lazar") - @algorithm_params = "feature_generation_uri="+File.join(@@config[:services]["opentox-algorithm"],"fminer") + @algorithm_uri = File.join(CONFIG[:services]["opentox-algorithm"],"lazar") + @algorithm_params = "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer") super end end class MajorityHamsterSplit < HamsterSplit def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-majority"],"/class/algorithm") + @algorithm_uri = File.join(CONFIG[:services]["opentox-majority"],"/class/algorithm") super end end @@ -93,15 +93,15 @@ module ValidationExamples class MajorityHamsterTrainingTest < HamsterTrainingTest def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-majority"],"/class/algorithm") + @algorithm_uri = File.join(CONFIG[:services]["opentox-majority"],"/class/algorithm") super end end class LazarHamsterTrainingTest < HamsterTrainingTest def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-algorithm"],"lazar") - @algorithm_params = "feature_generation_uri="+File.join(@@config[:services]["opentox-algorithm"],"fminer") + @algorithm_uri = File.join(CONFIG[:services]["opentox-algorithm"],"lazar") + @algorithm_params = "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer") super end end @@ -118,15 +118,15 @@ module ValidationExamples class MajorityHamsterCrossvalidation < HamsterCrossvalidation def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-majority"],"/class/algorithm") + @algorithm_uri = File.join(CONFIG[:services]["opentox-majority"],"/class/algorithm") super end end class LazarHamsterCrossvalidation < HamsterCrossvalidation def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-algorithm"],"lazar") - @algorithm_params = "feature_generation_uri="+File.join(@@config[:services]["opentox-algorithm"],"fminer") + @algorithm_uri = File.join(CONFIG[:services]["opentox-algorithm"],"lazar") + @algorithm_params = "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer") super end end @@ -142,15 +142,15 @@ module ValidationExamples class MajorityISTHamsterCrossvalidation < ISTHamsterCrossvalidation def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-majority"],"/class/algorithm") + @algorithm_uri = File.join(CONFIG[:services]["opentox-majority"],"/class/algorithm") super end end class LazarISTHamsterCrossvalidation < ISTHamsterCrossvalidation def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-algorithm"],"lazar") - @algorithm_params = "feature_generation_uri="+File.join(@@config[:services]["opentox-algorithm"],"fminer") + @algorithm_uri = File.join(CONFIG[:services]["opentox-algorithm"],"lazar") + @algorithm_params = "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer") super end end @@ -240,7 +240,7 @@ module ValidationExamples class MajorityCacoTrainingTest < CacoTrainingTest def initialize - @algorithm_uri = File.join(@@config[:services]["opentox-majority"],"/regr/algorithm") + @algorithm_uri = File.join(CONFIG[:services]["opentox-majority"],"/regr/algorithm") super end end @@ -301,4 +301,4 @@ module ValidationExamples end #puts ValidationExamples.list -#puts ValidationExamples.select("1,2a").inspect
\ No newline at end of file +#puts ValidationExamples.select("1,2a").inspect diff --git a/test/test_examples_util.rb b/test/test_examples_util.rb index 09f7d6c..7eb69ff 100644 --- a/test/test_examples_util.rb +++ b/test/test_examples_util.rb @@ -5,7 +5,7 @@ module ValidationExamples @@dataset_uris = {} - def self.upload_dataset(file, dataset_service=@@config[:services]["opentox-dataset"], file_type="application/x-yaml") + def self.upload_dataset(file, dataset_service=CONFIG[:services]["opentox-dataset"], file_type="application/x-yaml") raise "File not found: "+file.path.to_s unless File.exist?(file.path) if @@dataset_uris[file.path.to_s]==nil data = File.read(file.path) @@ -40,7 +40,7 @@ module ValidationExamples $test_case.post uri,params return wait($test_case.last_response.body) else - return OpenTox::RestClientWrapper.post(File.join(@@config[:services]["opentox-validation"],uri),params) + return OpenTox::RestClientWrapper.post(File.join(CONFIG[:services]["opentox-validation"],uri),params) end end @@ -50,7 +50,7 @@ module ValidationExamples $test_case.get uri,nil,'HTTP_ACCEPT' => accept_header return wait($test_case.last_response.body) else - return OpenTox::RestClientWrapper.get(File.join(@@config[:services]["opentox-validation"],uri),{:accept => accept_header}) + return OpenTox::RestClientWrapper.get(File.join(CONFIG[:services]["opentox-validation"],uri),{:accept => accept_header}) end end @@ -295,4 +295,4 @@ module ValidationExamples "crossvalidation" end end -end
\ No newline at end of file +end |