diff options
author | mr <mr@mrautenberg.de> | 2011-09-23 12:29:39 +0200 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-09-23 12:29:39 +0200 |
commit | 32856dc0fcba2751c2f4d8a1162a958f10af3250 (patch) | |
tree | 841561eae04cdfa520b7b7456f1553d3409f1145 | |
parent | 878f522af1d1ac2f132c5b6adb0deacdbd19cfa8 (diff) | |
parent | 6aef4de474e420e45fa6e84d440851fe73db1167 (diff) |
Merge branch 'release/v3.0.0'v3.0.0
-rw-r--r-- | dataset.rb | 1 | ||||
-rw-r--r-- | feature.rb | 6 | ||||
-rw-r--r-- | lazar.rb | 22 | ||||
-rw-r--r-- | model.rb | 4 | ||||
-rw-r--r-- | ontology.rb | 26 | ||||
-rw-r--r-- | toxcreate.rb | 36 | ||||
-rw-r--r-- | validation.rb | 10 |
7 files changed, 71 insertions, 34 deletions
@@ -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 => { @@ -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 @@ -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 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 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 @@ -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 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 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" diff --git a/validation.rb b/validation.rb index fbfa76d..06254c3 100644 --- a/validation.rb +++ b/validation.rb @@ -372,12 +372,16 @@ 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, :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 |