diff options
Diffstat (limited to 'lib/compound.rb')
-rw-r--r-- | lib/compound.rb | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/lib/compound.rb b/lib/compound.rb index 51ef96d..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') @@ -175,19 +196,18 @@ module OpenTox end # Convert identifier from OpenBabel input_format to OpenBabel output_format - def self.obconversion(identifier,input_format,output_format) - obconversion = OpenBabel::OBConversion.new - obmol = OpenBabel::OBMol.new - obconversion.set_in_and_out_formats input_format, output_format - obconversion.read_string obmol, identifier - case output_format - when /smi|can|inchi/ - obconversion.write_string(obmol).gsub(/\s/,'').chomp - else - obconversion.write_string(obmol) - end - end -=end + def self.obconversion(identifier,input_format,output_format) + obconversion = OpenBabel::OBConversion.new + obmol = OpenBabel::OBMol.new + obconversion.set_in_and_out_formats input_format, output_format + obconversion.read_string obmol, identifier + case output_format + when /smi|can|inchi/ + obconversion.write_string(obmol).gsub(/\s/,'').chomp + else + obconversion.write_string(obmol) + end + end @@ -225,6 +245,7 @@ module OpenTox def match(smarts_array) match_hits(smarts_array,false) end +=end end end |