From 640789982f3322509b47e835e1e5c4f80129fd1c Mon Sep 17 00:00:00 2001 From: RI-INBRE Molecular Informatics Core Date: Thu, 13 Mar 2025 14:19:01 -0400 Subject: [PATCH] Update pubchempy.py Canonical SMILES and Isometric SMILES are listed as deprecated in favor of SMILES (both stereoscopic and isometric) on the PUG REST documentation. Added capability to get SMILES string as follows: def run(Compound_Name): compounds = pcp.get_compounds(Compound_Name, 'name') for c in compounds: print(c.to_dict(properties=['smiles'])['smiles']) --- pubchempy.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pubchempy.py b/pubchempy.py index 8de112f..4078ec0 100644 --- a/pubchempy.py +++ b/pubchempy.py @@ -354,6 +354,7 @@ def get_assays(identifier, namespace='aid', **kwargs): PROPERTY_MAP = { 'molecular_formula': 'MolecularFormula', 'molecular_weight': 'MolecularWeight', + 'smiles': 'SMILES', 'canonical_smiles': 'CanonicalSMILES', 'isomeric_smiles': 'IsomericSMILES', 'inchi': 'InChI', @@ -827,14 +828,19 @@ def molecular_weight(self): """Molecular Weight.""" return _parse_prop({'label': 'Molecular Weight'}, self.record['props']) + @property + def smiles(self): + """SMILES, with both stereochemical and isotopic information.""" + return _parse_prop({'label': 'SMILES'}, self.record['props']) + @property def canonical_smiles(self): - """Canonical SMILES, with no stereochemistry information.""" + """Canonical SMILES, with no stereochemistry information (deprecated).""" return _parse_prop({'label': 'SMILES', 'name': 'Canonical'}, self.record['props']) @property def isomeric_smiles(self): - """Isomeric SMILES.""" + """Isomeric SMILES (deprecated).""" return _parse_prop({'label': 'SMILES', 'name': 'Isomeric'}, self.record['props']) @property