OEAddMolsΒΆ

OEAddMols(dst: OEMolBase, src: OEMolBase) -> amap: List[OEAtomBase], bmap: List[OEBondBase]
OEAddMols(dst: OEMolBase, src: OEMolBase, delim: str) -> amap: List[OEAtomBase], bmap: List[OEBondBase]

Adds the one molecule to another molecule.

dst
The destination molecule.
src
The molecule that will be added to the destination molecule.
delim
The delimiter used to concatenate the title of the two molecules. The empty string (e.g. "") is a valid argument, and causes a direct concatenation of the two titles. If None is passed as the argument, no concatenation of titles occurs. If not specified _ character will be used as to concatenate the titles together.
amap

Stores mappings between the atoms in the original src molecule and the newly created atoms in the dst molecule. The newly created atom that is corresponding to a source atom can be obtained by atom index lookup into the list.

srcatom = srcmol.GetAtom(OEHasAtomicNum(OEElemNo_N))
dstatom = amap[srcatom.GetIdx()]
bmap

Stores mappings between the bonds in the original src molecule and the newly created bonds in the dst molecule. The newly created bond that is corresponding to a source bond can be obtained by bond index lookup into the list.

srcbond = srcmol.GetBond(OEHasBondIdx(0))
dstbond = bmap[srcbond.GetIdx()]

Example

dstmol = OEGraphMol()
OESmilesToMol(dstmol, 'c1ccccc1 benzene')
srcmol = OEGraphMol()
OESmilesToMol(srcmol, 'c1cnccc1 pyridine')

amap, bmap = OEAddMols(dstmol, srcmol, "+")
print ("%s %s" % (OEMolToSmiles(dstmol), dstmol.GetTitle()))
print (" ".join(str(a) for a in amap))
print (" ".join(str(b) for b in bmap))

The above code snippet will generate the following output:

('c1ccccc1.c1ccncc1', 'benzene+pyridine')
 6 C  7 C  8 N  9 C 10 C 11 C
 6 (6C-11C)  7 (6C-7C)  8 (7C-8N)  9 (8N-9C) 10 (9C-10C) 11 (10C-11C)

Note

OEAddMols will not generate bonds between the molecules added.

See also