Convert a SMILES string to a chemical structure in Python

To convert a SMILES string to a chemical image in Python, you can use the RDKit library. RDKit is a widely used cheminformatics library that provides various functionalities for working with chemical data, including the ability to generate chemical structures from SMILES strings and save them as images.

Here is an example to show how to use the RDKit library to convert the SMILES string to a chemical structure.

from rdkit import Chem
from rdkit.Chem import Draw

# Example Isomorphic SMILES string
smi = 'C[C@]12CC[C@H]3[C@H]([C@@H]1CCC2=O)CCC4=C3C=CC(=C4)OS(=O)(=O)O'

# Generate a molecule object from the given SMILES string
mol = Chem.MolFromSmiles(smi)

# Generate an image of the molecule
img = Draw.MolToImage(mol)

# Save the image to a file
img.save('smi_image.png')

Using Chem.MolFromSmiles(smiles), we generate a molecule object from the SMILES string. Next, we use Draw.MolToImage(mol) to generate an image of the molecule.

The above code will generate the following chemical structure:

Estrone hydrogen sulfate

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.