Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pubchempy.py #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'])
riinbre-bioinfo authored Mar 13, 2025

Verified

This commit was signed with the committer’s verified signature.
commit 640789982f3322509b47e835e1e5c4f80129fd1c
10 changes: 8 additions & 2 deletions pubchempy.py
Original file line number Diff line number Diff line change
@@ -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