+1 vote
in Programming Languages by (56.8k points)
Using its SMILES string, I want to generate chemical structures for a given compound. What RDKit function(s) should I use?

1 Answer

+2 votes
by (74.2k points)
selected by
 
Best answer

Using the RDKit module, it is very easy to generate the chemical structure for a given compound. First, convert SMILES to molecule using the Chem.MolFromSmiles() function, then use the Draw.MolToImage() function to generate the chemical structure using the molecule.

Here is an example:

from rdkit import Chem

from rdkit.Chem import Draw

smiles = 'O=c1c2cc([N+](=O)[O-])ccc2nc(CN2CCCCC2)n1-c1ccccc1F'

mol = Chem.MolFromSmiles(smiles)

img = Draw.MolToImage(mol)

img.show()

The above code will generate the following chemical structure:
CHEMBL3183411

...