Module: Sylfy::Service::PubChem

Defined in:
lib/sylfy/service/pubchem.rb,
lib/sylfy/service/pubchemrest.rb

Defined Under Namespace

Modules: REST

Class Method Summary collapse

Class Method Details

.getnames(inchi) ⇒ Object

Method for setting inchi data member

Parameters:

id

LipidMap id to search

:id, :dataPrimarySource, :xrefs, :relations :inchi, :formula, :smiles, :inchiKey :names



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sylfy/service/pubchem.rb', line 44

def getnames(inchi)
	result = []
	inchi = Rubabel[inchi, :inchi].to_s(:inchikey) if inchi =~ /^InChI\=1S\/[A-Za-z0-9]+(\/[cnpqbtmsih][A-Za-z0-9\-\+\(\)\,]+)+$/
	
	if inchi =~ /^[A-Z]{14}\-[A-Z]{10}(\-[A-N])?/
		Sylfy::Service::PubChem::REST.compound(inchi, :inchikey, "property/IUPACName")["PropertyTable"]["Properties"].each {|e| result.push(e["IUPACName"])}
		Sylfy::Service::PubChem::REST.compound(inchi, :inchikey, :synonyms)["InformationList"]["Information"].each {|e| result += e["Synonym"]}
	end
	
	return result.uniq[0..21]
end

.idbyinchi(inchi) ⇒ Object

Method for setting inchi data member

Parameters:

id

LipidMap id to search

:id, :dataPrimarySource, :xrefs, :relations :inchi, :formula, :smiles, :inchiKey :names



27
28
29
30
31
32
33
34
35
36
# File 'lib/sylfy/service/pubchem.rb', line 27

def idbyinchi(inchi)
	result = []
	if inchi =~ /^InChI\=1S\/[A-Za-z0-9]+(\/[cnpqbtmsih][A-Za-z0-9\-\+\(\)\,]+)+$/
		REST::compound(Rubabel[inchi, :inchi].write(:inchikey), 'inchikey', "cids")["IdentifierList"]["CID"].each {|e| result.push("urn:miriam:pubchem.compound:#{e}")}
	elsif inchi =~ /^[A-Z]{14}\-[A-Z]{10}(\-[A-N])?/
		REST::compound(inchi, 'inchikey', "cids")["IdentifierList"]["CID"].each {|e| result.push("urn:miriam:pubchem.compound:#{e}")}
	end
	
	return result
end