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.

#include <openeye.h>
#include <vector>
#include <oesystem.h>
#include <oechem.h>

using namespace std;
using namespace OESystem;
using namespace OEChem;

int main()
{
  OEGraphMol src;
  OESmilesToMol(src, "c1ccccc1");

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

  vector<OEAtomBase *> atommap(src.GetMaxAtomIdx());

  OEGraphMol dst;
  OECopyMol(dst, src, &atommap[0]);

  for (OEIter<const OEAtomBase> srcatom = src.GetAtoms(); srcatom; ++srcatom)
  {
    const OEAtomBase *dstatom = atommap[srcatom->GetIdx()];
    cout << srcatom->GetIdx() << " -> " << dstatom->GetIdx() << endl;
  }

  return 0;
}