From 51f57e2858b60bed74ebcc97189b2188c900c283 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 6 May 2016 12:49:28 +0200 Subject: dataset tests cleanup --- test/descriptor.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index d7d1385..7c2cf8b 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -26,11 +26,14 @@ class DescriptorTest < MiniTest::Test def test_compound_openbabel_single c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" + PhysChem.openbabel_descriptors # required for descriptor initialisation, TODO: move into libs + PhysChem.find_or_create_by(:name => "Openbabel.logP") result = c.physchem [PhysChem.find_or_create_by(:name => "Openbabel.logP")] assert_equal 1.12518, result.first.last.round(5) end def test_compound_cdk_single + PhysChem.cdk_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "c1ccccc1" result = c.physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] assert_equal 12, result.first.last @@ -44,6 +47,7 @@ class DescriptorTest < MiniTest::Test end def test_compound_joelib_single + PhysChem.joelib_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" result = c.physchem [PhysChem.find_or_create_by(:name => "Joelib.LogP")] assert_equal 2.65908, result.first.last -- cgit v1.2.3 From c1be8fe66f640d44dbbc9bfe5212733994bfb9c5 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 9 May 2016 15:44:29 +0200 Subject: physchem crossvalidation fixed, test_compound_descriptor_parameters assertions fixed --- test/descriptor.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index 7c2cf8b..cd0c1ff 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -63,10 +63,21 @@ class DescriptorTest < MiniTest::Test end def test_compound_descriptor_parameters + PhysChem.descriptors c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" result = c.physchem [ "Openbabel.logP", "Cdk.AtomCount.nAtom", "Joelib.LogP" ].collect{|d| PhysChem.find_or_create_by(:name => d)} assert_equal 3, result.size - assert_equal [1.12518, 17.0, 2.65908], result.values.collect{|v| v.round 5} + result.each do |fid,v| + feature = Feature.find(fid) + case feature.name + when "Openbabel.logP" + assert_equal 1.12518, v.round(5) + when "Cdk.AtomCount.nAtom" + assert_equal 17.0, v.round(5) + when "Joelib.LogP" + assert_equal 2.65908, v.round(5) + end + end end end -- cgit v1.2.3 From 016403f7db0dedf8237f29af41312b5ff2720c30 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 5 Oct 2016 14:10:25 +0200 Subject: compound and descriptor tests fixed --- test/descriptor.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index cd0c1ff..2a5be60 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -28,34 +28,34 @@ class DescriptorTest < MiniTest::Test c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" PhysChem.openbabel_descriptors # required for descriptor initialisation, TODO: move into libs PhysChem.find_or_create_by(:name => "Openbabel.logP") - result = c.physchem [PhysChem.find_or_create_by(:name => "Openbabel.logP")] + result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Openbabel.logP")] assert_equal 1.12518, result.first.last.round(5) end def test_compound_cdk_single PhysChem.cdk_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "c1ccccc1" - result = c.physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] + result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] assert_equal 12, result.first.last c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] + result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] assert_equal 17, result.first.last c_types = {"Cdk.CarbonTypes.C1SP1"=>1, "Cdk.CarbonTypes.C2SP1"=>0, "Cdk.CarbonTypes.C1SP2"=>0, "Cdk.CarbonTypes.C2SP2"=>1, "Cdk.CarbonTypes.C3SP2"=>0, "Cdk.CarbonTypes.C1SP3"=>2, "Cdk.CarbonTypes.C2SP3"=>1, "Cdk.CarbonTypes.C3SP3"=>1, "Cdk.CarbonTypes.C4SP3"=>0} physchem_features = c_types.collect{|t,nr| PhysChem.find_or_create_by(:name => t)} - result = c.physchem physchem_features + result = c.calculated_physchem physchem_features assert_equal [1, 0, 0, 1, 0, 2, 1, 1, 0], result.values end def test_compound_joelib_single PhysChem.joelib_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.physchem [PhysChem.find_or_create_by(:name => "Joelib.LogP")] + result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Joelib.LogP")] assert_equal 2.65908, result.first.last end def test_compound_all c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.physchem PhysChem.descriptors + result = c.calculated_physchem PhysChem.descriptors amr = PhysChem.find_or_create_by(:name => "Cdk.ALOGP.AMR", :library => "Cdk") sbonds = PhysChem.find_by(:name => "Openbabel.sbonds") assert_equal 30.8723, result[amr.id.to_s] @@ -65,7 +65,7 @@ class DescriptorTest < MiniTest::Test def test_compound_descriptor_parameters PhysChem.descriptors c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.physchem [ "Openbabel.logP", "Cdk.AtomCount.nAtom", "Joelib.LogP" ].collect{|d| PhysChem.find_or_create_by(:name => d)} + result = c.calculated_physchem [ "Openbabel.logP", "Cdk.AtomCount.nAtom", "Joelib.LogP" ].collect{|d| PhysChem.find_or_create_by(:name => d)} assert_equal 3, result.size result.each do |fid,v| feature = Feature.find(fid) -- cgit v1.2.3 From 9e99495ecbff147218023c136bade9e56a502fed Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 13 Oct 2016 14:39:04 +0200 Subject: descriptor tests fixed --- test/descriptor.rb | 47 +++++++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index 2a5be60..911f5c3 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -27,57 +27,52 @@ class DescriptorTest < MiniTest::Test def test_compound_openbabel_single c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" PhysChem.openbabel_descriptors # required for descriptor initialisation, TODO: move into libs - PhysChem.find_or_create_by(:name => "Openbabel.logP") - result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Openbabel.logP")] - assert_equal 1.12518, result.first.last.round(5) + feature = PhysChem.find_or_create_by(:name => "Openbabel.logP") + result = c.calculate_properties([feature]) + assert_equal 1.12518, result.first.round(5) + assert_equal 1.12518, c.properties[feature.id.to_s].round(5) end def test_compound_cdk_single PhysChem.cdk_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "c1ccccc1" - result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] - assert_equal 12, result.first.last + feature = PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom") + result = c.calculate_properties([feature]) + assert_equal 12, result.first c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom")] - assert_equal 17, result.first.last + feature = PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom") + result = c.calculate_properties([feature]) + assert_equal 17, result.first c_types = {"Cdk.CarbonTypes.C1SP1"=>1, "Cdk.CarbonTypes.C2SP1"=>0, "Cdk.CarbonTypes.C1SP2"=>0, "Cdk.CarbonTypes.C2SP2"=>1, "Cdk.CarbonTypes.C3SP2"=>0, "Cdk.CarbonTypes.C1SP3"=>2, "Cdk.CarbonTypes.C2SP3"=>1, "Cdk.CarbonTypes.C3SP3"=>1, "Cdk.CarbonTypes.C4SP3"=>0} physchem_features = c_types.collect{|t,nr| PhysChem.find_or_create_by(:name => t)} - result = c.calculated_physchem physchem_features - assert_equal [1, 0, 0, 1, 0, 2, 1, 1, 0], result.values + result = c.calculate_properties physchem_features + assert_equal [1, 0, 0, 1, 0, 2, 1, 1, 0], result end def test_compound_joelib_single PhysChem.joelib_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.calculated_physchem [PhysChem.find_or_create_by(:name => "Joelib.LogP")] - assert_equal 2.65908, result.first.last + result = c.calculate_properties [PhysChem.find_or_create_by(:name => "Joelib.LogP")] + assert_equal 2.65908, result.first end def test_compound_all c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.calculated_physchem PhysChem.descriptors amr = PhysChem.find_or_create_by(:name => "Cdk.ALOGP.AMR", :library => "Cdk") sbonds = PhysChem.find_by(:name => "Openbabel.sbonds") - assert_equal 30.8723, result[amr.id.to_s] - assert_equal 5, result[sbonds.id.to_s] + result = c.calculate_properties([amr,sbonds]) + assert_equal 30.8723, result[0] + assert_equal 5, result[1] end def test_compound_descriptor_parameters PhysChem.descriptors c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - result = c.calculated_physchem [ "Openbabel.logP", "Cdk.AtomCount.nAtom", "Joelib.LogP" ].collect{|d| PhysChem.find_or_create_by(:name => d)} + result = c.calculate_properties [ "Openbabel.logP", "Cdk.AtomCount.nAtom", "Joelib.LogP" ].collect{|d| PhysChem.find_or_create_by(:name => d)} assert_equal 3, result.size - result.each do |fid,v| - feature = Feature.find(fid) - case feature.name - when "Openbabel.logP" - assert_equal 1.12518, v.round(5) - when "Cdk.AtomCount.nAtom" - assert_equal 17.0, v.round(5) - when "Joelib.LogP" - assert_equal 2.65908, v.round(5) - end - end + assert_equal 1.12518, result[0].round(5) + assert_equal 17.0, result[1].round(5) + assert_equal 2.65908, result[2].round(5) end end -- cgit v1.2.3 From fbded88db8b51f41ffbd5a02f601e4538ec87258 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 14 Oct 2016 09:55:51 +0200 Subject: git commit added to model metadata --- test/descriptor.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index 911f5c3..e5d8ff9 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -26,7 +26,6 @@ class DescriptorTest < MiniTest::Test def test_compound_openbabel_single c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" - PhysChem.openbabel_descriptors # required for descriptor initialisation, TODO: move into libs feature = PhysChem.find_or_create_by(:name => "Openbabel.logP") result = c.calculate_properties([feature]) assert_equal 1.12518, result.first.round(5) @@ -34,7 +33,6 @@ class DescriptorTest < MiniTest::Test end def test_compound_cdk_single - PhysChem.cdk_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "c1ccccc1" feature = PhysChem.find_or_create_by(:name => "Cdk.AtomCount.nAtom") result = c.calculate_properties([feature]) @@ -50,7 +48,6 @@ class DescriptorTest < MiniTest::Test end def test_compound_joelib_single - PhysChem.joelib_descriptors # required for descriptor initialisation, TODO: move into libs c = OpenTox::Compound.from_smiles "CC(=O)CC(C)C#N" result = c.calculate_properties [PhysChem.find_or_create_by(:name => "Joelib.LogP")] assert_equal 2.65908, result.first -- cgit v1.2.3 From c6e86fc1bfee7cb91782dd7067408d78a8e48ed9 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 8 Nov 2016 16:04:49 +0100 Subject: probability plot for classification --- test/descriptor.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index e5d8ff9..42d4661 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -12,7 +12,9 @@ class DescriptorTest < MiniTest::Test def test_smarts c = OpenTox::Compound.from_smiles "N=C=C1CCC(=F=FO)C1" - File.open("tmp.png","w+"){|f| f.puts c.png} + File.open("/tmp/tmp.png","w+"){|f| f.puts c.png} + assert_match /^PNG/,`file -b /tmp/tmp.png` + File.delete "/tmp/tmp.png" s = Smarts.find_or_create_by(:smarts => "F=F") result = c.smarts_match [s] assert_equal [1], result -- cgit v1.2.3 From a90047977da5a635072f2833816726eaf721aa88 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 9 Nov 2016 10:03:46 +0100 Subject: CDK 2.0 --- test/descriptor.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index 42d4661..6eb4316 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -4,10 +4,11 @@ class DescriptorTest < MiniTest::Test def test_list # check available descriptors - assert_equal 355,PhysChem.descriptors.size,"incorrect number of physchem descriptors" assert_equal 15,PhysChem.openbabel_descriptors.size,"incorrect number of Openbabel descriptors" - assert_equal 295,PhysChem.cdk_descriptors.size,"incorrect number of Cdk descriptors" assert_equal 45,PhysChem.joelib_descriptors.size,"incorrect number of Joelib descriptors" + p PhysChem.cdk_descriptors + assert_equal 286,PhysChem.cdk_descriptors.size,"incorrect number of Cdk descriptors" + assert_equal 346,PhysChem.descriptors.size,"incorrect number of physchem descriptors" end def test_smarts -- cgit v1.2.3 From b6116bc4705066da30668ff3370f3b1c307e44e7 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 11 Nov 2016 13:07:53 +0100 Subject: enm import fixed --- test/descriptor.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'test/descriptor.rb') diff --git a/test/descriptor.rb b/test/descriptor.rb index 6eb4316..563cdce 100644 --- a/test/descriptor.rb +++ b/test/descriptor.rb @@ -6,7 +6,6 @@ class DescriptorTest < MiniTest::Test # check available descriptors assert_equal 15,PhysChem.openbabel_descriptors.size,"incorrect number of Openbabel descriptors" assert_equal 45,PhysChem.joelib_descriptors.size,"incorrect number of Joelib descriptors" - p PhysChem.cdk_descriptors assert_equal 286,PhysChem.cdk_descriptors.size,"incorrect number of Cdk descriptors" assert_equal 346,PhysChem.descriptors.size,"incorrect number of physchem descriptors" end -- cgit v1.2.3