5. Transformation rules extraction
2019, 2020 Dr. Ramil Nugmanov;
2019 Dr. Timur Madzhidov; Ravil Mukhametgaleev
Installation instructions of CGRtools package information and tutorial’s files see on https://github.com/cimm-kzn/CGRtools
NOTE: Tutorial should be performed sequentially from the start. Random cell running will lead to unexpected results.
[1]:
import pkg_resources
if pkg_resources.get_distribution('CGRtools').version.split('.')[:2] != ['4', '1']:
print('WARNING. Tutorial was tested on 4.1 version of CGRtools')
else:
print('Welcome!')
Welcome!
[2]:
# load data for tutorial
from pickle import load
from traceback import format_exc
with open('molecules.dat', 'rb') as f:
molecules = load(f) # list of MoleculeContainer objects
with open('reactions.dat', 'rb') as f:
reactions = load(f) # list of ReactionContainer objects
m3 = molecules[2]
m7 = m3.copy()
m7.standardize()
m7.thiele()
m8 = m7.substructure([4, 5, 6, 7, 8, 9])
cgr1 = m7 ^ m8
from CGRtools.containers import *
CGRtools can be used to generate molecules and reactions based on a given transformation rule.
How to extract transformation rule
[3]:
cgr1
[3]:
[4]:
cgr1.center_atoms # list of atom numbers of reaction center. If several centers exist they will also be added to this list.
[4]:
(10, 4, 13, 7)
[5]:
cgr1.center_bonds # list of dynamic bonds as tuples of adjacent atom numbers
[5]:
((10, 4), (13, 7))
[6]:
cgr1.centers_list # list of lists of atom numbers belonging to each reaction center.
# Distant reaction centers will be split into separate lists
[6]:
((10, 4), (13, 7))
[7]:
rc1 = cgr1.substructure([13, 7], as_query=True) # get reaction center from CGR and transform reaction into query
print(rc1)
rc1
[C;a>a3>2;][->.][O;s>s1>0;]
[7]:
rc1 is phenol reduction, phenol is transformed into unsubstituted benzene