5
$\begingroup$

MoleculeModifyis a powerful function to alter a chemical structure. However, it accepts only one modification, there is no (direct) way to give a list of consecutive modifications. For instance, in order to change all bonds to bond type "Single", you have to use e.g. Fold:

MakeSimple[mol_] := 
 Module[{kekMol = MoleculeModify[mol, "Kekulize"]},
  Fold[MoleculeModify[#1, {"SetBondType", #2 -> "Single"}] &, kekMol, 
   Values /@ 
    FindMoleculeSubstructure[kekMol, Bond[_, "Double"], All]]]

Is this statement true, or do I miss something?

$\endgroup$

1 Answer 1

6
$\begingroup$

I've tested the following in 13.2 so it works going back that far. This is a documentation bug that I never specifically wrote that it can modify a list of bonds:

In[1]:= MoleculeName@
 MoleculeModify[
  m = Molecule["benzene"], {"SetBondType", 
   Thread[BondList[m] -> "Single"]}]

Out[1]= "cyclohexane"
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.