SQL functions for reaction transformations

SMIRKS is an extension of SMILES and SMARTS that specifies how one Smiles can be transformed into another Smiles, as if a chemical reaction were being carried out.

Function SQL example
xform Select xform('c1ccccc1C[N+](=O)[O-]', '[N+:1]([O-:2])=[O:3]>>[N+0:1](=[O+0:2])=[O:3]');

Select xform('CC=CO', '[C:1]=[C:2][OH1:3]>>[H][C:1][C:2]=[Oh0:3]');

Update nci.structure Set smiles=xform(smiles, '[N+:1]([O-:2])=[O:3]>>[N+0:1](=[O+0:2])=[O:3]')
Where matches(smiles, '[N+](=O)[O-]');
xform Select xform(ARRAY['CCNC', 'CC(=O)Cl'], '[H:99][N:1][C:5].[C:2](=[O:4])[Cl:3]>>[C:5][N:1][C:2]=[O:4]');

Select xform(ARRAY[amine.smiles, acid_chloride.smiles],
From amine, acid_chloride;
All the above functions are installed into a SCHEMA named gnova. They can be accessed as, for example gnova.xform. Or, you can set your search_path to include the SCHEMA gnova and access them by their unqualified names, for example xform.

xform(Smiles text, Smirks text) returns text

This function takes a Smiles and transforms it according to the Smirks. This can be used for "correcting" Smiles, for example to change charge-separated nitro groups. There must be only one reactant in the Smirks, although there may be multiple products expressed as dot-separated Smiles. For reactions involving multiple reactants, there is another form of the xform function described below.

xform(Smiles text[], Smirks text) returns text[]

This function takes an array of Smiles. Each element of the array is a reactant in the input Smirks. The output is an array of product Smiles. There must be exactly as many elements in the input array of Smiles as there are reactants in the input Smirks.


SMIRKS is a very powerful tool, but can be very exasperating to get exactly right. Here are a few useful SMIRKS that may help you. If you have any SMIRKS you wish to share, please contact us.

[N+:1]([O-:2])=[O:3]>>[N+0:1](=[O+0:2])=[O:3] charge-separated nitro
[C:1]=[C:2][NH1:3]>>[H][C:1][C:2]=[Nh0:3] imine enamine tautomers
[H:99][N:1][C:5].[C:2](=[O:4])[Cl:3]>>[C:5][N:1][C:2]=[O:4] amine+acid chloride reaction