Skip to content

Commit b02603d

Browse files
authored
add IUPAC Name and InChI to compound record (#1)
1 parent fe09838 commit b02603d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/pubchem_api.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def initialize(data)
2020
end
2121

2222
class CompoundRecord < APIResponse
23-
attr_reader :cid, :molecular_formula, :molecular_weight, :canonical_smiles, :inchi_key
23+
attr_reader :cid, :iupac_name, :molecular_formula, :molecular_weight, :canonical_smiles, :inchi, :inchi_key
2424

2525
def initialize(data)
2626
super(data)
@@ -29,9 +29,11 @@ def initialize(data)
2929

3030
# Extract properties from the 'props' array
3131
props = compound['props']
32+
@iupac_name = extract_prop(props, 'IUPAC Name')
3233
@molecular_formula = extract_prop(props, 'Molecular Formula')
33-
@molecular_weight = extract_prop(props, 'Molecular Weight').to_f
34+
@molecular_weight = extract_prop(props, 'Molecular Weight')
3435
@canonical_smiles = extract_prop(props, 'SMILES', 'Canonical')
36+
@inchi = extract_prop(props, 'InChI', 'Standard')
3537
@inchi_key = extract_prop(props, 'InChIKey', 'Standard')
3638
end
3739

0 commit comments

Comments
 (0)