Spatial Metabolomics

Converting Chemical SMILES to IUPAC Names: Open Source Tools and Scripts

January 3, 2025 Off By admin
Shares

To convert chemical SMILES strings to IUPAC names, several open-source and freely available tools can be used. Below is a step-by-step guide, including relevant scripts, and a list of recent online tools.


Step 1: Use Open Babel

Open Babel is a powerful open-source cheminformatics toolkit that supports SMILES-to-IUPAC name conversion.

Installation

On Unix-based systems:

bash
sudo apt-get install openbabel

Conversion Example

To convert a SMILES string to IUPAC name:

bash
obabel -:"O=C(Oc1ccccc1C(=O)O)C" -oinchi | grep "InChIKey" | awk '{print $NF}'

Alternatively:

bash
obabel -:"O=C(Oc1ccccc1C(=O)O)C" -oinchi

Note: Open Babel does not directly provide IUPAC names but interfaces with formats like InChI, which can be used for further naming with PubChem services.


Step 2: Use PubChem’s PUG REST API

PubChem provides programmatic access to convert SMILES to IUPAC names using their PUG REST API.

Python Script Example

import requests

def smiles_to_iupac(smiles):
url = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/{}/property/IUPACName/JSON".format(smiles)
response = requests.get(url)
if response.status_code == 200:
data = response.json()
return data['PropertyTable']['Properties'][0]['IUPACName']
else:
return "Error: Unable to fetch IUPAC name"

smiles = "O=C(Oc1ccccc1C(=O)O)C"
iupac_name = smiles_to_iupac(smiles)
print(f"IUPAC Name: {iupac_name}")


Step 3: Use RDKit

RDKit is a cheminformatics library that supports various operations on chemical structures.

Installation

bash
pip install rdkit

Python Script Example

python
from rdkit import Chem
from rdkit.Chem import Descriptors

def smiles_to_iupac(smiles):
mol = Chem.MolFromSmiles(smiles)
if mol:
return Descriptors.MolFormula(mol)
else:
return "Invalid SMILES"

smiles = "O=C(Oc1ccccc1C(=O)O)C"
iupac_name = smiles_to_iupac(smiles)
print(f"IUPAC Name: {iupac_name}")


Step 4: Online Tools

  1. NIH Cactus Chemical Identifier Resolver
    • Converts SMILES to IUPAC and vice versa.
    • Use programmatically or via web interface.
  2. Chemicalize.org
    • A ChemAxon service that provides SMILES-to-IUPAC conversion.
  3. PubChem
    • Offers web-based conversion via their structure editor or PUG REST API.
  4. ChemSpider
    • Allows searching and conversions, including SMILES to IUPAC.

Final Note

While there are multiple solutions, many open-source libraries like Open Babel or RDKit require external databases or APIs to fully support SMILES-to-IUPAC conversion. Combining tools like Open Babel with PubChem’s API provides a robust pipeline.

Shares