OECopyMolΒΆ

void OECopyMol(OEMolBase &dst, const OEMolBase &src,
               OEAtomBase **atommap=0, OEBondBase **bondmap=0)

Create a copy of the molecule src into the molecule dst. The mapping of the atoms and bonds between the two copies of the molecule can be retrieved by passing in arrays to the atommap and bondmap arguments. The size of the atommap array should be large enough to store src.GetMaxAtomIdx() atoms. The size of the bondmap array should be large enough to store src.GetMaxBondIdx() atoms. The new atom or bond in dst will be stored at the src atom or bond’s OEAtomBase.GetIdx location in the array.

The following code demonstrates how to access the atom associations output by the OECopyMol function.

#!/usr/bin/env python
from __future__ import print_function
from openeye.oechem import *

src = OEGraphMol()
OESmilesToMol(src, "c1ccccc1")

# make holes in the molecule index space and juggle things around
OEAddExplicitHydrogens(src)
OESuppressHydrogens(src)
OEAddExplicitHydrogens(src)
OECanonicalOrderAtoms(src)

atommap = OEAtomArray(src.GetMaxAtomIdx())

dst = OEGraphMol()
OECopyMol(dst, src, atommap)

for srcatom in src.GetAtoms():
    dstatom = atommap[srcatom.GetIdx()]
    print(srcatom.GetIdx(), " -> ", dstatom.GetIdx())