From d7504cc422bbaeee3546589d87e7baeb4e977c0b Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 12 Jan 2017 17:57:03 +0100 Subject: source uris for core and coating --- test/feature.rb | 4 ++-- test/model-nanoparticle.rb | 7 +++++++ test/nanomaterial-model-validation.rb | 5 ++--- test/validation-regression.rb | 5 ++--- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/feature.rb b/test/feature.rb index 533ac0f..40edb9f 100644 --- a/test/feature.rb +++ b/test/feature.rb @@ -55,7 +55,7 @@ class FeatureTest < MiniTest::Test end def test_physchem_description - assert_equal 355, PhysChem.descriptors.size + assert_equal 346, PhysChem.descriptors.size assert_equal 15, PhysChem.openbabel_descriptors.size assert_equal 295, PhysChem.cdk_descriptors.size assert_equal 45, PhysChem.joelib_descriptors.size @@ -63,7 +63,7 @@ class FeatureTest < MiniTest::Test end def test_physchem - assert_equal 355, PhysChem.descriptors.size + assert_equal 346, PhysChem.descriptors.size c = Compound.from_smiles "CC(=O)CC(C)C" logP = PhysChem.find_or_create_by :name => "Openbabel.logP" assert_equal 1.6215, logP.calculate(c) diff --git a/test/model-nanoparticle.rb b/test/model-nanoparticle.rb index 8dc6830..67bbfdd 100644 --- a/test/model-nanoparticle.rb +++ b/test/model-nanoparticle.rb @@ -8,6 +8,13 @@ class NanoparticleModelTest < MiniTest::Test @prediction_feature = @training_dataset.features.select{|f| f["name"] == 'log2(Net cell association)'}.first end + def test_core_coating_source_uris + @training_dataset.nanoparticles.each do |np| + refute_nil np.core.source + np.coating.each{|c| refute_nil c.source} + end + end + def test_nanoparticle_model assert true, @prediction_feature.measured model = Model::Lazar.create training_dataset: @training_dataset, prediction_feature: @prediction_feature diff --git a/test/nanomaterial-model-validation.rb b/test/nanomaterial-model-validation.rb index b91c389..9eaa17d 100644 --- a/test/nanomaterial-model-validation.rb +++ b/test/nanomaterial-model-validation.rb @@ -8,7 +8,7 @@ class NanomaterialValidationModelTest < MiniTest::Test end def test_default_nanomaterial_validation_model - validation_model = Model::NanoValidation.create + validation_model = Model::Validation.from_enanomapper [:endpoint,:species,:source].each do |p| refute_empty validation_model[p] end @@ -39,7 +39,7 @@ class NanomaterialValidationModelTest < MiniTest::Test :prediction => { :method => "OpenTox::Algorithm::Regression.weighted_average" }, :feature_selection => nil } - validation_model = Model::NanoValidation.create algorithms: algorithms + validation_model = Model::Validation.from_enanomapper algorithms: algorithms assert validation_model.regression? refute validation_model.classification? validation_model.crossvalidations.each do |cv| @@ -50,6 +50,5 @@ class NanomaterialValidationModelTest < MiniTest::Test assert_includes nanoparticle.dataset_ids, @training_dataset.id prediction = validation_model.predict nanoparticle refute_nil prediction[:value] - assert_includes prediction[:prediction_interval][0]..prediction[:prediction_interval][1], prediction[:measurements].median, "This assertion assures that measured values are within the prediction interval. It may fail in 5% of the predictions." end end diff --git a/test/validation-regression.rb b/test/validation-regression.rb index 7630521..01ed644 100644 --- a/test/validation-regression.rb +++ b/test/validation-regression.rb @@ -83,10 +83,9 @@ class ValidationRegressionTest < MiniTest::Test model = Model::Lazar.create training_dataset: dataset repeated_cv = RepeatedCrossValidation.create model repeated_cv.crossvalidations.each do |cv| - #assert cv.r_squared > 0.34, "R^2 (#{cv.r_squared}) should be larger than 0.034" - #assert_operator cv.accuracy, :>, 0.7, "model accuracy < 0.7, this may happen by chance due to an unfavorable training/test set split" + assert cv.r_squared > 0.34, "R^2 (#{cv.r_squared}) should be larger than 0.034" + assert_operator cv.accuracy, :>, 0.7, "model accuracy < 0.7, this may happen by chance due to an unfavorable training/test set split" end - File.open("tmp.png","w+"){|f| f.puts repeated_cv.correlation_plot} end end -- cgit v1.2.3