OECopyMol

void OECopyMol(OEMolBase &dst, const OEMolBase &src,
               OEAtomBase **atommap=0, OEBondBase **bondmap=0)
void OECopyMol(OEMCMolBase &dst, const OEMCMolBase &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.

from openeye import oechem

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

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

atommap = oechem.OEAtomArray(src.GetMaxAtomIdx())

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

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