Molecule¶
Represents a chemical molecule as a symbolic expression of atoms and bonds.
The canonical form is Molecule[{atoms…}, {bonds…}, {metadata…}]. An atom is a
bare element symbol, or Atom["El", "Prop" -> value, …] when it carries extra
properties. A molecule can be constructed from a chemical name (whose hydrogens
are materialized as explicit atoms):
… from a SMILES string (organic-subset hydrogens stay implicit):
… or from explicit atom and bond lists (also kept implicit):
Aromatic rings, formal charges, and isotopes are supported. A bracket-atom
hydrogen count rides along as a HydrogenCount property:
MoleculeQ¶
Tests whether an expression is a valid molecule:
AtomList and BondList¶
Return the atoms and bonds of a molecule:
$ wo 'BondList[Molecule["ammonia"]]'
{Bond[{1, 2}, Single], Bond[{1, 3}, Single], Bond[{1, 4}, Single]}
MoleculeValue¶
Computes properties of a molecule
("AtomCount", "BondCount", "AtomList", "BondList",
"MolecularFormula", and "NetCharge"). The molecular formula is returned as a
typeset Row of element symbols with the counts as subscripts:
$ wo 'MoleculeValue[Molecule["caffeine"], "MolecularFormula"]'
Subscript[C, 8]Subscript[H, 10]Subscript[N, 4]Subscript[O, 2]
Properties can also be accessed by applying the molecule to a property name:
Structure diagram¶
In visual hosts (the playground and Woxi Studio) a molecule displays as its 2-D
structure diagram. The same diagram is available anywhere via
ExportString[mol, "SVG"], a standalone SVG document (with an XML declaration):
It is a structure drawing, not a text summary, so it carries no Formula:
label:
MoleculePlot¶
MoleculePlot[mol] draws the full 2-D skeletal structure diagram as a
Graphics object. Atoms are laid out with a spring embedder; single, double,
triple, and aromatic bonds, heteroatom labels, formal charges, and isotope
mass numbers are all drawn. It accepts a molecule or any specification
Molecule itself accepts:
Bonds are drawn as vector polylines rather than <line> elements, matching the
markup wolframscript emits, so a benzene diagram contains no <line>: