From 753fcc204d93d86c76860bee6e2f7d0468c3c940 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 14 Apr 2016 19:43:24 +0200 Subject: features/toxicities fixed --- test/classification.rb | 14 +++++++------- test/nanoparticles.rb | 23 ++++++++++++++++++----- test/setup.rb | 4 ++-- 3 files changed, 27 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/classification.rb b/test/classification.rb index af23db6..7412714 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -30,14 +30,14 @@ class LazarClassificationTest < MiniTest::Test # make a dataset prediction compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini.csv") - prediction = model.predict compound_dataset - assert_equal compound_dataset.compounds, prediction.compounds + prediction_dataset = model.predict compound_dataset + assert_equal compound_dataset.compounds, prediction_dataset.compounds - cid = prediction.compounds[7].id.to_s - assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction.predictions[cid][:warning] - cid = prediction.compounds[9].id.to_s - assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction.predictions[cid][:warning] + cid = prediction_dataset.compounds[7].id.to_s + assert_equal "Could not find similar compounds with experimental data in the training dataset.", prediction_dataset.predictions[cid][:warning] + cid = prediction_dataset.compounds[9].id.to_s + assert_equal "1 compounds have been removed from neighbors, because they have the same structure as the query compound.", prediction_dataset.predictions[cid][:warning] # cleanup - [training_dataset,model,compound_dataset].each{|o| o.delete} + [training_dataset,model,compound_dataset,prediction_dataset].each{|o| o.delete} end end diff --git a/test/nanoparticles.rb b/test/nanoparticles.rb index 6f241ec..46073a9 100644 --- a/test/nanoparticles.rb +++ b/test/nanoparticles.rb @@ -6,16 +6,29 @@ class NanoparticleTest < MiniTest::Test dataset_ids = Import::Enanomapper.import assert_operator Nanoparticle.count , :>, 570, "Only #{Nanoparticle.count} nanoparticles imported" assert_operator dataset_ids.size, :>, 8, "Only #{dataset_ids.size} bundles imported" - p dataset_ids.collect{|d| Dataset.find(d).name} assert dataset_ids.collect{|d| Dataset.find(d).name}.include? ("NanoWiki") assert dataset_ids.collect{|d| Dataset.find(d).name}.include? ("Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles") + p dataset_ids.collect{|d| {d => Dataset.find(d).name}} + dataset_ids.collect do |d| + d = Dataset.find(d) + p d.name + puts d.to_csv + end end - def test_create_model - Model::NanoLazar.create_all.each do |model| - np = Nanoparticle.find(model.training_particle_ids.sample) - model.predict np + def test_export + Dataset.all.each do |d| + puts d.to_csv end end + def test_create_model + training_dataset = Dataset.find_or_create_by(:name => "Protein Corona Fingerprinting Predicts the Cellular Interaction of Gold and Silver Nanoparticles") + model = Model::LazarRegression.create(training_dataset, :prediction_algorithm => "OpenTox::Algorithm::Regression.local_physchem_regression", :neighbor_algorithm => "nanoparticle_neighbors") + nanoparticle = training_dataset.nanoparticles[-34] + prediction = model.predict nanoparticle + p prediction + refute_nil prediction[:value] + end + end diff --git a/test/setup.rb b/test/setup.rb index e7c32b4..6c97282 100644 --- a/test/setup.rb +++ b/test/setup.rb @@ -5,5 +5,5 @@ require_relative '../lib/lazar.rb' include OpenTox TEST_DIR ||= File.expand_path(File.dirname(__FILE__)) DATA_DIR ||= File.join(TEST_DIR,"data") -$mongo.database.drop -$gridfs = $mongo.database.fs +#$mongo.database.drop +#$gridfs = $mongo.database.fs -- cgit v1.2.3