Class: OpenTox::Compound
- Defined in:
- lib/opentox-ruby-api-wrapper.rb
Instance Attribute Summary
Attributes inherited from OpenTox
Instance Method Summary collapse
-
#initialize(params) ⇒ Compound
constructor
Initialize with
:uri => uri,:smiles => smilesor:name => name(name can be also an InChI/InChiKey, CAS number, etc). -
#match(smarts_features) ⇒ Object
Match an array of smarts features, returns matching features.
-
#match?(smarts) ⇒ Boolean
Matchs a smarts string.
-
#smiles ⇒ Object
Get the (canonical) smiles.
Methods inherited from OpenTox
Constructor Details
#initialize(params) ⇒ Compound
Initialize with :uri => uri, :smiles => smiles or :name => name (name can be also an InChI/InChiKey, CAS number, etc)
27 28 29 30 31 32 33 34 35 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 27 def initialize(params) if params[:uri] @uri = params[:uri].to_s elsif params[:smiles] @uri = RestClient.post ENV['OPENTOX_COMPOUND'] ,:smiles => uri_escape(params[:smiles]) elsif params[:name] @uri = RestClient.post ENV['OPENTOX_COMPOUND'] ,:name => uri_escape(params[:name]) end end |
Instance Method Details
#match(smarts_features) ⇒ Object
Match an array of smarts features, returns matching features
52 53 54 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 52 def match(smarts_features) smarts_features.collect{ |smarts| smarts if self.match?(smarts.name) }.compact end |
#match?(smarts) ⇒ Boolean
Matchs a smarts string
43 44 45 46 47 48 49 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 43 def match?(smarts) if RestClient.get(@uri + '/match/' + uri_escape(smarts)) == 'true' true else false end end |
#smiles ⇒ Object
Get the (canonical) smiles
38 39 40 |
# File 'lib/opentox-ruby-api-wrapper.rb', line 38 def smiles RestClient.get @uri end |