What would one use these selected atoms - or molecule patterns - for?
Basically anytime you want to modify a molecule you have to refer to atoms by their atom index - their position in the atoms list. In this example from the MoleculeModify
documentation the goal is to remove a hydroxyl group from a molecule, turning hexanol into hexane. To call the "DeleteAtom"
function you need to know which atom to delete. You can find it programmatically with FindMoleculeSubstructure
or interactively with AtomSelector
.
There are also cases where there are multiple atoms that would match a pattern and you only want the position of one of them. Take the two nonequivalent chlorine atoms in 2,4-dichlorotoluene, and delete just one of them:
AtomSelector[Molecule["2,4-dichlorotoluene"], Dynamic[selection]]
![enter image description here](https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2023-08-21at10.22.15AM.png&userId=987067)
In[30]:= MoleculeName[
MoleculeModify[
Molecule["2,4-dichlorotoluene"], {"DeleteAtom", selection}]]
Out[30]= "1-chloro-4-methylbenzene"