MoleculeModify
✖
MoleculeModify
gives a molecule or list of molecules derived from the molecule mol by applying the modification "mod".
gives a molecule or list of molecules derived from the molecule mol by applying the modification "mod" with additional specifications specs.
represents an operator form of MoleculeModify that can be applied to a molecule.
Details and Options




- Operations that modify the molecule's atom list:
-
{"AddAtom",atom} add a disconnected atom {"AddAtom",{atom1,atom2,…}} add a list of atoms {"DeleteAtom",a} delete the atom with index a {"DeleteAtom",{a1,a2,…}} delete the indicated atoms {"ReplaceAtom",aatom} replace the atom with index a with atom {"ReplaceAtom",{a1atom1,…}} replace atoms ai with atomi - atom should have one of 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["sym","prop"val,…] atom with specified properties - "AddAtom" will add a disconnected atom, with no bonds to the rest of the molecule. To add a new atom and bond together use "AddBond".
- "DeleteAtom" will remove any bonds to the atom in question.
- When removing or replacing an atom, the number of explicit hydrogen atoms may be adjusted to maintain proper valence. Disconnected hydrogen atoms will be removed. To disable this behavior, use the option ValenceErrorHandlingFalse.
- Implicit hydrogen atoms are added to the added atoms as normal. To disable implicit hydrogens, use "HydrogenCount"None in the new atom specification.
- Operations that modify atom properties:
-
{"SetFormalCharge",aval} set the formal charge of the atom with index a to val {"SetMassNumber",aval} set the mass number of the atom with index a to val {"SetUnpairedElectronCount",aval} set the number of radical electrons for the given atom - To change a property for multiple atoms, use a list of rules {a1val1,a2val2,…}.
- Operations that modify the molecule's bond list:
-
{"AddBond",{a1,a2}} add a single bond between atoms with indices a1 and a2 {"AddBond",Bond[{a1,a2},"type"]} add a bond of the given type between the given atoms {"AddBond",Bond[{a1,atom},type]} a bond between an atom with index a1 and a new atom represented by atom {"DeleteBond",{a1,a2}} remove the bond between the atoms with the given indices {"SetBondType",{a1,a2}"type"} set the bond type for the bond between atoms with indices a1 and a2 -
"SetAromaticity" convert localized single and double bonds to aromatic "Kekulize" convert aromatic bonds to localized single and double bonds {"RenumberAtoms",{a1,a2,…}} reorder the atoms list so that the atom with index ai appears at position i in the atoms list {"SetMetaInformation",meta} set the molecule's MetaInformation to meta, which should be an association or key-value pair "MakeHydrogensExplicit" convert any implicit hydrogens to explicit "MakeHydrogensImplicit" remove explicit hydrogen atoms when their presence can be inferred by normal valence rules - Information about a molecule's 3D arrangement, independent of the 3D geometry, is stored in the StereochemistryElements option value. The following operations modify the stereo elements:
-
"AssignStereochemistryFromCoordinates" assign tetrahedral and double bond stereochemistry elements from 3D coordinates "RemoveStereochemistry" remove any defined stereochemistry - To change the defined stereochemistry for an atom or bond, use one of the following operations:
-
{"SetAtomChirality",aval} set the chiral value for an atom to "R" or "S" {"SetBondStereo",{a1,a2}val} set the bond stereo value to either "E" or "Z" - Changing the stereo for an atom or bond will affect the 3D coordinates that are generated on demand. If the molecule contains 3D coordinates already, these are discarded when changing the stereochemistry.
-
{"ReplaceSubstructure",pattrepl} replace all occurrences of patt with repl {"ReplaceSubstructure",pattrepl,attchmts} replace patt with repl, using the specified attachment points between pattern and replacement {"ReplaceSubstructureList",pattrepl} replace each occurrence of patt with repl and return a list - Here repl should be a Molecule object or SMILES string, and patt can have one of the following forms:
-
MoleculePattern[…] a valid molecule pattern object {a1,a2,…} a list of atom indices constituting a connected substructure {{a1,a2,…},{b1,b2,…},…} a list of lists of atom indices, each of which will be replaced with repl - attchmts should be a list of rules {p1r1,…} from pattern atom index to replacement atom index. If no attachment points are provided, the first and last atoms from the pattern and replacement are matched.
- When a molecule is plotted in 3D or 2D, coordinates are taken from the AtomCoordinates and AtomDiagramCoordinates option values, respectively. If no coordinates are present in the molecule expression, they are generated automatically.
- The following operations will precompute the automatic coordinates and return a Molecule object containing them:
-
"ComputeAtomCoordinates" compute automatic 3D coordinates for the molecule {"ComputeAtomCoordinates",opts} compute atom coordinates using the options opts {"GenerateConformers",n} compute 3D coordinates n times with a different seed value and return a list of molecules "ComputeAtomDiagramCoordinates" compute 2D coordinates - "ComputeAtomCoordinates" will make all implicit hydrogens explicit in order to embed the molecule.
- "ComputeAtomCoordinates" takes the following options:
-
"Canonicalize" True whether to canonicalize the coordinates "EnergyMinimize" True whether to run a force-field minimization on the coordinates RandomSeeding 1234 how to seed randomness - "GenerateConformers" will return unminimized conformers by default.
- "ComputeAtomDiagramCoordinates" will make implicit those hydrogens attached to carbon, and make explicit those attached to a heteroatom, to match the default output of MoleculePlot. Use {"ComputeAtomDiagramCoordinates",IncludeHydrogensTrue} to include all atoms.
- To change the coordinates for a single atom, use:
-
{"SetAtomPosition",a{x,y,z}} set the position of the specified atom - To canonicalize atom coordinates without changing internal geometry, use:
-
"CanonicalizeAtomCoordinates" translate the molecule's center of mass to the origin and align the principal axes with the Cartesian axes - For general geometry transformations use the following:
-
{"TransformAtomCoordinates",tfun} apply the transformation function tfun to the coordinates - Here tfun should be a TransformationFunction object, e.g. TranslationTransform, ReflectionTransform, etc., or any arbitrary function that operates on and returns a QuantityArray object.
- The following operations modify the internal coordinates:
-
{"SetBondLength", {a1,a2}val} set the bond length between the specified atoms {"SetBondAngle", {a1,a2,a3}val} set the angle between the specified atoms {"SetTorsionAngle",{a1,a2,a3,a4}val} set the torsion angle for a group of four consecutively bonded atoms - These operations also support a list of length or angle changes, e.g. {{a1,a2}val1,…}.
- Here val should be a Quantity object or numeric. If numeric, the units are taken to be "Angstroms" or "AngularDegrees".
- For "SetBondLength", atoms a1 and a2 must be bonded and the bond between them should not be in a ring. All atoms connected to atom a2 are moved.
- For "SetBondAngle", atoms {a1,a2} and {a2,a3} should be bonded and both bonds should not be in rings. All atoms connected to atom a3 are moved.
- For "SetTorsionAngle", atoms {a1,a2}, {a2,a3} and {a3,a4} should be bonded, and bond {a2,a3} should not be in a ring. All atoms connected to atom a4 are moved.
- To minimize the coordinates with respect to the MMFF force field, use the following:
-
"EnergyMinimizeAtomCoordinates" minimize the total force-field energy {"EnergyMinimizeAtomCoordinates",ff} minimize the energy using the force field ff, one of "UFF", "MMFF94" or "MMFF94s" {"EnergyMinimizeAtomCoordinates",constraints} minimize the energy with the given constraints added to the force field - constraints should be a list of bond, angle or torsion constraints of the following forms:
-
{a1,a2}d specify a distance between two atoms {a1,a2,a3}θ specify an angle among three atoms {a1,a2,a3,a4}θ specify a torsion angle among four atoms <… > an association with keys "Atoms", "Value" and "ForceConstant"
Atom Modifications
Bond Modifications
General Modifications
Stereochemistry Modifications
Substructure Replacement
Generating Coordinates
Geometry Modifications
Examples
open allclose allBasic Examples (4)Summary of the most common use cases

https://wolfram.com/xid/0elsynzjvng3a88-qf7fcx


https://wolfram.com/xid/0elsynzjvng3a88-i370h8


https://wolfram.com/xid/0elsynzjvng3a88-rrgm0t

Add a bond to turn hexane into cyclohexane:

https://wolfram.com/xid/0elsynzjvng3a88-lu2s5t


https://wolfram.com/xid/0elsynzjvng3a88-ji165q

Delete a bond to convert cyclohexane to hexane:

https://wolfram.com/xid/0elsynzjvng3a88-cqpj92


https://wolfram.com/xid/0elsynzjvng3a88-1c8yer

Replace all nitro groups in TNT with methyl groups:

https://wolfram.com/xid/0elsynzjvng3a88-svxd92

https://wolfram.com/xid/0elsynzjvng3a88-b568a2

Use "ReplaceSubstructureList" to replace one nitro group at a time:

https://wolfram.com/xid/0elsynzjvng3a88-snusl2

Scope (37)Survey of the scope of standard use cases
"AddAtom" (1)
"AddBond" (1)
"AssignStereochemistryFromCoordinates" (1)
Use a molecule's 3D coordinates to infer stereochemistry. First create a molecule with atoms, bonds and coordinates, but no defined stereochemistry:

https://wolfram.com/xid/0elsynzjvng3a88-1co4l8


https://wolfram.com/xid/0elsynzjvng3a88-4r01j8


https://wolfram.com/xid/0elsynzjvng3a88-76vtuy

"CanonicalizeAtomCoordinates" (1)
Import a structure from an "XYZ" file and canonicalize the 3D coordinates:

https://wolfram.com/xid/0elsynzjvng3a88-tjk2y3

After importing, compute the molecule's center of mass and principal axes:

https://wolfram.com/xid/0elsynzjvng3a88-fhsqtp

"CanonicalizeAtomCoordinates" will translate the molecule, move the center of mass to the origin and rotate to align the principal axes with the Cartesian axes:

https://wolfram.com/xid/0elsynzjvng3a88-wp79km

"ComputeAtomCoordinates" (2)
When a molecule is created from an identifier like a SMILES string or name, coordinates are not computed immediately:

https://wolfram.com/xid/0elsynzjvng3a88-bs10rd

Use "ComputeAtomCoordinates" to compute the coordinates and store them in the molecule expression:

https://wolfram.com/xid/0elsynzjvng3a88-gyzkie

Generate different conformations using the RandomSeeding option:

https://wolfram.com/xid/0elsynzjvng3a88-emvl2v

https://wolfram.com/xid/0elsynzjvng3a88-j69ine

The resulting molecules have different conformational energy:

https://wolfram.com/xid/0elsynzjvng3a88-0tfpdh

"ComputeAtomDiagramCoordinates" (2)
When a molecule is visualized in 2D using MoleculePlot, hydrogen atoms attached to carbon atoms are hidden by default. Only the hydroxyl hydrogen is shown by default in octanol:

https://wolfram.com/xid/0elsynzjvng3a88-lkvzud

"ComputeAtomDiagramCoordinates" will remove those hydrogens that are not shown, and make explicit those that are shown:

https://wolfram.com/xid/0elsynzjvng3a88-kya2l

The coordinates are now stored in the molecule expression:

https://wolfram.com/xid/0elsynzjvng3a88-3gwqb7

As there is only one hydrogen shown by default, the returned molecule has one explicit hydrogen:

https://wolfram.com/xid/0elsynzjvng3a88-ylb9kl

The coordinates match exactly those used in a molecule plot:

https://wolfram.com/xid/0elsynzjvng3a88-tq3jv3

Compute the atom diagram coordinates showing the default hydrogens, all hydrogens or none:

https://wolfram.com/xid/0elsynzjvng3a88-6xlod4

https://wolfram.com/xid/0elsynzjvng3a88-erkrgy

"DeleteAtom" (2)
Convert hexanol to hexane using "DeleteAtom":

https://wolfram.com/xid/0elsynzjvng3a88-e4f748


https://wolfram.com/xid/0elsynzjvng3a88-c3rsot


https://wolfram.com/xid/0elsynzjvng3a88-56a9aw

Find an Entity to match:

https://wolfram.com/xid/0elsynzjvng3a88-8hpwwf

When an atom is deleted, any hydrogens attached to it are also removed, and unfilled valences on heavy atoms are filled by implicit hydrogens. Use ValenceErrorHandling->False to disable this behavior and leave unpaired electrons instead:

https://wolfram.com/xid/0elsynzjvng3a88-4od0hl


https://wolfram.com/xid/0elsynzjvng3a88-0mg0wr

"DeleteBond" (2)
Delete an acyclic bond to create disconnected structures:

https://wolfram.com/xid/0elsynzjvng3a88-n5vorx


https://wolfram.com/xid/0elsynzjvng3a88-9onj58


https://wolfram.com/xid/0elsynzjvng3a88-52x3ox


https://wolfram.com/xid/0elsynzjvng3a88-i1mjqz


https://wolfram.com/xid/0elsynzjvng3a88-80a2xt

"EnergyMinimizeAtomCoordinates" (1)
Import a structure from an "XYZ" file and use the MMFF force field to minimize the energy:

https://wolfram.com/xid/0elsynzjvng3a88-r8euvw


https://wolfram.com/xid/0elsynzjvng3a88-c5nldc

Verify that the conformational energy has lowered:

https://wolfram.com/xid/0elsynzjvng3a88-itcsfo

Show the new structure together with the old:

https://wolfram.com/xid/0elsynzjvng3a88-tasoho

"GenerateConformers" (1)
It is often desirable to have a set of conformations for a molecule, for example, to sample a larger portion of the energy landscape. Generate 100 conformers for cyclohexane:

https://wolfram.com/xid/0elsynzjvng3a88-mi8hvg
The conformers will have a large energy spread:

https://wolfram.com/xid/0elsynzjvng3a88-u3p6tg

After minimizing the conformations using a force field, they fall into two groups energetically:

https://wolfram.com/xid/0elsynzjvng3a88-o5vsd5

These groupings correspond to the so-called "chair" and "twist-boat" conformations, which are global and local minima on the potential energy surface, respectively. Select one conformer from each group and plot in 3D:

https://wolfram.com/xid/0elsynzjvng3a88-nwgbe7

https://wolfram.com/xid/0elsynzjvng3a88-shpjgs

"Kekulize" (1)
By default, aromatic molecules have delocalized "Aromatic" bond types:

https://wolfram.com/xid/0elsynzjvng3a88-eup4ej


https://wolfram.com/xid/0elsynzjvng3a88-l6fyzl


https://wolfram.com/xid/0elsynzjvng3a88-ygatfe


https://wolfram.com/xid/0elsynzjvng3a88-dtvq7b

"MakeHydrogensImplicit" (1)
Remove all the hydrogen atoms from a molecule:

https://wolfram.com/xid/0elsynzjvng3a88-6pm4cu


https://wolfram.com/xid/0elsynzjvng3a88-es4pdg


https://wolfram.com/xid/0elsynzjvng3a88-sqb84x


https://wolfram.com/xid/0elsynzjvng3a88-25qj4v

"RemoveStereochemistry" (1)
Remove explicit stereo information from a molecule, leaving the chirality undefined:

https://wolfram.com/xid/0elsynzjvng3a88-jgd6pj


https://wolfram.com/xid/0elsynzjvng3a88-6iscmx


https://wolfram.com/xid/0elsynzjvng3a88-jbld07


https://wolfram.com/xid/0elsynzjvng3a88-ou5ctm

"RenumberAtoms" (1)
Change the ordering of atoms in a molecule:

https://wolfram.com/xid/0elsynzjvng3a88-wd5xy4


https://wolfram.com/xid/0elsynzjvng3a88-0a8cav


https://wolfram.com/xid/0elsynzjvng3a88-kia26r


https://wolfram.com/xid/0elsynzjvng3a88-z10ilp

"ReplaceAtom" (1)
"ReplaceSubstructure" (1)
"ReplaceSubstructureList" (1)
"SetAromaticity" (1)
Change localized single and double bonds to aromatic:

https://wolfram.com/xid/0elsynzjvng3a88-qmebg1

https://wolfram.com/xid/0elsynzjvng3a88-msqj6l


https://wolfram.com/xid/0elsynzjvng3a88-lf8xpl


https://wolfram.com/xid/0elsynzjvng3a88-db9euy

"SetAtomChirality" (1)
Convert D-glucose to D-mannose:

https://wolfram.com/xid/0elsynzjvng3a88-2bjkh5


https://wolfram.com/xid/0elsynzjvng3a88-20yo7j


https://wolfram.com/xid/0elsynzjvng3a88-400ang


https://wolfram.com/xid/0elsynzjvng3a88-jzo5sm


https://wolfram.com/xid/0elsynzjvng3a88-m8h6cq

"SetAtomPosition" (1)
"SetBondAngle" (3)
Set the angle between three atoms:

https://wolfram.com/xid/0elsynzjvng3a88-3h3fl9


https://wolfram.com/xid/0elsynzjvng3a88-ftwas0


https://wolfram.com/xid/0elsynzjvng3a88-o5k2xu


https://wolfram.com/xid/0elsynzjvng3a88-52tyaz


https://wolfram.com/xid/0elsynzjvng3a88-esibm

Angles cannot be set for nonbonded atoms:

https://wolfram.com/xid/0elsynzjvng3a88-5ovlw1


Bond angles in a ring cannot be set:

https://wolfram.com/xid/0elsynzjvng3a88-xgek8


"SetBondLength" (1)
Set the distance between two bonded atoms:

https://wolfram.com/xid/0elsynzjvng3a88-3xxba


https://wolfram.com/xid/0elsynzjvng3a88-x8c7ki


https://wolfram.com/xid/0elsynzjvng3a88-xet71


https://wolfram.com/xid/0elsynzjvng3a88-2polne


https://wolfram.com/xid/0elsynzjvng3a88-vlpnj5


"SetBondStereo" (1)
"SetBondType" (1)

https://wolfram.com/xid/0elsynzjvng3a88-0hzs3g


https://wolfram.com/xid/0elsynzjvng3a88-w6ez2q

"SetFormalCharge" (1)
"SetMassNumber" (1)
Label the C-2 of mevalonolactone with 13C by setting the mass number to 13:

https://wolfram.com/xid/0elsynzjvng3a88-2p9tgy


https://wolfram.com/xid/0elsynzjvng3a88-brc9k5

Use AtomList to find the labeled carbon:

https://wolfram.com/xid/0elsynzjvng3a88-yctm61

Label the 5-pro-S hydrogen of mevalonolactone with deuterium by setting the mass number to 2:

https://wolfram.com/xid/0elsynzjvng3a88-qafgs1


https://wolfram.com/xid/0elsynzjvng3a88-8kuwlw

"SetMetaInformation" (1)
Often, laboratories use a compound numbering system for samples and notebooks, and these identification numbers are used by chemists when writing internal reports, research papers and patents. Use the molecule's meta-information to store this kind of data.

https://wolfram.com/xid/0elsynzjvng3a88-1z39tt


https://wolfram.com/xid/0elsynzjvng3a88-o712rc

Store experimental data in this property:

https://wolfram.com/xid/0elsynzjvng3a88-ebcr40


https://wolfram.com/xid/0elsynzjvng3a88-gw4t4n

Use an empty association to remove the metadata:

https://wolfram.com/xid/0elsynzjvng3a88-lj8kqa


https://wolfram.com/xid/0elsynzjvng3a88-6tkywd

"SetTorsionAngle" (1)
Set the geometry of a molecule to a desired conformation, for example, for an internal hydrogen bond:

https://wolfram.com/xid/0elsynzjvng3a88-ufx4yz

https://wolfram.com/xid/0elsynzjvng3a88-7cs2bj

https://wolfram.com/xid/0elsynzjvng3a88-xqlsus


https://wolfram.com/xid/0elsynzjvng3a88-fh4sm0

"SetUnpairedElectronCount" (1)
"TransformAtomCoordinates" (2)
Create a copy of a molecule with the coordinates translated in space:

https://wolfram.com/xid/0elsynzjvng3a88-6w5p18

https://wolfram.com/xid/0elsynzjvng3a88-8haoi4


https://wolfram.com/xid/0elsynzjvng3a88-lnz7zo

Create a molecule's enantiomer using ReflectionTransform:

https://wolfram.com/xid/0elsynzjvng3a88-kwhznv


https://wolfram.com/xid/0elsynzjvng3a88-fzre86


https://wolfram.com/xid/0elsynzjvng3a88-4mqftz


https://wolfram.com/xid/0elsynzjvng3a88-ka90dd


https://wolfram.com/xid/0elsynzjvng3a88-qwelh0

Neat Examples (1)Surprising or curious use cases
Add distance constraints to the MMFF force field to find a conformation with a given distance between two atoms. First, create the base molecule:

https://wolfram.com/xid/0elsynzjvng3a88-waw4k6
Find the two atoms that are farthest away in the standard configuration:

https://wolfram.com/xid/0elsynzjvng3a88-pe1juy


https://wolfram.com/xid/0elsynzjvng3a88-m0zd4p

The default conformation has these two atoms 32 ångströms apart:

https://wolfram.com/xid/0elsynzjvng3a88-6vbsas


https://wolfram.com/xid/0elsynzjvng3a88-q1hfnf

Use "EnergyMinimizeAtomCoordinates" to find new conformations with specific separations for these atoms:

https://wolfram.com/xid/0elsynzjvng3a88-dnxdsv

Verify that the returned geometries match the requirement and get the force field energies:

https://wolfram.com/xid/0elsynzjvng3a88-3s7rzu


https://wolfram.com/xid/0elsynzjvng3a88-zqsy95

Wolfram Research (2019), MoleculeModify, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculeModify.html (updated 2020).
Text
Wolfram Research (2019), MoleculeModify, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculeModify.html (updated 2020).
Wolfram Research (2019), MoleculeModify, Wolfram Language function, https://reference.wolfram.com/language/ref/MoleculeModify.html (updated 2020).
CMS
Wolfram Language. 2019. "MoleculeModify." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/MoleculeModify.html.
Wolfram Language. 2019. "MoleculeModify." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/MoleculeModify.html.
APA
Wolfram Language. (2019). MoleculeModify. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MoleculeModify.html
Wolfram Language. (2019). MoleculeModify. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MoleculeModify.html
BibTeX
@misc{reference.wolfram_2025_moleculemodify, author="Wolfram Research", title="{MoleculeModify}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/MoleculeModify.html}", note=[Accessed: 11-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_moleculemodify, organization={Wolfram Research}, title={MoleculeModify}, year={2020}, url={https://reference.wolfram.com/language/ref/MoleculeModify.html}, note=[Accessed: 11-May-2025
]}