from rdkit import Chem
from rdkit.Chem import rdChemReactions
from rdkit.Chem import AllChem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
IPythonConsole.ipython_useSVG=True
intra_rxn = AllChem.ReactionFromSmarts('([C:1][C:2](=[O:6])[O:3].[N:4][C:5])>>[C:1][C:2](=[O:6])[N:4][C:5]')
inter_rxn = AllChem.ReactionFromSmarts('[C:1][C:2](=[O:6])[O:3].[N:4][C:5]>>[C:1][C:2](=[O:6])[N:4][C:5]')
intra_rxn
inter_rxn
acid = Chem.MolFromSmiles('CC(=O)O')
amine = Chem.MolFromSmiles('NC')
aminoacid = Chem.MolFromSmiles('N(C)CCC(O)CC(=O)O')
combmol = Chem.MolFromSmiles("CC(=O)O.N1CCC(C)1")
inter_rxn.RunReactants([acid, amine])[0][0]
ps = intra_rxn.RunReactants([aminoacid])
Draw.MolsToGridImage([ aminoacid, ps[0][0]])
# Intra reaction can not represent with inter molecular reactoin query
inter_rxn.RunReactant(aminoacid,0)[0][0]
#inra moleclar query works fine
intra_rxn.RunReactant(aminoacid,0)[0][0]
# paired molecular object also works but get two molecules as one object
intra_rxn.RunReactant(combmol,0)[0][0]
def sepMol(mol):
smi_list = Chem.MolToSmiles(mol).split('.')
mols = [ Chem.MolFromSmiles(smi) for smi in smi_list]
return mols
ms = sepMol(combmol)
print(len(ms))
ms.append(intra_rxn.RunReactant(combmol,0)[0][0])
2
Draw.MolsToGridImage(ms, molsPerRow=1)