Function Repository Resource:

ChemicalNameToSMILES

Source Notebook

Convert a chemical name into a SMILES identifier string

Contributed by: Wolfram Chemistry Team

ResourceFunction["ChemicalNameToSMILES"]["name"]

returns a SMILES string corresponding to the given chemical name.

Details

ResourceFunction["ChemicalNameToSMILES"] uses the Open Parser for Systematic IUPAC Nomenclature (OPSIN) to create a chemical graph from a given name, which is then converted to a SMILES string.
The input for ResourceFunction["ChemicalNameToSMILES"] must be a string. The return value can be a SMILES string or a Failure object.
ResourceFunction["ChemicalNameToSMILES"] takes the following options:
"AllowRadicals"Truewhether to return a SMILES string for fragments
"AddDummyAtoms"Falsewhether to add wildcard atoms to fragments
"Canonicalize"Truewhether to canonicalize the SMILES string
"FailOnBadStereochemistry"Truewhether to return a Failure for inputs with bad stereochemistry

Examples

Basic Examples (2) 

Find the SMILES string from a chemical name:

In[1]:=
ResourceFunction[
 "ChemicalNameToSMILES"]["2-amino-14,16-dimethyloctadecan-3-ol"]
Out[1]=

Plot the molecule in 3D:

In[2]:=
MoleculePlot3D[%]
Out[2]=

Use a chemical name with defined stereochemistry:

In[3]:=
ResourceFunction[
 "ChemicalNameToSMILES"]["(2R,3S,4S,5R)-3-(dimethylamino)-2,4,5-trihydroxyhexanal"]
Out[3]=

Plot the molecule in 2D:

In[4]:=
MoleculePlot[%]
Out[4]=

Scope (2) 

When given an invalid chemical name, ChemicalNameToSMILES will return a Failure identifying the uninterpretable portion of the name:

In[5]:=
ResourceFunction[
 "ChemicalNameToSMILES"]["3,6-Dideoxy-3-(dimethylamina)-D-glucose"]
Out[5]=

Fixing the typographical error allows the name to be parsed:

In[6]:=
ResourceFunction[
 "ChemicalNameToSMILES"]["3,6-Dideoxy-3-(dimethylamino)-D-glucose"]
Out[6]=

Options (4) 

AddDummyAtoms (1) 

When parsing a chemical substituent, it is possible to add dummy atoms at the relevant attachment points:

In[7]:=
ResourceFunction["ChemicalNameToSMILES"]["carboxyl", "AddDummyAtoms" -> #] & /@ {True, False}
Out[7]=

AllowRadicals (1) 

By default, ChemicalNameToSMILES will parse fragment names such as "oxo" and "keto" as radicals with unpaired electrons. Use the option "AllowRadicals" to disable this behavior:

In[8]:=
ResourceFunction["ChemicalNameToSMILES"]["carboxyl", "AllowRadicals" -> #] & /@ {True, False}
Out[8]=

Canonicalize (2) 

SMILES strings are canonicalized by default, so these two equivalent names return the same result:

In[9]:=
ResourceFunction[
 "ChemicalNameToSMILES"] /@ {"1,3-dichlorobenzene", "1,5-dichlorobenzene"}
Out[9]=

Use the "Canonicalize" option to disable this:

In[10]:=
ResourceFunction["ChemicalNameToSMILES"][#, "Canonicalize" -> False] & /@ {"1,3-dichlorobenzene", "1,5-dichlorobenzene"}
Out[10]=

Version History

  • 1.0.1 – 17 March 2023
  • 1.0.0 – 27 September 2019

Source Metadata

Related Resources

License Information