Message Boards Message Boards

1
|
3554 Views
|
2 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Building a molecule as union of two existing molecules

I was expecting to be able to construct a molecule by creating one or more bonds between existing molecules. It's not obvious to me how I might go about doing that.

Is there a process by which I can create a union between smaller molecules to gradually build up more complex molecules?

POSTED BY: Lawrence Winkler
2 Replies

Thank you. Very helpful.

POSTED BY: Lawrence Winkler

This might be the simplest way to join two molecules, where you add the bond yourself graphically:

moleculeJoin[m1_, m2_] :=  MoleculeDraw @ 
  StringRiffle[MoleculeValue[{m1, m2}, "IsomericSMILES"], "."]

Here I could do something like

moleculeJoin[Molecule["n-octanol"], Molecule["cysteine"]]

enter image description here

Or you could do it programmatically via something like

moleculeJoin[m1_, m2_, newBonds:{___Bond}] := Module[
    {atoms, bonds, stereo, offset = AtomCount @ m1, mol},
    atoms = Join[AtomList @ m1, AtomList @ m2];
    bonds = Join[BondList @ m1,
        BondList[m2] /. n_Integer :> (n + offset)
    ];
    stereo = Join[m1 @ "StereochemistryElements",
        ReplaceAll[m2 @ "StereochemistryElements", n_Integer :> (n + offset)]
    ];
    mol = Molecule[atoms,
        bonds,
        If[Length[stereo] > 0,
            StereochemistryElements -> stereo, {}
        ]
    ];
    MoleculeModify[mol,
        {"AddBond", newBonds /. Bond[{a1_, a2_}, rest___] :> Bond[{a1, a2 + offset}, rest]}
    ]
]

Using this form, you could join octanol and cysteine creating a bond between atom 6 in octanol and atom 7 in cysteine using

moleculeJoin[Molecule["n-octanol"], Molecule["cysteine"], {Bond[{6, 7}, "Single"]}]

Hope that helps.

POSTED BY: Jason Biggs
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