Message Boards Message Boards

Interactively select atoms in a molecule

Posted 10 months ago

POSTED BY: Jason Biggs
3 Replies

This is very cool. Can you please expand on the example? What would one use these selected atoms - or molecule patterns - for?

POSTED BY: Tamas Simon

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

In[30]:= MoleculeName[
 MoleculeModify[
  Molecule["2,4-dichlorotoluene"], {"DeleteAtom", selection}]]

Out[30]= "1-chloro-4-methylbenzene"
POSTED BY: Jason Biggs

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract