diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-02-23 10:34:45 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-02-23 10:34:45 +0100 |
commit | 182f3e9f34026934626ceff42902274f2e6f046c (patch) | |
tree | 45834ead3d416e871c8881bb6add353827de1a65 | |
parent | 545f4f9e511d8e39a808a1c24de37eb33d2f026e (diff) |
error handling fixed
-rw-r--r-- | Rakefile | 25 | ||||
-rw-r--r-- | all.rb | 2 | ||||
-rw-r--r-- | dataset.rb | 11 | ||||
-rw-r--r-- | lazar.rb | 7 | ||||
-rw-r--r-- | model.rb | 4 |
5 files changed, 36 insertions, 13 deletions
@@ -1,13 +1,27 @@ require 'rubygems' require 'opentox-ruby' -if File.exists? "auth.rb" - require "auth" -else +=begin +=end +class Exception + + def message + unless errorCause == nil + errorCause.to_yaml + else + self.to_s + end + end + +end + +#if File.exists? "auth.rb" + #require "auth" +#else #exit "Please create an authenticatio TEST_USER = "guest" TEST_PW = "guest" -end +#end task ARGV[0] do puts "Environment: #{ENV["RACK_ENV"]}" @@ -27,7 +41,8 @@ task :teardown do OpenTox::Authorization.logout(@@subjectid) end -[:all, :feature, :dataset, :fminer, :lazar, :authorization].each do |t| +[:all, :feature, :dataset, :fminer, :lazar, :authorization, :validation].each do |t| +#[:all, :feature, :dataset, :fminer, :lazar, :authorization].each do |t| task :teardown => t task t => :setup end @@ -1,6 +1,7 @@ require 'rubygems' require 'test/unit' require 'opentox-ruby' +require './authorization.rb' require './compound.rb' require './feature.rb' require './dataset.rb' @@ -9,3 +10,4 @@ require './task.rb' require './algorithm.rb' require './fminer.rb' require './lazar.rb' +#require './validation.rb' @@ -5,6 +5,8 @@ require 'validate-owl' class DatasetTest < Test::Unit::TestCase +=begin +=end def setup @datasets = { @@classification_training_dataset.uri => { @@ -26,7 +28,6 @@ class DatasetTest < Test::Unit::TestCase #@new_dataset.delete end -=begin def test_save_external @dataset = OpenTox::Dataset.find "http://apps.ideaconsult.net:8080/ambit2/dataset/2698", @@subjectid @@ -37,13 +38,13 @@ class DatasetTest < Test::Unit::TestCase #@dataset.load_csv(File.open("data/hamster_carcinogenicity.csv").read) #@dataset.save end -=end def test_create dataset = OpenTox::Dataset.create(CONFIG[:services]["opentox-dataset"], @@subjectid) dataset.save(@@subjectid) assert_kind_of URI::HTTP, URI.parse(dataset.uri) - dataset.delete(@@subjectid) + puts `curl #{dataset.uri}` + #dataset.delete(@@subjectid) end def test_all @@ -65,14 +66,14 @@ class DatasetTest < Test::Unit::TestCase end def test_rest_csv - uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"],{:accept => "text/uri-list"}, {:file => File.new("data/hamster_carcinogenicity.csv"), :subjectid => @@subjectid}).to_s.chomp + uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"], {:file => File.new("data/hamster_carcinogenicity.csv")} ,{:accept => "text/uri-list", :subjectid => @@subjectid}).to_s.chomp @dataset = OpenTox::Dataset.new uri, @@subjectid @dataset.load_all(@@subjectid) hamster_carc? end def test_multicolumn_csv - uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"],{:accept => "text/uri-list"}, {:file => File.new("data/multicolumn.csv"), :subjectid => @@subjectid}).to_s.chomp + uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"], {:file => File.new("data/multicolumn.csv")},{:accept => "text/uri-list", :subjectid => @@subjectid}).to_s.chomp @dataset = OpenTox::Dataset.new uri, @@subjectid @dataset.load_all(@@subjectid) assert_equal 5, @dataset.features.size @@ -17,7 +17,12 @@ class LazarTest < Test::Unit::TestCase lazar = OpenTox::Model::Lazar.find model_uri, @@subjectid assert_equal lazar.features.size, 222 compound = OpenTox::Compound.from_smiles("c1ccccc1NN") + #puts lazar.uri + #puts compound.inspect + #puts "prediction" + #puts prediction.value(compound).inspect prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) + #puts prediction_uri prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) assert_equal prediction.value(compound).round_to(4), 0.149518871336721.round_to(4) assert_equal prediction.confidence(compound).round_to(4), 0.615246530364447.round_to(4) @@ -62,8 +67,8 @@ class LazarTest < Test::Unit::TestCase assert_equal prediction.value(compound), false prediction.delete(@@subjectid) lazar.delete(@@subjectid) + end =begin =end - end end @@ -7,7 +7,7 @@ class ModelTest < Test::Unit::TestCase def setup @models = [ - OpenTox::Model.all.last, + OpenTox::Model.find_all.last, #"http://apps.ideaconsult.net:8080/ambit2/algorithm/J48", ] end @@ -37,6 +37,6 @@ class ModelTest < Test::Unit::TestCase end end -end =end +end |