summaryrefslogtreecommitdiff
path: root/lib/compound.rb
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2013-06-19 16:29:43 +0200
committerChristoph Helma <helma@in-silico.ch>2013-06-19 16:29:43 +0200
commitbc9d5b9266e18d39ab5fd83db272bffde98c4161 (patch)
treee30a2a96d77b2f010c8b10316b2163d112613355 /lib/compound.rb
parent4dba36635f5d214c4453d2d0d67426d6f14f5b6b (diff)
openbabel requirement removed. initial descriptor classes.
Diffstat (limited to 'lib/compound.rb')
-rw-r--r--lib/compound.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/compound.rb b/lib/compound.rb
index 89bf840..daeabb9 100644
--- a/lib/compound.rb
+++ b/lib/compound.rb
@@ -1,4 +1,4 @@
-require "openbabel"
+#require "openbabel"
CACTUS_URI="http://cactus.nci.nih.gov/chemical/structure/"
module OpenTox
@@ -116,6 +116,27 @@ module OpenTox
# compound.match?("cN") # returns false
# @param [String] smarts Smarts string
def match?(smarts)
+ matcher = Algorithm.new File.join($algorithm[:uri],"descriptor","smarts")
+ matcher.run :compound_uri => @uri, :smarts => smarts, :count => false
+ end
+
+ # Match an array of smarts strings, returns array with matching smarts
+ # @example
+ # compound = OpenTox::Compound.from_name("Benzene")
+ # compound.match(['cc','cN']) # returns ['cc']
+ # @param [Array] smarts_array Array with Smarts strings
+ # @return [Array] Array with matching Smarts strings
+ def match(smarts_array)
+ matcher = Algorithm.new File.join($algorithm[:uri],"descriptor","smarts")
+ matcher.run :compound_uri => @uri, :smarts => smarts_array, :count => false
+ end
+
+ # Match a smarts string
+ # @example
+ # compound = OpenTox::Compound.from_name("Benzene")
+ # compound.match?("cN") # returns false
+ # @param [String] smarts Smarts string
+ def match?(smarts)
obconversion = OpenBabel::OBConversion.new
obmol = OpenBabel::OBMol.new
obconversion.set_in_format('inchi')