Module: Ruspider::InchIAPI

Includes:
XmlUtils
Included in:
ChemSpider
Defined in:
lib/ruspider/inchi_api.rb

Overview

Constant Summary collapse

API =
'InChi.asmx'

Instance Method Summary collapse

Methods included from XmlUtils

#array_from_xml, #get_first_node, #get_nodes, #hash_from_string, #hash_from_xml

Instance Method Details

#get_original_mol(csid) ⇒ Object



17
18
19
20
# File 'lib/ruspider/inchi_api.rb', line 17

def get_original_mol(csid)
  response = @rest.post(API, 'CSIDToMol', csid)
  response.text
end

#inchi_key_to_csid(inchi_key) ⇒ Object



27
28
29
30
# File 'lib/ruspider/inchi_api.rb', line 27

def inchi_key_to_csid(inchi_key)
  response = @rest.post(API, 'InChIKeyToCSID', inchi_key: inchi_key)
  get_nodes(Nokogiri::XML(response), 'string').first.content.to_i
end

#inchi_to_csid(inchi) ⇒ Object



22
23
24
25
# File 'lib/ruspider/inchi_api.rb', line 22

def inchi_to_csid(inchi)
  response = @rest.post(API, 'InChIToCSID', inchi: inchi)
  get_nodes(Nokogiri::XML(response), 'string').first.content.to_i
end

#initialize(rest) ⇒ Object



13
14
15
# File 'lib/ruspider/inchi_api.rb', line 13

def initialize(rest)
  @rest = rest
end