diff options
author | gebele <gebele@alfadeo.de> | 2011-07-15 15:31:08 +0200 |
---|---|---|
committer | gebele <gebele@alfadeo.de> | 2011-07-15 15:31:08 +0200 |
commit | b2e01d0db0eadbe216a1a727b4a8b4b6904e3e3e (patch) | |
tree | f96c9fd9c6aa3bc6465611c6ee755e3d731da653 | |
parent | 3315754ea91b2c7f6ba7b5a3eec1dc7ed032e2b6 (diff) |
Merge branch 'development' into feature/policy
Conflicts:
toxcreate.rb
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | compound.rb | 19 | ||||
-rw-r--r-- | data/ISSCAN-multi.csv | 59 | ||||
-rw-r--r-- | data/multicolumn.csv | 2 | ||||
-rw-r--r-- | fminer.rb | 326 | ||||
-rw-r--r-- | lazar.rb | 72 | ||||
-rw-r--r-- | toxcreate.rb | 13 | ||||
-rw-r--r-- | validation.rb | 3 |
9 files changed, 436 insertions, 63 deletions
@@ -1,3 +1,4 @@ .yardoc -dump.rdb +dump +reference bak @@ -21,11 +21,13 @@ end task :setup do @@subjectid = OpenTox::Authorization.authenticate(TEST_USER,TEST_PW) @@classification_training_dataset = OpenTox::Dataset.create_from_csv_file("data/hamster_carcinogenicity.csv", @@subjectid) + @@multinomial_training_dataset = OpenTox::Dataset.create_from_csv_file("data/ISSCAN-multi.csv", @@subjectid) @@regression_training_dataset = OpenTox::Dataset.create_from_csv_file("data/EPAFHM.csv", @@subjectid) end task :teardown do @@classification_training_dataset.delete(@@subjectid) + @@multinomial_training_dataset.delete(@@subjectid) @@regression_training_dataset.delete(@@subjectid) OpenTox::Authorization.logout(@@subjectid) end diff --git a/compound.rb b/compound.rb index ef87845..048e012 100644 --- a/compound.rb +++ b/compound.rb @@ -4,26 +4,39 @@ require 'test/unit' class CompoundTest < Test::Unit::TestCase - def test_compound - + def test_compound_from_smiles_0 c = OpenTox::Compound.from_smiles "F[B-](F)(F)F.[Na+]" assert_equal "InChI=1S/BF4.Na/c2-1(3,4)5;/q-1;+1", c.inchi #assert_equal "[Na+].F[B-](F)(F)F", c.smiles # still does not work on 64bit machines + end + + def test_compound_from_smiles_1 c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" assert_equal "InChI=1S/C6H9NO/c1-5(4-7)3-6(2)8/h5H,3H2,1-2H3", c.inchi assert_equal "CC(CC(=O)C)C#N", c.to_smiles + end + + def test_compound_from_name c = OpenTox::Compound.from_name "Benzene" assert_equal "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H", c.inchi assert_equal "c1ccccc1", c.to_smiles + end + + def test_compound_from_smiles_2 c = OpenTox::Compound.from_smiles "N#[N+]C1=CC=CC=C1.F[B-](F)(F)F" assert_equal "InChI=1S/C6H5N2.BF4/c7-8-6-4-2-1-3-5-6;2-1(3,4)5/h1-5H;/q+1;-1", c.inchi assert_equal "N#[N+]c1ccccc1.F[B-](F)(F)F", c.to_smiles + end + + def test_compound_from_inchi c = OpenTox::Compound.from_inchi "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H" assert_equal "c1ccccc1", c.to_smiles + end + + def test_compound_ambit c = OpenTox::Compound.new "http://apps.ideaconsult.net:8080/ambit2/compound/144036" assert_equal "InChI=1S/C6H11NO2/c1-3-5-6(4-2)7(8)9/h5H,3-4H2,1-2H3", c.inchi assert_equal "CCC=C(CC)N(=O)=O", c.to_smiles end - end diff --git a/data/ISSCAN-multi.csv b/data/ISSCAN-multi.csv new file mode 100644 index 0000000..b404683 --- /dev/null +++ b/data/ISSCAN-multi.csv @@ -0,0 +1,59 @@ +SMILES,ISSCAN +CC(CCl)Cl,1 +C(Br)(Br)Br,1 +C=C(C)CCl,1 +O=Cc1ccco1,1 +COC34(C(COC(N)=O)C=1C(=O)C(N)=C(C)C(=O)C=1N4(CC2NC23)),1 +CC(N)Cc1ccccc1.CC(N)Cc1ccccc1,1 +Cc1cc(ccc1(N))C(=C2C=CC(=N)C=C2)c3ccc(N)cc3,1 +Oc1ccc(cc1)c2ccccc2,1 +CC(C)C=O,1 +N#CC(C#N)=Cc1ccccc1Cl,1 +Nc1ccc(cc1(N))[N+](=O)[O-],2 +NC(CCC(=O)NNc1ccc(CO)cc1)C(O)=O,2 +c1ccc2c(c1)nc(s2)SSc4nc3ccccc3s4,2 +C=CC=O,2 +CC(=O)Nc3cccc2Cc1ccccc1c23,2 +Cc1cccc2cccnc12,2 +Cc1ccc2ncccc2(c1),2 +CBr,2 +Nc1cc(ccc1(C(=O)O))[N+](=O)[O-],2 +C1N2CN3CN1CN(C2)C3,2 +O=[N+]([O-])c2cccc1ccccc12,2 +Oc1cccc2cccnc12,2 +O=CC(=C(C(=O)O)Cl)Cl,2 +CC1CN(N=O)C(=O)NC1(=O),2 +O1C2C1C3C4C2C5C3C6(C4(C(C5(C6(Cl)Cl)Cl)Cl)Cl)Cl,2 +OCCNc1ccc(cc1[N+](=O)[O-])N(CCO)CCO,2 +Cc1cc(N)ccc1(N).OS(=O)(=O)O,2 +CC(O)CCl,2 +O=[N+]([O-])C(Cl)(Cl)Cl,2 +Cc1ccc(cc1)S(=O)(=O)NC(=O)NN2CCCCCC2,2 +c1cc2ccc3cccc4ccc(c1)c2c34,2 +CC(=O)Nc1ccc(cc1)C(=O)CCl,2 +FC(F)Cl,2 +CN(N=O)c1ccc(cc1)[N+](=O)[O-],2 +C=CC,2 +Oc4c(cc1cc(ccc1c4(N=Nc2ccc(c3ccccc23)S(=O)(=O)[O-]))S(=O)(=O)[O-])S(=O)(=O)[O-],0 +CC=NN(C)C=O,0 +Nc2ccc(N=Nc1ccccc1)c(N)n2,0 +Cc3cc(C)c(N=Nc1cc(c2ccccc2(c1(O)))S(=O)(=O)[O-])c(c3)S(=O)(=O)[O-],0 +[O-]c1ccccc1c2ccccc2,0 +NNC(N)=O,0 +CNNCc1ccc(cc1)C(=O)NC(C)C,0 +c1cc(c(cc1c2ccc(c(c2Cl)Cl)Cl)Cl)Cl,0 +CCN(Cc1cccc(c1)S(=O)(=O)[O-])c2ccc(cc2)C(=C3C=CC(C=C3)=[N+](CC)Cc4cccc(c4)S(=O)(=O)[O-])c5ccc(cc5)S(=O)(=O)[O-],0 +COC(=O)C(c1ccccc1)C2CCCCN2,0 +CCCCC(CC)COS(=O)(=O)[O-],0 +Nc1ccccc1,0 +Cc1cccc(N)c1,0 +CN(C)CCN(Cc1cccs1)c2ccccn2,0 +CN(C)CCOC(C)(c1ccccc1)c2ccccn2,0 +Cc1cc(C)c(cc1(C))N=Nc3c(O)c(cc2cc(ccc23)S(=O)(=O)[O-])S(=O)(=O)[O-],0 +Cc1ccccc1(N),0 +CCC1(C(=O)N=C([O-])NC1(=O))c2ccccc2,0 +Nc5cc(cc6cc(c(N=Nc1ccc(cc1(O))c4ccc(N=Nc2c(O)c3c(N)cc(cc3(cc2S(=O)(=O)[O-]))S(=O)(=O)[O-])c(O)[c-]4)c(O)c56)S(=O)(=O)[O-])S(=O)(=O)[O-],0 +O=C1[N-]S(=O)(=O)c2ccccc12,0 +CN(C)c1ccc(cc1)C(c2ccc(cc2)N(C)C)=C3C=CC(C=C3)=[N+](C)C,0 +C13(C4(C2(C5(C(C1(C2(Cl)Cl)Cl)(C3(C(C45Cl)(Cl)Cl)Cl)Cl)Cl)Cl)Cl)Cl,0 +CCOCCc1c(nc(N)[n+]2[nH]cnc12)c3ccccc3,0 diff --git a/data/multicolumn.csv b/data/multicolumn.csv index 551429e..2fa9a1c 100644 --- a/data/multicolumn.csv +++ b/data/multicolumn.csv @@ -1,5 +1,5 @@ SMILES, Hamster Carcinogenicity, numeric feature, classification, mixed, string -CC=O , 1, 1, true , true , "test" +c1ccccc1NN , 1, 1, true , true , "test" C12C3=C(C=CC=C3)CC1=CC(=CC=2)NC(C)=O , 1, 2, false, 7.5 , "test" O=C(N)\C(C2=CC=CO2)=C/C1=CC=C([N+]([O-])=O)O1, 1, 3, true , 5 , "test" C1(N=CNN=1)N , 0, 4, false, false, "test" @@ -3,6 +3,12 @@ require 'opentox-ruby' require 'test/unit' require 'validate-owl.rb' +class Float + def round_to(x) + (self * 10**x).round.to_f / 10**x + end +end + class FminerTest < Test::Unit::TestCase def setup @@ -26,7 +32,35 @@ class FminerTest < Test::Unit::TestCase feature = @@classification_training_dataset.features.keys.first @dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s dump - assert_equal 52, @dataset.features.size + assert_equal 41, @dataset.features.size # 32 bit + #assert_equal 52, @dataset.features.size + # assert no hit counts present + count=0 + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C10H13N3O2/c1-13(12-15)7-3-5-10(14)9-4-2-6-11-8-9/h2,4,6,8H,3,5,7H2,1H3').size > 0 + e.each { |p,h| + if p.to_s.scan('bbrc/40').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/29').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/18').size>0 + count += 1 if h[0] == true + end + } + end + } + assert_equal 3, count + + # assert some values + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/31').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], 2 + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.97 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#6&a]-[#6&a]:[#6&a]:[#6&a]:[#6&a]-[#7&A]" + end + } cleanup end @@ -34,38 +68,300 @@ class FminerTest < Test::Unit::TestCase feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" @dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid, :feature_type=>"paths"}).to_s dump - assert_equal 219, @dataset.features.size + assert_equal 131, @dataset.features.size # 32 bit + #assert_equal 219, @dataset.features.size + + # assert no hit counts present + count = 0 + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C5H10N2O2S/c1-4(10-3)7-9-5(8)6-2/h1-3H3,(H,6,8)').size > 0 + e.each { |p,h| + if p.to_s.scan('bbrc/86').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/54').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/32').size>0 + count += 1 if h[0] == true + end + } + end + } + assert_equal 3, count + + # assert some values + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/188').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], "activating" + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 1.0 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#6&a]:[#6&a]:[#8&a]:[#6&a]:[#6&a]" + end + } + cleanup end def test_last + feature = @@classification_training_dataset.features.keys.first @dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@classification_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s dump - assert_equal 23, @dataset.features.size + assert_in_delta 21, @dataset.features.size, 2 # 32 bit + + # assert no hit counts present + count = 0 + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C5H10N2O/c8-6-7-4-2-1-3-5-7/h1-5H2').size > 0 + e.each { |p,h| + if p.to_s.scan('last/11').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('last/5').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('last/13').size>0 + count += 1 if h[0] == true + end + } + end + } + #assert_equal 3, count + + # assert some values + #@dataset.features.each { |c,e| + # if c.to_s.scan('feature/last/3').size > 0 + # assert_equal e['http://www.opentox.org/api/1.1#effect'], 2 + # assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.99 + # assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#8&A]=[#6&A]-[#6&A]-[#6&A]" + # end + #} cleanup end - def test_bbrc_rest_parameters + +def test_regression_last + feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" + @dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, + :min_frequency => 40, + :subjectid => @@subjectid}).to_s + dump + assert_in_delta 16, @dataset.features.size, 2 + + + # assert no hit counts present + #count=0 + #@dataset.data_entries.each { |c,e| + # if c.to_s.scan('InChI=1S/C9H10O3/c1-2-12-9-5-7(6-10)3-4-8(9)11/h3-6,11H,2H2,1H3').size > 0 + # e.each { |p,h| + # if p.to_s.scan('last/5').size>0 + # count += 1 if h[0] == true + # end + # if p.to_s.scan('last/11').size>0 + # count += 1 if h[0] == true + # end + # if p.to_s.scan('last/13').size>0 + # count += 1 if h[0] == true + # end + # } + # end + #} + #assert_in_delta 3, count, 2 + + # assert some values + #@dataset.features.each { |c,e| + # if c.to_s.scan('feature/last/3').size > 0 + # assert_equal e['http://www.opentox.org/api/1.1#effect'], "activating" + # assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 1.0 + # assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#8&A]=[#6&A]-[#8&A]-[#6&A]" + # end + #} + cleanup +end + + + + def test_bbrc_rest_parameters_nr_hits feature = @@classification_training_dataset.features.keys.first @dataset_uri = OpenTox::RestClientWrapper.post(File.join(CONFIG[:services]["opentox-algorithm"],"fminer","bbrc"),{ "dataset_uri" => @@classification_training_dataset.uri, "prediction_feature" => feature, - "backbone" => true, - "min_frequency" => 2, + "nr_hits" => true, :subjectid => @@subjectid }) dump - assert_equal 52, @dataset.features.size + assert_equal 41, @dataset.features.size # 32 bit + #assert_equal 52, @dataset.features.size + + # assert hit counts present + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C14H19N3S.ClH/c1-16(2)9-10-17(12-13-6-5-11-18-13)14-7-3-4-8-15-14;/h3-8,11H,9-10,12H2,1-2H3;1H').size > 0 + e.each { |p,h| + if p.to_s.scan('bbrc/39').size>0 + assert_equal 6, h[0] + end + if p.to_s.scan('bbrc/18').size>0 + assert_equal 5, h[0] + end + if p.to_s.scan('bbrc/38').size>0 + assert_equal 14, h[0] + end + } + end + } + + # assert some values + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/31').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], 2 + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.97 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#6&a]-[#6&a]:[#6&a]:[#6&a]:[#6&a]-[#7&A]" + end + } + cleanup end -# Deactivated by AM because of efficiency problems (does not return) -# def test_regression_last -# feature = File.join @@regression_training_dataset.uri,"feature/LC50_mmol" -# @dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@regression_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s -# dump -# assert_equal 4, d.features.size -# cleanup -# end + def test_bbrc_rest_parameters_bb_false + feature = @@classification_training_dataset.features.keys.first + @dataset_uri = OpenTox::RestClientWrapper.post(File.join(CONFIG[:services]["opentox-algorithm"],"fminer","bbrc"),{ + "dataset_uri" => @@classification_training_dataset.uri, + "prediction_feature" => feature, + "backbone" => false, + :subjectid => @@subjectid }) + dump + assert_equal 139, @dataset.features.size # 32 bit + #assert_equal 52, @dataset.features.size + + # assert no hit counts present + count=0 + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C10H13N3O2/c1-13(12-15)7-3-5-10(14)9-4-2-6-11-8-9/h2,4,6,8H,3,5,7H2,1H3').size > 0 + e.each { |p,h| + if p.to_s.scan('bbrc/113').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/99').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/77').size>0 + count += 1 if h[0] == true + end + } + end + } + assert_equal 3, count + + + # assert some values + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/31').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], 2 + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.99 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#8&A]-[#6&A]-[#7&A]-[#7&A]=[#8&A]" + end + } + + cleanup + end + + def test_bbrc_multinomial + feature = @@multinomial_training_dataset.features.keys.first + @dataset_uri = OpenTox::Algorithm::Fminer::BBRC.new.run({:dataset_uri => @@multinomial_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s + dump + assert_equal 152, @dataset.features.size # 32 bit + + #assert no hit counts present + count=0 + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C10H7NO2/c12-11(13)10-7-3-5-8-4-1-2-6-9(8)10/h1-7H').size > 0 + e.each { |p,h| + if p.to_s.scan('bbrc/37').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/38').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('bbrc/39').size>0 + count += 1 if h[0] == true + end + } + end + } + assert_equal 3, count + + # assert some values + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/0').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], 2 + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 1.00 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#6&A]-[#6&A](=[#6&A])(-[#6&A])" + end + } + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/92').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], 1 + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.99 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#7&A]-[#6&a](:[#6&a]:[#6&a]:[#6&a])(:[#6&a]:[#6&a]-[#16&A])" + end + } + @dataset.features.each { |c,e| + if c.to_s.scan('feature/bbrc/42').size > 0 + assert_equal e['http://www.opentox.org/api/1.1#effect'], 3 + assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.99 + assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#6&a]:[#6&a]:[#6&a]:[#6&a]:[#6&a]:[#7&a]:[#6&a]" + end + } + cleanup + end + + def test_last_multinomial + feature = @@multinomial_training_dataset.features.keys.first + @dataset_uri = OpenTox::Algorithm::Fminer::LAST.new.run({:dataset_uri => @@multinomial_training_dataset.uri, :prediction_feature => feature, :subjectid => @@subjectid}).to_s + dump + assert_in_delta 138, @dataset.features.size, 2 # 32 bit + + #assert no hit counts present + count=0 + @dataset.data_entries.each { |c,e| + if c.to_s.scan('InChI=1S/C7H6N2O4/c8-6-3-4(9(12)13)1-2-5(6)7(10)11/h1-3H,8H2,(H,10,11)').size > 0 + e.each { |p,h| + if p.to_s.scan('last/127').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('last/54').size>0 + count += 1 if h[0] == true + end + if p.to_s.scan('last/120').size>0 + count += 1 if h[0] == true + end + } + end + } + #assert_equal 3, count + + # assert some values + #@dataset.features.each { |c,e| + # if c.to_s.scan('feature/last/54').size > 0 + # assert_equal e['http://www.opentox.org/api/1.1#effect'], 1 + # assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.99 + # assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#7&A;$([#7&A](=[#8&A])=[#8&A]),$([#7&A](-[#6&a])=[#8&A])](~*)=[#8&A]" + # end + #} + #@dataset.features.each { |c,e| + # if c.to_s.scan('feature/last/48').size > 0 + # assert_equal e['http://www.opentox.org/api/1.1#effect'], 2 + # assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.99 + # assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#6&A]=[#6&A](-[#6&A])-[#6&A]" + # end + #} + #@dataset.features.each { |c,e| + # if c.to_s.scan('feature/bbrc/76').size > 0 + # assert_equal e['http://www.opentox.org/api/1.1#effect'], "2" + # assert_equal e['http://www.opentox.org/api/1.1#pValue'].to_f.round_to(2), 0.0 + # assert_equal e['http://www.opentox.org/api/1.1#smarts'], "[#7&A]-[#6&a]:[#6&a]:[#6&a](-[#16&A;$([#16&A](-,=[#8&A])-[#6&a]),$([#16&A](=[#8&A])-[#6&a])](~*)):[#6&a]:[#6&a;$([#6&a](:[#6&a])(:[#6&a]):[#6&a]),$([#6&a](:[#6&a])(:[#6&a]):[#6&a])](~*)(~*):[#6&a]:[#6&a]" + # end + #} + cleanup + end end @@ -41,14 +41,13 @@ class LazarTest < Test::Unit::TestCase end def predict_dataset(dataset) - prediction_uri = @model.run(:dataset_uri => dataset.uri, :subjectid => @@subjectid) + prediction_uri = @model.run(:dataset_uri => dataset.uri, :subjectid => @@subjectid) prediction = OpenTox::LazarPrediction.find(prediction_uri, @@subjectid) @predictions << prediction dump prediction, File.join(@dump_dir,caller[0][/`.*'/][1..-2],"dataset_prediction")+".yaml" end def cleanup # executed only when assertions succeed (teardown is called even when assertions fail) - validate_owl @model.uri @files.each do |f| reference = f.sub(/dump/,"reference") FileUtils.mkdir_p File.dirname(reference) @@ -56,7 +55,6 @@ class LazarTest < Test::Unit::TestCase FileUtils.rm f end @predictions.each do |dataset| - validate_owl @model.uri dataset.delete(@@subjectid) end @model.delete(@@subjectid) @@ -67,24 +65,24 @@ class LazarTest < Test::Unit::TestCase def test_create_regression_model create_model :dataset_uri => @@regression_training_dataset.uri predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.4.round_to(3), @predictions.first.value(@compounds.first).round_to(3) - assert_equal 0.276.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) - assert_equal 61, @predictions.first.neighbors(@compounds.first).size + assert_equal 0.421.round_to(2), @predictions.first.value(@compounds.first).round_to(2) + assert_equal 0.262.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) + assert_equal 123, @predictions.first.neighbors(@compounds.first).size cleanup end def test_create_regression_prop_model create_model :dataset_uri => @@regression_training_dataset.uri, :local_svm_kernel => "propositionalized" predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - assert_equal 0.4.round_to(1), @predictions.first.value(@compounds.first).round_to(1) - assert_equal 0.276.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) - assert_equal 61, @predictions.first.neighbors(@compounds.first).size - assert_equal 219, @model.features.size + assert_equal 0.262.round_to(3), @predictions.first.confidence(@compounds.first).round_to(3) + assert_equal 123, @predictions.first.neighbors(@compounds.first).size + assert_equal 131, @model.features.size cleanup end def test_classification_model create_model :dataset_uri => @@classification_training_dataset.uri + puts @model.uri # single prediction predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") # dataset activity @@ -93,9 +91,9 @@ class LazarTest < Test::Unit::TestCase predict_dataset OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid) # assertions # single prediction - assert_equal false, @predictions[0].value(@compounds[0]) - assert_equal 0.3067.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) - assert_equal 14, @predictions[0].neighbors(@compounds[0]).size + assert_equal "false", @predictions[0].value(@compounds[0]) + assert_equal 0.2938.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) + assert_equal 16, @predictions[0].neighbors(@compounds[0]).size # dataset activity assert !@predictions[1].measured_activities(@compounds[1]).empty? assert_equal "true", @predictions[1].measured_activities(@compounds[1]).first.to_s @@ -104,10 +102,11 @@ class LazarTest < Test::Unit::TestCase c = OpenTox::Compound.from_smiles("CC(=Nc1ccc2c(c1)Cc1ccccc21)O") assert_equal nil, @predictions[2].value(c) assert_equal "true", @predictions[2].measured_activities(c).first.to_s - c = OpenTox::Compound.new("http://ot-dev.in-silico.ch/compound/InChI=1S/C2H4N4/c3-2-4-1-5-6-2/h1H,(H3,3,4,5,6)") - assert_equal false, @predictions[2].value(c) + c = OpenTox::Compound.from_smiles("c1ccccc1NN") + assert_equal "false", @predictions[2].value(c) + assert_equal 0.2938.round_to(4) , @predictions[2].confidence(c).round_to(4) # model - assert_equal 52, @model.features.size + assert_equal 41, @model.features.size cleanup end @@ -117,35 +116,36 @@ class LazarTest < Test::Unit::TestCase predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") predict_dataset OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid) - assert_equal false, @predictions[0].value(@compounds[0]) - assert_equal 0.3067.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) - assert_equal 14, @predictions[0].neighbors(@compounds[0]).size + assert_equal "false", @predictions[0].value(@compounds[0]) + assert_equal 0.3952.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) + assert_equal 16, @predictions[0].neighbors(@compounds[0]).size - c = OpenTox::Compound.new("http://ot-dev.in-silico.ch/compound/InChI=1S/C2H4N4/c3-2-4-1-5-6-2/h1H,(H3,3,4,5,6)") + c = OpenTox::Compound.from_smiles("c1ccccc1NN") assert_equal 4, @predictions[1].compounds.size - assert_equal false, @predictions[1].value(c) + assert_equal "false", @predictions[1].value(c) - assert_equal 52, @model.features.size + assert_equal 41, @model.features.size cleanup end - def test_classification_svm_prop_model + def test_classification_svm_prop_model - create_model :dataset_uri => @@classification_training_dataset.uri, :prediction_algorithm => "local_svm_classification", :local_svm_kernel => "propositionalized" - predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") - predict_dataset OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid) - - assert_equal false, @predictions[0].value(@compounds[0]) - assert_equal 0.3067.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) - assert_equal 14, @predictions[0].neighbors(@compounds[0]).size + create_model :dataset_uri => @@classification_training_dataset.uri, :prediction_algorithm => "local_svm_classification", :local_svm_kernel => "propositionalized" + predict_compound OpenTox::Compound.from_smiles("c1ccccc1NN") + predict_dataset OpenTox::Dataset.create_from_csv_file("data/multicolumn.csv", @@subjectid) + + assert_equal "false", @predictions[0].value(@compounds[0]) + #assert_equal 0.2938.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) + assert_equal 0.3952.round_to(4), @predictions[0].confidence(@compounds[0]).round_to(4) + assert_equal 16, @predictions[0].neighbors(@compounds[0]).size - c = OpenTox::Compound.new("http://ot-dev.in-silico.ch/compound/InChI=1S/C2H4N4/c3-2-4-1-5-6-2/h1H,(H3,3,4,5,6)") - assert_equal 4, @predictions[1].compounds.size - assert_equal false, @predictions[1].value(c) + c = OpenTox::Compound.from_smiles("c1ccccc1NN") + assert_equal 4, @predictions[1].compounds.size + assert_equal "false", @predictions[1].value(c) - assert_equal 52, @model.features.size - cleanup - end + assert_equal 41, @model.features.size + cleanup + end =begin def test_ambit_classification_model diff --git a/toxcreate.rb b/toxcreate.rb index 1a4ebd9..9659c1e 100644 --- a/toxcreate.rb +++ b/toxcreate.rb @@ -4,8 +4,11 @@ require 'opentox-ruby' require 'test/unit' require 'akephalos' require 'capybara/dsl' +<<<<<<< HEAD require 'capybara/envjs' +======= +>>>>>>> development Capybara.default_driver = :akephalos # use this without visual inspection #Capybara.default_driver = :selenium # use this for visual inspection Capybara.run_server = false @@ -48,7 +51,9 @@ class ToxCreateTest < Test::Unit::TestCase assert page.has_content? "Welcome guest!" end =end - def test_02_toxcreate # works only with akephalos + def test_02_toxcreate # works only with akephalos + Capybara.current_driver = :akephalos + #login(@browser, @user, @password) visit CONFIG[:services]["opentox-toxcreate"] assert page.has_content?('Upload training data') attach_file('file', "./data/hamster_carcinogenicity.mini.csv") @@ -131,8 +136,7 @@ class ToxCreateTest < Test::Unit::TestCase sleep 5 #page.evaluate_script('window.confirm = function() { return true; }') click_on "delete" - end - + end =begin def test_08_multi_cell_call #login(@browser, @user, @password) @@ -163,9 +167,6 @@ class ToxCreateTest < Test::Unit::TestCase click_on "Create model" end end -=end - - =begin def login(browser, user, password) browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login") diff --git a/validation.rb b/validation.rb index ff0725d..cf2a3bd 100644 --- a/validation.rb +++ b/validation.rb @@ -24,7 +24,8 @@ end class ValidationTest < Test::Unit::TestCase @@delete = true - @@feature_types = ["bbrc", "last"] + #@@feature_types = ["bbrc", "last"] + @@feature_types = ["bbrc"] @@qmrf_test = true @@data = [] @@data << { :type => :crossvalidation, |