diff options
Diffstat (limited to 'fminer.rb')
-rw-r--r-- | fminer.rb | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -363,5 +363,39 @@ end #} cleanup end + + def test_match + feature = @@classification_training_dataset.features.keys.first + feature_dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({ + :dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s + feature_dataset = OpenTox::Dataset.find(feature_dataset_uri,@@subjectid) + tmp_resources = [ feature_dataset_uri ] + [true,false].each do |hits| + matched_dataset_uri = OpenTox::RestClientWrapper.post(File.join(CONFIG[:services]["opentox-algorithm"],"fminer","bbrc","match"), + {:feature_dataset_uri => feature_dataset_uri, :dataset_uri => @@multinomial_training_dataset.uri, + :nr_hits => hits, :subjectid => @@subjectid}).to_s + tmp_resources << matched_dataset_uri + matched_dataset = OpenTox::Dataset.find(matched_dataset_uri,@@subjectid) + # matched dataset should have same features as feature dataset + assert_equal feature_dataset.features.keys.sort,matched_dataset.features.keys.sort + # matched datset should have same compounds as input dataset for matching + assert_equal matched_dataset.compounds.sort,@@multinomial_training_dataset.compounds.sort + matched_dataset.compounds.each do |c| + matched_dataset.features.keys.each do |f| + if matched_dataset.data_entries[c] and matched_dataset.data_entries[c][f] + v = matched_dataset.data_entries[c][f] + if hits + assert_equal v.size,1 + assert v[0].is_a?(Integer) + assert v[0]>0 + else + assert_equal v,[1] + end + end + end + end + end + tmp_resources.each{|uri| OpenTox::RestClientWrapper.delete(uri,{:subjectid=>@@subjectid})} + end end |