Chalk−1

Chemistry · General chemistry II · Concept

SMILES: a structure written as a line of text

SMILES is a way to type a structure. Atoms are their symbols, neighbors in the string are bonded, a branch goes in parentheses, and a ring is closed by a pair of matching digits. Square brackets hold whatever is unusual, such as a charge, a stated number of hydrogens, an isotope or a stereocenter. One molecule has many valid strings, so programs settle on one canonical string when they need to compare.

A concrete case

Ethanol in three letters

Take the three letters CCO. Each letter is an atom, and letters side by side are bonded. A carbon is bonded to a carbon, which is bonded to an oxygen.

No hydrogen is written, yet every atom gets its share. A carbon makes four bonds and an oxygen two. The first carbon has one bond in the string, so it carries 3 hydrogens. The second carbon has two bonds and carries 2, and the oxygen has one and carries 1.

That adds up to 3+2+1=6 hydrogens on CH3CH2OH, the formula C2H6O. Three letters hold the whole of ethanol.

3+2+1=6

The rule

What a SMILES string records

A SMILES string lists the atoms of a molecule and says which are bonded. It holds no coordinates, angles or bond lengths, so it carries the same connections as a skeletal structure and none of the layout. Read it left to right. Each atom is bonded to the one before it unless a parenthesis, a digit or a dot says otherwise.

Atoms and implied hydrogens

Ten elements can be written bare: B, C, N, O, P, S, F, Cl, Br and I, called the organic subset. A bare atom gets as many hydrogens as its normal valence leaves room for, so C alone is methane, CH4.

Every other element, and any atom with a charge, a stated hydrogen count or a mass number, goes in square brackets, where nothing is implied. [Na+] is a sodium ion, [NH4+] is ammonium, and [13CH4] is methane made with carbon-13.

Bonds, branches, rings and marks

A single bond is not written. A double bond is = and a triple bond is #. A branch goes in parentheses right after the atom it hangs from, and after the closing parenthesis the chain carries on from that same atom. In CC(=O)O, acetic acid, the =O is a one-atom branch on the second carbon, and the final O is bonded to that carbon too. A dot separates pieces that are not bonded to each other.

Reading SMILES symbols
SymbolMeaningExample
C, N, O, Cl and the rest of the organic subsetAn atom with its hydrogens impliedCCO is ethanol
[ ]An atom written in full: element, hydrogens, charge, mass number[NH4+] and [13CH4]
= and #A double bond and a triple bondC=C is ethene; C#N is hydrogen cyanide
( )A branchCC(C)C is 2-methylpropane
1, 2, …Ring closure: the two atoms with the same digit are bondedC1CCCCC1 is cyclohexane
c, n, oAn aromatic atom in a ringc1ccccc1 is benzene
.Pieces that are not bonded[Na+].[Cl-] is sodium chloride
/ and \The side of a double bond a group is onF/C=C/F is trans
@ and @@The arrangement around a stereocenterN[C@@H](C)C(=O)O is L-alanine

Rings

To write a ring, break one of its bonds and give the two atoms the same digit. In C1CCCCC1, cyclohexane, the first and last carbons both carry the 1, so they are bonded to each other. The digit is a label, not a count of atoms, and it can be used again once its ring is closed. Two rings that are open at the same time need two different digits.

Aromatic rings

Atoms in an aromatic ring can be written lowercase. That stands for the ring’s delocalized bonding without choosing where the double bonds sit, so c1ccccc1 is benzene. The same molecule can also be written with capital letters and alternating double bonds, C1=CC=CC=C1. A lowercase atom that is not in a ring is an error.

Stereochemistry

Plain SMILES says nothing about arrangement in space. Extra marks add it.

Around a double bond, / and \ on the two neighboring single bonds work as a pair. When they lean the same way, as in F/C=C/F, the groups are on opposite sides. That is trans, and E here because fluorine outranks hydrogen on each carbon. When they lean opposite ways, as in F/C=C\F, the groups are on the same side, cis, here Z.

At a stereocenter, @ or @@ inside the brackets gives the arrangement. Look from the atom written before the center. The atoms that follow in the string run counterclockwise for @ and clockwise for @@, and a hydrogen written inside the brackets counts first among them. Those marks describe the string’s own atom order, so @ does not mean R and @@ does not mean S.

Why it works

Why one line of text can hold a structure

Strip a molecule down to its connections and it is a set of atoms with lines between them. Walking along those lines from atom to atom writes them down in order, the way CCO walks from one end of ethanol to the other.

A walk cannot go two ways at once. At a fork, the string finishes one side inside parentheses and then carries on along the other. A ring has no end, so the string cuts one of its bonds and labels the two loose ends with the same digit. Every bond ends up written exactly once, as two neighbors, a branch or a pair of digits.

The hydrogens can stay out because each common element has a normal number of bonds, four for carbon, three for nitrogen and two for oxygen. Whatever the string leaves unused is filled with hydrogen. Since the walk may start anywhere and take the branches in any order, one molecule always has many correct strings.

The method

Writing and reading a string

To write one:

1. Start at an atom, often one end of the longest chain.

2. Write each atom as you walk along a bond to it. Put = or # in front of an atom joined by a double or a triple bond.

3. At a fork, write one branch in parentheses, then carry on along the other.

4. For a ring, give the first ring atom a digit, walk around, and put the same digit on the last ring atom.

5. Put in brackets any atom with a charge, a stated hydrogen count or a mass number, and any element outside the organic subset.

To read one, follow the chain and skip the parentheses, then hang each branch on the atom just before it, join each pair of matching digits, and fill every bare atom with hydrogens.

Where it breaks

Where it breaks

A formula is not a SMILES string. CH4 asks for an H written bare, which SMILES does not allow, and methane is simply C. Formulas list atoms by element, while a string lists them in the order they are joined.

Two strings that look alike can be different molecules. CC(C)CCC and CCC(C)CC differ only in where the parenthesis sits, and they are 2-methylpentane and 3-methylpentane. Two strings that look nothing alike, such as Cc1ccccc1 and CC1=CC=CC=C1, can be one molecule.

Plain strings drop arrangement in space. CC=CC is but-2-ene without saying cis or trans, and CC(O)CC is butan-2-ol without saying R or S.

Implied hydrogens assume the normal valence. An atom with a charge or an unusual number of bonds needs brackets that state its hydrogens. Chalk also draws only named elements and single, double and triple bonds.

What Chalk refuses

Chalk reads the strict OpenSMILES grammar. It never guesses at a string it cannot read. It refuses the string and says why, and most refusals come from typing a formula where a SMILES belongs.

What Chalk says about a string it cannot read
TypedChalk saysWrite instead
CH4H goes in square brackets in SMILES: write [H].C, because the hydrogens of a bare atom are implied
CCl4Ring bond 4 opens here and never closes: a ring number is written twice, once on each atom it joins.ClC(Cl)(Cl)Cl
NaNa goes in square brackets in SMILES: write [Na].[Na], or [Na+] for the ion
D2OD is not a SMILES atom; write [2H].[2H]O[2H]
CC(CThis branch is never closed: add ).CC(C)C
C1CCCCRing bond 1 opens here and never closes: a ring number is written twice, once on each atom it joins.C1CCCC1

Check your answer

Check your answer

Count the formula your string makes. Fill in the hydrogens atom by atom and compare the total with the compound’s formula. Toluene, Cc1ccccc1, has to come to C7H8. A string that gives C7H10 has lost a double bond or a lowercase letter.

Read the string back as a stranger would. Walk it atom by atom and draw what it says. If the drawing is not the molecule you meant, the string is wrong, even when Chalk accepts it.

A right string can still look different from the key. CCO, OCC and C(C)O are all ethanol. A canonical SMILES is the one string a given program always writes for a molecule, whatever order its atoms arrived in. Chalk writes its own SMILES in the order of your drawing, and Analyze → Canonical SMILES asks RDKit for the canonical one. Different programs can choose different canonical strings, so compare forms written by the same one.

In the Skeletal tool, import your string and the key’s as two drawings and choose Analyze → Compare. Chalk reports “Same compound” when they match. Analyze → Name writes Chalk’s name for the structure.

How a program chooses one string

To write a canonical string, a program first ranks the atoms by properties that do not depend on the order they were typed in. It starts from the element and the number of neighbors, then refines each atom’s rank by the ranks of its neighbors until nothing changes. Ties that remain come from symmetry and are broken by a fixed rule.

The program then writes the string from the lowest-ranked atom and takes branches in rank order. David Weininger introduced SMILES in 1988 and published a ranking method of this kind the next year.

Every program ranks by its own properties, so their canonical strings can differ. The InChI identifier was designed to remove that. One shared, open program computes it, so ethanol’s InChI is the same wherever it is made.

Common mistakes

  • Typing a formula where a SMILES belongs, such as CH4, H2O or CCl4. Neighbors in a string are bonded atoms, so the strings are C, O and ClC(Cl)(Cl)Cl.
  • Writing a hydrogen on a bare atom, as in CC(=O)OH. The last oxygen already gets its hydrogen implied, so acetic acid is CC(=O)O.
  • Reading a ring digit as a number of atoms. In C1CCCCC1 the 1 only marks the two atoms that close the ring, and the ring has six carbons because six C’s are written.
  • Writing a charge or a hydrogen outside brackets, as in OH- for hydroxide. A bare atom cannot carry either, so hydroxide is [OH-].
  • Expecting one correct string. CCO and OCC are both ethanol, so compare canonical forms from one program, not the text as typed.
  • Reading @ as R and @@ as S. The marks follow the order of atoms in the string, and the same center can be written with either one.
  • Writing a metal bare, as in Na. Only the organic subset may stand outside brackets, so sodium is [Na] and its ion is [Na+].
  • Writing lowercase letters for atoms that are not in an aromatic ring, as in ccO. Lowercase marks aromatic ring atoms only, so ethanol stays CCO.

Key terms

SMILES
A way to write a structure as one line of text: atoms as their symbols, branches in parentheses, ring closures as matching digits, as in CCO for ethanol. It records connections, not the drawing’s positions, and one molecule can have several valid SMILES.
Canonical SMILES
The one SMILES string a given program always writes for a molecule, whatever order its atoms were drawn or typed in. Two strings that get the same canonical SMILES from that program describe the same molecule. Different programs may choose different canonical strings.
Skeletal structure
A drawing of an organic molecule in which lines are bonds and each unlabeled end or corner is a carbon. Hydrogens on carbon are not drawn but are filled in so each carbon has four bonds. Other atoms and any charges are labeled.
Isomer
Isomers have the same molecular formula but are different compounds. Constitutional (structural) isomers join their atoms differently, like butane and 2-methylpropane. Stereoisomers share the same connections but differ in three-dimensional arrangement, like cis- and trans-but-2-ene.
Aromaticity
The extra stability of a ring whose pi electrons are delocalized all the way around it. In the simple Hückel model the ring must be flat, with a p orbital on every ring atom overlapping in one continuous cycle, and hold 4⁢n+2 pi electrons (n=0,1,2,…).
Stereocenter
An atom where swapping any two groups gives a different stereoisomer. In organic chemistry it is usually a carbon bonded to four different groups.
E and Z configuration
The label for the arrangement of groups on a double bond. Rank the two groups on each carbon by CIP priority: Z (German zusammen, together) if the higher-ranked groups are on the same side, E (entgegen, opposite) if they are on opposite sides.

Work through an example

What molecule is CC(C)C(=O)O? Give its condensed structure, molecular formula and name.

Read a SMILES string →

Write a SMILES string for a ring →

Read brackets and stereo marks in SMILES →

Sources and scope

Authored study material. Tool results depend on the stated inputs and model assumptions.

After reading

Study it, then try it

Practice the key terms as flashcards, then open the example in its tool, change a value and keep a useful result on your board.

Study the 7 key terms Import CC(C)C(=O)O into the Skeletal tool See it in every representation Practice 1: import the string and check your name Open worked example on a board Organic nomenclature in Chemistry Reference

Your existing work stays on this device. Examples open as editable copies.