From 6ac119c32cef094d4f1c2fb5c2daa4e274401f70 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 17 Sep 2015 14:56:25 +0200 Subject: neighbor calculation moved to Compound class --- test/compound.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/compound.rb') diff --git a/test/compound.rb b/test/compound.rb index 6deba4e..6a3c696 100644 --- a/test/compound.rb +++ b/test/compound.rb @@ -108,4 +108,30 @@ print c.sdf assert_equal c.openbabel_fingerprint("FP4").size, c.fp4.size end end + + def test_fingerprint_neighbors + types = ["FP2", "FP3", "FP4", "MACCS"] + min_sim = 0.7 + training_dataset = Dataset.from_csv_file File.join(DATA_DIR,"EPAFHM.csv") + [ + "CC(=O)CC(C)C#N", + "CC(=O)CC(C)C", + "C(=O)CC(C)C#N", + ].each do |smi| + c = OpenTox::Compound.from_smiles smi + p c.smiles + types.each do |type| + p type + neighbors = c.fingerprint_neighbors({:type => type, :training_dataset_id => training_dataset.id, :min_sim => min_sim}) + p neighbors.collect{|n| [Compound.find(n.first).smiles,n.last]} + if type == "FP4" + fp4_neighbors = c.neighbors + neighbors.each do |n| + p [Compound.find(n.first).smiles,n.last] unless fp4_neighbors.include?(n) + assert_includes fp4_neighbors, n + end + end + end + end + end end -- cgit v1.2.3