Understanding SMILES
Every molecule in this project is given as a SMILES string (Simplified Molecular Input Line Entry System). In Iteration 1 you used these strings without reading them. In this iteration you work with the raw data, so it helps to know what a SMILES string says about a molecule, and what it does not say. You don’t need to write SMILES strings yourself, and you don’t need a chemistry background for this page.
SMILES: a way to write the structure of a molecule as a single line of text: its atoms, the bonds between them, and its rings.
Cn1c2ccccc2c2ccc(-c3ccc(-c4ccc(-c5cccs5)c5nonc54)s3)cc21
Atoms
Each atom is written as its element symbol: C for carbon, N for nitrogen, O for oxygen, S for sulfur. Atoms written next to each other are bonded. So CCO is a carbon bonded to a carbon, bonded to an oxygen: ethanol.
Hydrogen atoms are usually left out. Every atom gets as many hydrogens as it needs to have its normal number of bonds. Carbon normally has four bonds, so the first C in CCO has three hydrogens. The drawings follow the same habit: a corner or end of a line without a letter is a carbon, and its hydrogens are not drawn.
CCO, as it is usually drawnCCO, with all hydrogens drawnSome atoms need square brackets: elements outside the common set B, C, N, O, P, S, F, Cl, Br and I, such as silicon ([Si], or [SiH2] for a silicon atom with two hydrogens), and atoms with a charge or an explicit hydrogen, such as [O-] or [nH]. An aromatic atom in brackets is lowercase too: [se] is a selenium atom in an aromatic ring, as in selenophene, the selenium version of thiophene below. You will see [Si], [SiH2] and [se] in the project molecules.
Bonds
A single bond needs no symbol. A double bond is written as = and a triple bond as #.
CCO: single bonds onlyCC=O: a double bondCC#N: a triple bondBranches
A SMILES string is read from left to right, like a path through the molecule. When the path splits, the side branch goes in parentheses, and the path continues after the closing parenthesis. In CC(O)CC, the O hangs off the second carbon, and the chain continues with two more carbons. Branches can contain bonds and further branches: in CC(=O)O, the branch is a double-bonded oxygen.
CC(O)CC: the branch is the OCC(=O)O: the branch is the =ORings
A line of text cannot close a loop, so rings are written as a chain plus a label. A digit after an atom opens a ring, and the same digit later closes it: the two atoms with that digit are bonded. C1CCCCC1 is a chain of six carbons in which the first and the last are bonded, a ring of six.
When a molecule has several rings, each ring gets its own digit while it is open. A digit can be used again after its ring is closed, so the digits count open rings, not all rings. In the long project molecule above, the digits go up to 5, but the molecule has more than five rings.
C1CCCCC1: the two 1s create the highlighted bondc1ccc2ccccc2c1: two ring closures, 1 and 2Aromatic rings
Lowercase letters mark atoms in an aromatic ring: a flat ring in which the electrons are shared over the whole ring, as in benzene. Benzene can be written as c1ccccc1 or, with alternating single and double bonds, as C1=CC=CC=C1. Both strings describe the same molecule.
Aromatic rings are everywhere in this project. Organic solar-cell molecules are often long chains of rings like the ones below, for example rings with a sulfur atom (s).
The letters are not always taken literally. RDKit decides itself which rings are aromatic, so it changes some strings when it reads them: in some of the project molecules, a ring written in lowercase is not aromatic for RDKit, or the other way around. Compute features from the molecule that RDKit makes (Chem.MolFromSmiles), not from the letters of the string.
c1ccccc1c1ccsc1c1ccc2nsnc2c1What a SMILES string does not say
SMILES describes which atoms are bonded to which. It does not describe the shape of the molecule in space: the drawings on this page are flat, but real molecules are three-dimensional and can bend and rotate.
Some molecules have the same atoms and bonds but a different arrangement in space. SMILES has optional symbols for this: / and \ for the two sides of a double bond, and @ and @@ for the arrangement around an atom. When these symbols are left out, the string does not say which of the arrangements is meant.
F/C=C/F: the fluorines on opposite sidesF/C=C\F: the fluorines on the same sideFC=CF, without the slashes, can be either of the two.
The SMILES strings in this project contain none of these symbols. Two molecules that differ only in such an arrangement would therefore have the same string, and the same descriptors.
One molecule, many strings
You can start a SMILES string at any atom, choose the order of the branches, number the rings in another way, and write aromatic rings in lowercase or with alternating bonds. Each choice gives another valid string for the same molecule:
| Molecule | Some valid SMILES strings |
|---|---|
| Ethanol | CCO, OCC, C(O)C |
| Thiophene | c1ccsc1, s1cccc1, C1=CSC=C1 |
| Acetic acid | CC(=O)O, OC(=O)C |
The same holds for the long molecules of the project. These two strings describe the molecule at the top of this page:
Cn1c2ccccc2c2ccc(-c3ccc(-c4ccc(-c5cccs5)c5nonc54)s3)cc21
c1cc(-c2ccc(-c3cc4c(c5ccccc5n4C)cc3)s2)c2nonc2c1-c1sccc1
A canonical SMILES is one string chosen by a fixed set of rules, so that a molecule always gets the same string, however it was written before. RDKit, the chemistry library of this course, computes it when it reads a molecule and writes it out again:
Canonical SMILES: the one SMILES string that a program always produces for a given molecule.
from rdkit import Chem
for smiles in ["CCO", "OCC", "C(O)C"]:
print(Chem.MolToSmiles(Chem.MolFromSmiles(smiles)))
# CCO
# CCO
# CCOThe rules differ between programs, and sometimes between versions of the same program. The canonical SMILES of RDKit is not the same as that of another chemistry package, so canonical strings can only be compared when they were made by the same software. A string is also not canonical just because it is in a dataset: the first string of the project molecule above comes from the starter dataset, and RDKit’s canonical version of it has c45) where that string has c54).
Further reading
- SMILES: A Simplified Chemical Language, in the Daylight Theory Manual: the full description of SMILES, including charges, isotopes and the arrangement of atoms in space.
- Weininger, D. (1988). SMILES, a chemical language and information system. 1. Introduction to methodology and encoding rules. Journal of Chemical Information and Computer Sciences, 28(1), 31–36. The paper that introduced SMILES.