diff options
author | mr <mr@mrautenberg.de> | 2011-01-04 17:51:47 +0100 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-01-04 17:51:47 +0100 |
commit | 5527fc0726560448350f5c592eb1ae2f07309a57 (patch) | |
tree | 5b6f7e167300451281a351eb9ecbdff433766345 /lazar.rb | |
parent | 7092d168aca6adb437500ed6113bf35eab9500b6 (diff) | |
parent | 9400b9abba43cc3a9d2a21d1ab174534de9f9128 (diff) |
Authorization
Diffstat (limited to 'lazar.rb')
-rw-r--r-- | lazar.rb | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -2,6 +2,12 @@ require 'rubygems' require 'opentox-ruby' require 'test/unit' +class Float + def round_to(x) + (self * 10**x).round.to_f / 10**x + end +end + class LazarTest < Test::Unit::TestCase =begin @@ -13,8 +19,8 @@ class LazarTest < Test::Unit::TestCase compound = OpenTox::Compound.from_smiles("c1ccccc1NN") prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) - assert_equal prediction.value(compound), 0.149480050002539 - assert_equal prediction.confidence(compound), 0.615246530364447 + assert_equal prediction.value(compound).round_to(4), 0.149518871336721.round_to(4) + assert_equal prediction.confidence(compound).round_to(4), 0.615246530364447.round_to(4) assert_equal prediction.neighbors(compound).size, 81 prediction.delete(@@subjectid) lazar.delete(@@subjectid) @@ -30,7 +36,7 @@ class LazarTest < Test::Unit::TestCase prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid) prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) assert_equal prediction.value(compound), false - assert_equal prediction.confidence(compound), 0.25857114104619 + assert_equal prediction.confidence(compound).round_to(4), 0.25857114104619.round_to(4) assert_equal prediction.neighbors(compound).size, 15 prediction.delete(@@subjectid) # dataset activity @@ -47,6 +53,10 @@ class LazarTest < Test::Unit::TestCase prediction = OpenTox::LazarPrediction.find lazar.run(:dataset_uri => test_dataset.uri, :subjectid => @@subjectid), @@subjectid assert_equal prediction.compounds.size, 4 compound = OpenTox::Compound.new prediction.compounds.first + puts "compound" + puts compound.inspect + puts "prediction" + puts prediction.value(compound).inspect assert_equal prediction.value(compound), false prediction.delete(@@subjectid) lazar.delete(@@subjectid) |