Class: Ruspider::ChemSpider
- Inherits:
-
Object
- Object
- Ruspider::ChemSpider
- Includes:
- InchIAPI, MassSpecAPI, SpectraAPI
- Defined in:
- lib/ruspider/chemspider.rb
Overview
ChemSpider Ruby interface
Constant Summary
Constants included from SpectraAPI
SpectraAPI::API, SpectraAPI::FIELDS
Constants included from MassSpecAPI
MassSpecAPI::API, MassSpecAPI::FIELDS
Constants included from InchIAPI
Instance Method Summary collapse
- #get_compound(csid) ⇒ Object
- #get_compound_spectra(csid) ⇒ Object
- #get_compounds(csids) ⇒ Object
- #get_spectra(spectrum_ids) ⇒ Object
- #get_spectrum(spectrum_id) ⇒ Object
-
#initialize(token = '', header = {}) ⇒ ChemSpider
constructor
A new instance of ChemSpider.
Methods included from SpectraAPI
#all_spectra, #all_spectra_info, #get_compound_spectra_info, #get_spectra_info_list, #get_spectrum_info
Methods included from MassSpecAPI
#databases, #get_extended_compound_info, #get_extended_compound_info_list
Methods included from XmlUtils
#array_from_xml, #get_first_node, #get_nodes, #hash_from_string, #hash_from_xml
Methods included from InchIAPI
#get_original_mol, #inchi_key_to_csid, #inchi_to_csid
Constructor Details
#initialize(token = '', header = {}) ⇒ ChemSpider
Returns a new instance of ChemSpider.
17 18 19 20 21 22 |
# File 'lib/ruspider/chemspider.rb', line 17 def initialize(token = '', header = {}) @rest = RestClient.new(token, header) InchIAPI.instance_method(:initialize).bind(self).call(@rest) MassSpecAPI.instance_method(:initialize).bind(self).call(@rest) SpectraAPI.instance_method(:initialize).bind(self).call(@rest) end |
Instance Method Details
#get_compound(csid) ⇒ Object
24 25 26 |
# File 'lib/ruspider/chemspider.rb', line 24 def get_compound(csid) Compound.new(csid, self) end |
#get_compound_spectra(csid) ⇒ Object
40 41 42 43 44 |
# File 'lib/ruspider/chemspider.rb', line 40 def get_compound_spectra(csid) get_spectra_info_list([csid]).map do |x| Spectrum.from_info_dict(x, self) end end |
#get_compounds(csids) ⇒ Object
28 29 30 |
# File 'lib/ruspider/chemspider.rb', line 28 def get_compounds(csids) csids.map { |x| Compound.new(x, self) } end |