diff options
author | Christoph Helma <helma@in-silico.ch> | 2016-04-28 11:05:05 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2016-04-28 11:05:05 +0200 |
commit | acf19c81e345ceccde834653a0f0edce27827958 (patch) | |
tree | 058ae154e0f167991518f486913067f4bc648725 | |
parent | 32d767ee7cfcc19337892551906950621f348174 (diff) |
compound classification fixed
-rw-r--r-- | lib/compound.rb | 2 | ||||
-rw-r--r-- | lib/model.rb | 2 | ||||
-rw-r--r-- | test/classification.rb | 9 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/compound.rb b/lib/compound.rb index 049d77b..c2ce5d0 100644 --- a/lib/compound.rb +++ b/lib/compound.rb @@ -335,7 +335,7 @@ module OpenTox {'$match' => {'tanimoto' => {'$gte' => params[:min_sim]}}}, {'$sort' => {'tanimoto' => -1}} ] - + $mongo["substances"].aggregate(aggregate).select{|r| r["dataset_ids"].include? params[:training_dataset_id]} end diff --git a/lib/model.rb b/lib/model.rb index 45054e2..80b4685 100644 --- a/lib/model.rb +++ b/lib/model.rb @@ -64,7 +64,7 @@ module OpenTox prediction[:warning] = "#{database_activities.size} compounds have been removed from neighbors, because they have the same structure as the query compound." neighbors.delete_if{|n| n["_id"] == compound.id} end - neighbors.delete_if{|n| n['toxicities'].empty? or n['toxicities'][prediction_feature.id.to_s] == [nil] } + #neighbors.delete_if{|n| n['toxicities'].empty? or n['toxicities'][prediction_feature.id.to_s] == [nil] } if neighbors.empty? prediction.merge!({:value => nil,:confidence => nil,:warning => "Could not find similar compounds with experimental data in the training dataset.",:neighbors => []}) else diff --git a/test/classification.rb b/test/classification.rb index 7412714..99fde3b 100644 --- a/test/classification.rb +++ b/test/classification.rb @@ -4,7 +4,7 @@ class LazarClassificationTest < MiniTest::Test def test_lazar_classification training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"hamster_carcinogenicity.csv") - model = Model::LazarClassification.create training_dataset + model = Model::LazarClassification.create training_dataset.features.first, training_dataset [ { :compound => OpenTox::Compound.from_inchi("InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"), @@ -25,8 +25,8 @@ class LazarClassificationTest < MiniTest::Test compound = Compound.from_smiles "CCO" prediction = model.predict compound - assert_equal ["false"], prediction[:database_activities] assert_equal "true", prediction[:value] + assert_equal ["false"], prediction[:database_activities] # make a dataset prediction compound_dataset = OpenTox::Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.mini.csv") @@ -35,7 +35,10 @@ class LazarClassificationTest < MiniTest::Test 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 + prediction_dataset.predictions.each do |cid,pred| + assert_equal "Could not find similar compounds with experimental data in the training dataset.", pred[:warning] if pred[:value].nil? + end + cid = Compound.from_smiles("CCOC(=O)N").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,prediction_dataset].each{|o| o.delete} |