Molecule
Details and Options
- Molecule is always converted to an optimized representation and treated as raw by functions like AtomQ and for purposes of pattern matching.
- name can be any of the following forms:
-
"identifier" a systematic chemical name, SMILES or InChI string Entity["Chemical",entity] a chemical entity ExternalIdentifier[type,id] an external identifier of the given type BioSequence[type,seq] biomolecular sequence of the given type BioMolecule[…] a biomolecule - For Molecule[ExternalIdentifier[type, id]], type may be one of "PubChemCompoundID", "PubChemSubstanceID", "InChI" or "ChEMBLID".
- For Molecule[BioSequence[type,seq]], type should be one of "DNA", "RNA", "Peptide", "CircularDNA", "CircularRNA", "CircularPeptide" or "HybridStrand".
- Atoms can be specified in the following forms:
-
"sym" atom with atomic symbol "sym" (e.g. "C", "Cl") Entity["Element",element] atom of a given element Entity["Isotope",isotope] atom of the specified isotope Atom[elemspec,"prop""val",…] atom with specified properties - Bonds can be entered as Bond[{id1,id2},type], where idi is an atom index and type is one of "Single", "Double", "Triple" or "Aromatic".
- Hydrogen atoms may be omitted from the atom list if their presence can be inferred from the valence and bonding of the atoms present.
- Possible options include:
-
AtomCoordinates Automatic three-dimensional coordinates IncludeAromaticBonds True whether to mark bonds as "Aromatic" MetaInformation <||> an association for user-supplied data StereochemistryElements None a list specifying stereochemical arrangement AtomDiagramCoordinates Automatic two-dimensional coordinates ValenceFilling Automatic whether to fill unmet valences with hydrogens - MoleculeQ[mol] gives True only if mol corresponds to a valid molecule expression.
- Graph[Molecule[…]] returns a Graph object.
- Property values for molecules can be accessed via mol["property"], which is equivalent to MoleculeValue[mol,"property"].
Examples
open all close allBasic Examples (4)
Create a molecule from a list of atoms and bonds:
Molecule[{"O", "H", "H"}, {Bond[{1, 2}, "Single"], Bond[{1, 3}, "Single"]}]Create a molecule from a chemical Entity:
Molecule[Entity["Chemical", "Caffeine"]]Create a Molecule from a SMILES string:
Molecule["C[C@H](Cc1c[nH]c2c1ccc(c2)O)N"]Create a molecule from a systematic chemical name:
Molecule["N,N-dimethyl-3-[(9R,10S)-10-methyl-2-(trifluoromethyl)-9,10-dihydroanthracen-9-yl]propan-1-amine"]Scope (2)
Molecule can parse a wide range of chemical nomenclature, reading and understanding the bits and pieces of a chemical name:
Molecule /@ {"1,3-dichlorobenzene", "2,4-dichlorobenzene", "4-chloro,6-chlorobenzene", "meta-dichlorobenzene"}Each of the names created the same molecule:
MoleculeMatchQ[Entity["Chemical", "1,3Dichlorobenzene"]] /@ %Use "Element" and "Isotope" entities to populate the atom list:
Molecule[{Entity["Element", "Oxygen"], Entity["Isotope", "Hydrogen2"], Entity["Isotope", "Hydrogen2"]}, {Bond[{1, 2}, "Single"], Bond[{1, 3}, "Single"]}]The list of atoms has been converted to the canonical form:
AtomList@%Options (9)
AtomCoordinates (2)
By default Molecule will compute coordinates when they are not given:
Molecule["water"]["AtomCoordinates"]//NormalPass in pre-computed coordinate to disable automatic generation:
Molecule["water", AtomCoordinates -> {{0, 0, 0}, {-.75, -.5, 0}, {.75, .5, 0}}]%["AtomCoordinates"]//NormalCreate a molecule with coordinates specified in angstroms:
Molecule[{"O", "O"}, {Bond[{1, 2}, "Double"]}, AtomCoordinates -> {{0, 0, 0}, {0, 1.2075, 0}}]The specified coordinates are used to compute geometric properties:
%["BondLengths"]AtomDiagramCoordinates (1)
By default Molecule will compute 2D diagram coordinates when they are not given:
Molecule["water"]["AtomDiagramCoordinates"]Pass in pre-computed coordinate to disable automatic generation:
Molecule["water", AtomDiagramCoordinates -> {{0, 0}, {-.75, .5}, {.75, .5}}]%["AtomDiagramCoordinates"]IncludeAromaticBonds (1)
IncludeHydrogens (2)
Create a Molecule from a SMILES string with implicit hydrogens:
m = Molecule[ "CC"]InputForm[m]Setting IncludeHydrogens to All will make all hydrogen atoms explicit:
m2 = Molecule[ "CC", IncludeHydrogens -> All]InputForm[m2]These two expressions represent the same molecule and return the same property values:
MoleculeValue[{m, m2}, "MolecularMass"]But they have different memory footprints:
ByteCount /@ {m, m2}Create a molecule with a mixture of explicit and implicit hydrogen atoms:
m = Molecule["C[C]([H])([H])[H]"]The "SMILES" property will contain the explicit hydrogens:
m["SMILES"]But the "CanonicalSMILES" property will not:
m["CanonicalSMILES"]StereochemistryElements (2)
Create a molecule with a defined stereocenter:
m1 = Molecule[{Atom["N"], Atom["C"], Atom["Br"], Atom["Cl"], Atom["C"]}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{2, 4}, "Single"], Bond[{2, 5}, "Single"]}, StereochemistryElements -> {<|"StereoType" -> "Tetrahedral", "ChiralCenter" -> 2, "Direction" -> "Counterclockwise", "FiducialAtom" -> 1, "Ligands" -> {3, 4, 5}|>}]Find its absolute stereo configuration:
m1[{"AtomChirality", 2}]m2 = Molecule[{"N", "C", "Br", "Cl", "C"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{2, 4}, "Single"], Bond[{2, 5}, "Single"]}, StereochemistryElements -> {<|"StereoType" -> "Tetrahedral", "ChiralCenter" -> 2, "Direction" -> "Clockwise", "FiducialAtom" -> 1, "Ligands" -> {3, 4, 5}|>}]Find its absolute stereo configuration:
m2[{"AtomChirality", 2}]Create a molecule with defined geometry around a double bond:
m1 = Molecule[{"Cl", "C", "C", "C", "Cl", "C", "Cl"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{3, 4}, "Double"], Bond[{4, 5}, "Single"], Bond[{4, 6}, "Single"], Bond[{3, 7}, "Single"]}, StereochemistryElements -> {<|"StereoType" -> "DoubleBond", "StereoBond" -> {3, 4}, "Ligands" -> {7, 5}, "Value" -> "Opposite"|>}]Next, create its geometric isomer:
m2 = Molecule[{"Cl", "C", "C", "C", "Cl", "C", "Cl"}, {Bond[{1, 2}, "Single"], Bond[{2, 3}, "Single"], Bond[{3, 4}, "Double"], Bond[{4, 5}, "Single"], Bond[{4, 6}, "Single"], Bond[{3, 7}, "Single"]}, StereochemistryElements -> {<|"StereoType" -> "DoubleBond", "StereoBond" -> {3, 4}, "Ligands" -> {7, 5}, "Value" -> "Together"|>}]The geometry is reflected in the SMILES and InChI identifiers:
MoleculeValue[{m1, m2}, "SMILES"]MoleculeValue[{m1, m2}, "InChI"]ValenceFilling (1)
By default, empty atomic valences will be filled with hydrogen atoms:
Molecule[{"O"}, {}]Use ValenceFillingNone to disable filling open valences:
Molecule[{"O"}, {}, ValenceFilling -> None]Properties & Relations (1)
Create a Graph from a Molecule:
g = Graph[Molecule["carbon dioxide"]]Retrieve atom information from the graph using AnnotationValue:
AnnotationValue[{g, VertexList[g]}, "AtomicNumber"]Possible Issues (2)
Hydrogen atoms may be omitted from the atoms list and will be inferred from common atomic valence:
Molecule[{"C", "C"}, {Bond[{1, 2}, "Single"]}]AtomCount[%]Molecule[{"C", "C"}, {Bond[{1, 2}, "Single"]}, ValenceFilling -> None]AtomCount[%]A chemical formula is not sufficient to determine molecular structure:
Molecule["H2SO4"]Use Interpreter to find the appropriate "Chemical" entity first:
Interpreter["Chemical"]["H2SO4"]Molecule[%]Neat Examples (2)
Filtering a group of molecules for those containing a particular substructure or functional group is intuitive and simple. Create a list of molecules using the
entity class:
(ketones = Map[Molecule, EntityClass["Chemical", "Ketones"]["SMILES"]])//ShortNow use a SMARTS pattern to select only those ketones that are also diaryl ethers:
etherPattern = MoleculePattern["[c][OX2][c]"];
Select[ketones, MoleculeContainsQ[ etherPattern]]Generate 2D diagrams and highlight the diaryl ether functional group:
Table[MoleculePlot[m, etherPattern], {m, %}]Create a WordCloud of different synonyms for the same molecule, together with the molecule's structure diagram:
names = {"(E)-3-(4-hydroxy-3-methoxy-phenyl)
prop-2-enoic acid", "(E)-3-(4-hydroxy-3-methoxyphenyl)-2-propenoic acid", "(E)-3-(4-hydroxy-3-methoxyphenyl)
acrylic acid", "(E)-3-methoxy-4-hydroxycinnamic acid", "(E)-4-hydroxy-3-methoxycinnamic acid", "trans-4-hydroxy-3-methoxycinnamic acid", "ferulic acid", "coniferic acid", "trans-ferulic acid", "(E)-ferulic acid", "COc1cc(ccc1O)/C=C/C(=O)O"};
plot = MoleculePlot[Molecule@First@names, ColorRules -> {_ -> White}];
WordCloud[Join[{1 -> plot}, Thread[.2 -> names]], PlotTheme -> "Marketing", ImageSize -> {300, 300}]See Also
MoleculeValue MoleculePlot MoleculePlot3D MoleculePattern MoleculeModify MoleculeQ MoleculeDraw Atom Bond BioSequence ChemicalData MoleculeRecognize ExternalIdentifier ChemicalInstance MoleculeFingerprint
Entity Types: Chemical Protein
Function Repository: SelectAtoms3D ChemicalNameToSMILES IUPACName AlkaneIsomers MolecularComplexity MoleculeFingerprintSimilarity PubChemSimilaritySearch RingMoleculeQ SmilesString RandomSmilesString PointGroupSymbol
Related Links
Text
Wolfram Research (2019), Molecule, Wolfram Language function, https://reference.wolfram.com/language/ref/Molecule.html (updated 2020).
CMS
Wolfram Language. 2019. "Molecule." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/Molecule.html.
APA
Wolfram Language. (2019). Molecule. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Molecule.html
BibTeX
@misc{reference.wolfram_2026_molecule, author="Wolfram Research", title="{Molecule}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Molecule.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_molecule, organization={Wolfram Research}, title={Molecule}, year={2020}, url={https://reference.wolfram.com/language/ref/Molecule.html}, note=[Accessed: 13-June-2026]}