diff options
author | Christoph Helma <helma@in-silico.ch> | 2010-07-20 11:25:37 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2010-07-20 11:25:37 +0200 |
commit | d5378ac285f200a9a75b52030856c77f4697325f (patch) | |
tree | c365a9596588e78bd88bb0bbdd7236b16d73f583 | |
parent | 59a4c9fba3ca77d9901dad2457fe1c5618a099ca (diff) |
@@config -> CONFIG
-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 | 26 | ||||
-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_persistance.rb | 4 | ||||
-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 |
11 files changed, 63 insertions, 63 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 820fc83..f7208a4 100644 --- a/application.rb +++ b/application.rb @@ -1,5 +1,5 @@ require 'rubygems' -gem 'opentox-ruby-api-wrapper', '= 1.5.7' +gem 'opentox-ruby-api-wrapper', '= 1.6.0' [ '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,13 +5,13 @@ 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)") - @@alg = File.join @@config[:services]["opentox-algorithm"],"lazar" - @@alg_params = "feature_generation_uri="+File.join(@@config[:services]["opentox-algorithm"],"fminer") - @@data=File.join @@config[:services]["opentox-dataset"],"1" - @@train_data=File.join @@config[:services]["opentox-dataset"],"2" - @@test_data=File.join @@config[:services]["opentox-dataset"],"3" + @@alg = File.join CONFIG[:services]["opentox-algorithm"],"lazar" + @@alg_params = "feature_generation_uri="+File.join(CONFIG[:services]["opentox-algorithm"],"fminer") + @@data=File.join CONFIG[:services]["opentox-dataset"],"1" + @@train_data=File.join CONFIG[:services]["opentox-dataset"],"2" + @@test_data=File.join CONFIG[:services]["opentox-dataset"],"3" @@css_file="http://apps.ideaconsult.net:8080/ToxPredict/style/global.css" @@summary="" @@ -26,7 +26,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, @@ -58,17 +58,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], @@ -84,7 +84,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 aea036f..cb0267c 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 7c9aa8b..051c3ce 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_persistance.rb b/report/report_persistance.rb index a06dba8..04489c1 100644 --- a/report/report_persistance.rb +++ b/report/report_persistance.rb @@ -67,8 +67,8 @@ end class Reports::FileReportPersistance < Reports::ReportPersistance def initialize() - raise "pls specify report-directory (:reports -> :report_dir) in config file" unless @@config[:reports] and @@config[:reports][:report_dir] - @report_dir = @@config[:reports][:report_dir] + raise "pls specify report-directory (:reports -> :report_dir) in config file" unless CONFIG[:reports] and CONFIG[:reports][:report_dir] + @report_dir = CONFIG[:reports][:report_dir] FileUtils.mkdir @report_dir.to_s unless File.directory?(@report_dir) raise "report cannot be found nor created" unless File.directory?(@report_dir) LOGGER.debug "reports are stored in "+@report_dir.to_s diff --git a/report/report_test.rb b/report/report_test.rb index ff4e3db..119a672 100644 --- a/report/report_test.rb +++ b/report/report_test.rb @@ -113,12 +113,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 @@ -328,4 +328,4 @@ end # # end # -#end
\ No newline at end of file +#end diff --git a/test/test_examples.rb b/test/test_examples.rb index beeaa30..ae4f617 100644 --- a/test/test_examples.rb +++ b/test/test_examples.rb @@ -20,15 +20,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 @@ -46,15 +46,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 @@ -71,15 +71,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 @@ -95,15 +95,15 @@ module ValidationExamples class MajorityISTHamsterCrossvalidation < ISTHamsterCrossvalidationInsilico 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 < ISTHamsterCrossvalidationInsilico 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 @@ -160,7 +160,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 @@ -212,4 +212,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 582b814..3d4d605 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 @@ -291,4 +291,4 @@ module ValidationExamples "crossvalidation" end end -end
\ No newline at end of file +end |