From 7969f100f68decc6847595bdb4a0620e28425544 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Mon, 15 Aug 2011 09:16:59 +0200 Subject: test crossvalidation and qmrf searches with model-uri --- validation.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/validation.rb b/validation.rb index fbfa76d..28ca973 100644 --- a/validation.rb +++ b/validation.rb @@ -378,6 +378,10 @@ class ValidationTest < Test::Unit::TestCase model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => cv.metadata[OT.dataset], :prediction_feature => prediction_feature_uri, :subjectid => @@subjectid}).to_s assert model_uri.uri? + # test search in cvs with model uri + cv_uris = OpenTox::RestClientWrapper.get(File.join(CONFIG[:services]["opentox-validation"],"/crossvalidation?model="+model_uri), + {:subjectid => @@subjectid}).chomp.split("\n") + assert cv_uris.size>0 and cv_uris.include?(cv.uri) # validations = cv.metadata[OT.validation] # assert_kind_of Array,validations # assert validations.size==cv.metadata[OT.numFolds].to_i,validations.size.to_s+"!="+cv.metadata[OT.numFolds].to_s @@ -389,6 +393,10 @@ class ValidationTest < Test::Unit::TestCase # OpenTox::QMRFReport.find_for_model(model_uri, @@subjectid) #end qmrfReport = OpenTox::QMRFReport.create(model_uri, @@subjectid) + # test search in qmrf reports with model uri + qmrf_uris = OpenTox::RestClientWrapper.get(File.join(CONFIG[:services]["opentox-validation"],"/reach_report/QMRF?model="+model_uri), + {:subjectid => @@subjectid}).chomp.split("\n") + assert qmrf_uris.size==1 and qmrf_uris[0]==qmrfReport.uri puts qmrfReport.uri unless @@delete @@qmrfReports << qmrfReport end -- cgit v1.2.3 From 13832c4fa41d50eac7e12c22fa7668553dfbf081 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 17 Aug 2011 14:26:37 +0200 Subject: add subjectids for A&A --- dataset.rb | 1 - validation.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dataset.rb b/dataset.rb index 077530b..fe249b2 100644 --- a/dataset.rb +++ b/dataset.rb @@ -6,7 +6,6 @@ require 'validate-owl' class DatasetTest < Test::Unit::TestCase def setup - @@subjectid = nil @datasets = { @@regression_training_dataset.uri => nil, @@classification_training_dataset.uri => { diff --git a/validation.rb b/validation.rb index 28ca973..06254c3 100644 --- a/validation.rb +++ b/validation.rb @@ -372,7 +372,7 @@ class ValidationTest < Test::Unit::TestCase assert defined?cv,"no crossvalidation defined" assert cv.metadata[OT.validation].is_a?(Array) assert cv.metadata[OT.validation].first.uri? - validation = OpenTox::Validation.find(cv.metadata[OT.validation].first) + validation = OpenTox::Validation.find(cv.metadata[OT.validation].first, @@subjectid) prediction_feature_uri = validation.metadata[OT.predictionFeature] assert prediction_feature_uri.uri? model_uri = OpenTox::Algorithm::Lazar.new.run({:dataset_uri => cv.metadata[OT.dataset], :prediction_feature => prediction_feature_uri, -- cgit v1.2.3 From 95e8205415932112eb6dd3393b861fad7a52f3d4 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 22 Aug 2011 16:24:50 +0000 Subject: tests for prediction features added --- feature.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/feature.rb b/feature.rb index c06f9f5..0c9d097 100644 --- a/feature.rb +++ b/feature.rb @@ -8,7 +8,9 @@ class FeatureTest < Test::Unit::TestCase def setup @features = [ @@classification_training_dataset.features.keys.first, - "http://apps.ideaconsult.net:8080/ambit2/feature/35796" + "http://apps.ideaconsult.net:8080/ambit2/feature/35796", + File.join(OpenTox::Model::Lazar.all.last,"predicted","value") + ] end @@ -16,6 +18,7 @@ class FeatureTest < Test::Unit::TestCase @features.each do |uri| + puts uri f = OpenTox::Feature.new(uri) f.load_metadata(@@subjectid) assert_not_nil f.metadata[DC.title] @@ -26,6 +29,7 @@ class FeatureTest < Test::Unit::TestCase def test_owl #@features.each do |uri| validate_owl @features.first, @@subjectid unless CONFIG[:services]["opentox-dataset"].match(/localhost/) + validate_owl @features.last, @@subjectid unless CONFIG[:services]["opentox-dataset"].match(/localhost/) # Ambit does not validate #end end -- cgit v1.2.3 From b4a69302d68efc2a27c1f8a23155d58a52224a26 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 23 Aug 2011 17:29:49 +0200 Subject: fix has_content syntax --- toxcreate.rb | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/toxcreate.rb b/toxcreate.rb index de9ab59..9b40e0e 100644 --- a/toxcreate.rb +++ b/toxcreate.rb @@ -25,24 +25,24 @@ class ToxCreateTest < Test::Unit::TestCase =begin def test_01_login visit File.join(CONFIG[:services]["opentox-toxcreate"], "login") - click_on "Login" - puts "Login without credentials" - assert page.has_content? "Please enter username and password." + click_button "Login" + puts "Login without credentials" + assert page.has_content?("Please enter username and password.") fill_in('Username', :with => @user) fill_in('Password', :with => @password + "nonsense") - click_on "Login" + click_button "Login" puts "Login with wrong password" - assert page.has_content? "Login failed. Please try again." - fill_in('Username', :with => @user) - fill_in('Password', :with => @password) - click_on "Login" - assert page.has_content? "Welcome #{@user}!" + assert page.has_content?('Login failed. Please try again.') + fill_in('Username', :with => "anonymous") + fill_in('Password', :with => "anonymous") + click_button "Login" + assert page.has_content?("Welcome anonymous!") visit File.join(CONFIG[:services]["opentox-toxcreate"], "login") - click_on "Login as guest" + click_button "Login as guest" puts "Login as user guest" - assert page.has_content? "Welcome guest!" + assert page.has_content?("Welcome guest!") end -=end + def test_02_toxcreate # works only with akephalos Capybara.current_driver = :akephalos #login(@browser, @user, @password) @@ -58,7 +58,7 @@ class ToxCreateTest < Test::Unit::TestCase end assert first(".model_status").has_content?("Completed") end - +=end def test_03_predict Capybara.register_driver :akephalos do |app| Capybara::Driver::Akephalos.new(app, :validate_scripts => false) @@ -66,13 +66,13 @@ class ToxCreateTest < Test::Unit::TestCase session = Capybara::Session.new(:akephalos) session.visit CONFIG[:services]["opentox-toxcreate"] session.click_on "Predict" - session.fill_in "or enter a Name, InChI, Smiles, CAS, ...", :with => "NNc1ccccc1" - session.check "hamster_carcinogenicity" + session.fill_in "or enter a Smiles string", :with => "NNc1ccccc1" + session.check "hamster carcinogenicity" session.click_button "Predict" - assert session.has_content? "inactive" + assert session.has_content?("Not enough similar compounds in training dataset") session.click_on "Confidence" - assert session.has_content? "Indicates the applicability domain of a model" - session.click_on "Details" + assert session.has_content?("Indicates the applicability domain of a model") + session.click_button "Details" #assert page.has_content? "false" #assert page.has_content? "0.294" -- cgit v1.2.3 From 5bf775db23ea77687dab659c8d7fcbdad1822b81 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 25 Aug 2011 17:37:57 +0000 Subject: model owl validation --- model.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model.rb b/model.rb index 2b11be0..cf78ad8 100644 --- a/model.rb +++ b/model.rb @@ -7,7 +7,7 @@ class ModelTest < Test::Unit::TestCase def setup @models = [ - OpenTox::Model.all.last, + OpenTox::Model::Lazar.all.last, #"http://apps.ideaconsult.net:8080/ambit2/algorithm/J48", ] end @@ -16,8 +16,8 @@ class ModelTest < Test::Unit::TestCase end def test_metadata + puts @model.inspect @models.each do |model| - #puts model validate_owl(model) end end -- cgit v1.2.3 From 6ae5229e5a6c7e94e82cf3a11f8d76b80f4a36ef Mon Sep 17 00:00:00 2001 From: David Vorgrimmler Date: Mon, 19 Sep 2011 16:02:06 +0200 Subject: Changed regression results to new results with nr_hits. --- lazar.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lazar.rb b/lazar.rb index 57f6842..b241b5c 100644 --- a/lazar.rb +++ b/lazar.rb @@ -65,17 +65,17 @@ class LazarTest < Test::Unit::TestCase def test_create_regression_model create_model :dataset_uri => @@regression_training_dataset.uri predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.421.round_to(2), @predictions.first.value(@compounds.first).round_to(2) - assert_equal 0.262.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) - assert_equal 123, @predictions.first.neighbors(@compounds.first).size + assert_equal 0.93.round_to(2), @predictions.first.value(@compounds.first).round_to(2) + assert_equal 0.453.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) + assert_equal 253, @predictions.first.neighbors(@compounds.first).size cleanup end def test_create_regression_prop_model create_model :dataset_uri => @@regression_training_dataset.uri, :local_svm_kernel => "propositionalized" predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.262.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) - assert_equal 123, @predictions.first.neighbors(@compounds.first).size + assert_equal 0.453.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) + assert_equal 253, @predictions.first.neighbors(@compounds.first).size assert_equal 131, @model.features.size cleanup end @@ -149,18 +149,18 @@ class LazarTest < Test::Unit::TestCase def test_regression_mlr_prop_model create_model :dataset_uri => @@regression_training_dataset.uri, :prediction_algorithm => "local_mlr_prop" predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.262, @predictions.first.confidence(@compounds.first).round_to(3) - assert_equal 0.168, @predictions.first.value(@compounds.first).round_to(3) - assert_equal 123, @predictions.first.neighbors(@compounds.first).size + assert_equal 0.453, @predictions.first.confidence(@compounds.first).round_to(3) + assert_equal 0.265, @predictions.first.value(@compounds.first).round_to(3) + assert_equal 253, @predictions.first.neighbors(@compounds.first).size assert_equal 131, @model.features.size end def test_regression_mlr_prop_conf_stdev create_model :dataset_uri => @@regression_training_dataset.uri, :prediction_algorithm => "local_mlr_prop", :conf_stdev => "true" predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.056, @predictions.first.confidence(@compounds.first).round_to(3) - assert_equal 0.168, @predictions.first.value(@compounds.first).round_to(3) - assert_equal 123, @predictions.first.neighbors(@compounds.first).size + assert_equal 0.154, @predictions.first.confidence(@compounds.first).round_to(3) + assert_equal 0.265, @predictions.first.value(@compounds.first).round_to(3) + assert_equal 253, @predictions.first.neighbors(@compounds.first).size assert_equal 131, @model.features.size end -- cgit v1.2.3 From 0d4ad938a3e1e7da2aa77fe6a5e4ea919ec85f37 Mon Sep 17 00:00:00 2001 From: David Vorgrimmler Date: Tue, 20 Sep 2011 12:17:04 +0200 Subject: Changed prediction value. --- lazar.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazar.rb b/lazar.rb index b241b5c..a46e2f2 100644 --- a/lazar.rb +++ b/lazar.rb @@ -65,7 +65,7 @@ class LazarTest < Test::Unit::TestCase def test_create_regression_model create_model :dataset_uri => @@regression_training_dataset.uri predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.93.round_to(2), @predictions.first.value(@compounds.first).round_to(2) + assert_equal 1.09.round_to(2), @predictions.first.value(@compounds.first).round_to(2) assert_equal 0.453.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) assert_equal 253, @predictions.first.neighbors(@compounds.first).size cleanup -- cgit v1.2.3 From 6aef4de474e420e45fa6e84d440851fe73db1167 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 20 Sep 2011 17:06:18 +0200 Subject: ontology basic tests --- ontology.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ontology.rb diff --git a/ontology.rb b/ontology.rb new file mode 100644 index 0000000..0dd710c --- /dev/null +++ b/ontology.rb @@ -0,0 +1,26 @@ +require "rubygems" +require "opentox-ruby" +require "test/unit" + +unless AA_SERVER #overwrite turned off A&A server for testing + AA_SERVER = "https://opensso.in-silico.ch" + @@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) +end + +class TestOpenToxOntology < Test::Unit::TestCase + + def test_01_register_model + uri = OpenTox::Model::Lazar.all.last + puts uri + OpenTox::Ontology::Model.register(uri, @@subjectid) + assert_equal(true, OpenTox::Ontology::Model.exists?(uri, @@subjectid)) + end + + def test_02_delete_model + uri = OpenTox::Model::Lazar.all.last + puts uri + OpenTox::Ontology::Model.delete(uri, @@subjectid) + assert_equal(false, OpenTox::Ontology::Model.exists?(uri, @@subjectid)) + end + +end \ No newline at end of file -- cgit v1.2.3