Function Repository Resource:

SmilesPlot

Source Notebook

Visualize a SMILES string together with the molecule it represents

Contributed by: Jason Biggs

ResourceFunction["SmilesPlot"][smiles]

returns an annotated molecule plot labeled by the input SMILES string 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 bold.
Hovering over ring closures, represented by integers in a SMILES string, will highlight all atoms in the ring.
Hovering over parentheses in the SMILES string will highlight all enclosed atoms.

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", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]@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", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][smiles]
Out[4]=

Scope (2) 

SmilesPlot will work with "Chemical" entities:

In[5]:=
ResourceFunction[
 "SmilesPlot", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][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/eeed8259-c0e1-415b-b9bd-15796ffd62ea"]
Out[6]=

Options (1) 

ColorFunction (1) 

Specify a color function for the atoms:

In[7]:=
ResourceFunction[
 "SmilesPlot", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["OC(=O)[C@@H](c1ccc(s1)C(=O)c1ccccc1)C", ColorFunction -> "SolarColors"]
Out[7]=

Possible Issues (1) 

Some SMILES strings will be canonicalized before plotting:

In[8]:=
ResourceFunction[
 "SmilesPlot", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["CC1=CC(=O)/C(=c\\2/cc[nH][nH]2)/C(=O)O1"]
Out[8]=

Publisher

JasonB

Version History

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

Related Resources

License Information