Wolfram Research

Function Repository Resource:

SmilesPlot (1.0.0) current version: 2.0.0 »

Source Notebook

Visualize a SMILES string together with the molecule it represents

Contributed by: Jason Biggs

ResourceFunction["SmilesPlot"][smiles]

returns MoleculePlot[Molecule[smiles]] labeled by the SMILES string smiles with corresponding atoms color coded.

Details and Options

SMILES stands for simplified molecular-input line-entry system, and is a line notation for encoding molecular structure in an ASCII string.
The value for smiles should be a valid SMILES string.
Atoms are highlighted with a unique color in both the molecule plot and the SMILES string.
Hovering the mouse over an atom code in the SMILES string will highlight the atom in the structure diagram.
Hovering the mouse over an atom in the structure diagram will make the corresponding atom code in the SMILES string format in bold.

Examples

Basic Examples (2) 

Find the SMILES string for a simple hydrocarbon and visualize it:

In[1]:=
smiles = Entity["Chemical", "3Ethyl2Methylhexane"]["IsomericSMILES"]
Out[1]=
In[2]:=
ResourceFunction["SmilesPlot"]@smiles
Out[2]=

Find the SMILES string for a chemical name and visualize it:

In[3]:=
smiles = ResourceFunction[
ResourceObject[<|"Name" -> "ChemicalNameToSMILES", "ShortName" -> "ChemicalNameToSMILES", "UUID" -> "e19c0563-69d5-422f-b3dc-f13622528b85", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Convert a chemical name into a SMILES identifier string", "RepositoryLocation" -> URL[
      "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "SymbolName" -> "Chemistry`NameToSMILES", "FunctionLocation" -> CloudObject[
      "https://www.wolframcloud.com/obj/a42a9651-a952-49f2-839f-6a11489ceaa0"]|>, ResourceSystemBase -> Automatic]]@
  "4-amino-2,6-diphenylphenol"
Out[3]=
In[4]:=
ResourceFunction["SmilesPlot"][smiles]
Out[4]=

Scope (2) 

SmilesPlot will work with "Chemical" entities:

In[5]:=
ResourceFunction["SmilesPlot"][
 Entity["Chemical", "3AminobutanoicAcid"]]
Out[5]=

SmilesPlot will work with Molecule objects:

In[6]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/402c90c2-eae8-46bb-bdb3-0ba0874bf47d"]
Out[6]=

Options (2) 

Specify a color function for the atoms:

In[7]:=
ResourceFunction["SmilesPlot", ResourceVersion->"1.0.0"]["OC(=O)[C@@H](c1ccc(s1)C(=O)c1ccccc1)C", ColorFunction -> "SolarColors"]
Out[7]=

By default, selected atoms are ringed in blue when mousing over the atom code in the SMILES string. Use the option "HighlightColor" to specify an alternate color:

In[8]:=
ResourceFunction["SmilesPlot", ResourceVersion->"1.0.0"]["OC(=O)[C@@H](c1ccc(s1)C(=O)c1ccccc1)C", ColorFunction -> "BlueGreenYellow", "HighlightColor" -> White, Background -> Lighter[Gray, 0.5]]
Out[8]=

Possible Issues (1) 

Some SMILES strings will be canonicalized before plotting:

In[9]:=
ResourceFunction["SmilesPlot", ResourceVersion->"1.0.0"]["C1=CC=C(C=C1)C2=CC(=CC(=C2O)C3=CC=CC=C3)N"]
Out[9]=

Publisher

JasonB

Version History

  • 2.0.0 – 26 April 2023
  • 1.0.0 – 05 August 2020

Related Resources

License Information