summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2016-04-14 19:43:24 +0200
committerChristoph Helma <helma@in-silico.ch>2016-04-14 19:43:24 +0200
commit753fcc204d93d86c76860bee6e2f7d0468c3c940 (patch)
tree30fc9980de8b298ee57199c9b540408019a8976c /test
parent64f1f32ced77afb278bdb7c27397c5299a73675c (diff)
features/toxicities fixed
Diffstat (limited to 'test')
-rw-r--r--test/classification.rb14
-rw-r--r--test/nanoparticles.rb23
-rw-r--r--test/setup.rb4
3 files changed, 27 insertions, 14 deletions
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