connorcoley / rdchiral

Wrapper for RDKit's RunReactants to improve stereochemistry handling
MIT License
151 stars 50 forks source link

Multiple reactants #34

Closed feiranl closed 2 years ago

feiranl commented 2 years ago

Hi,

My template rule has two reactants. May I know how can I input two reactants in the product_smiles = rdchiralRunText(rule, reactant_smiles). For example, the smiles for my reactants are O=C([O-])CCC(=O)C(=O)[O-] and [NH4+].

connorcoley commented 2 years ago

RDChiral is mostly meant for retrosynthetic reactions starting from a single product (based on the way it handled ambiguity). If you want to repurpose it for a template with multiple inputs, you should just use a concatenated SMILES O=C([O-])CCC(=O)C(=O)[O-].[NH4+]

feiranl commented 2 years ago

Hi, Thanks for the reply!

If I use the concatenated SMILES as the input, there would reports an error ValueError: ChemicalParserException: Number of reactants provided does not match number of reactant templates.

The code I am using is:

rule = '[C:1]-[C;H0;D3;+0:2](-[O-;H0;D1:5])=[O;D1;H0:4].[NH4+;D0:3]>>[C:1]-[C;H0;D3;+0:2](-[NH2;D1;+0:3])=[O;D1;H0:4].[OH2;D0;+0:5]'
product_smiles = rdchiralRunText(rule, 'O=C([O-])CCC(=O)C(=O)[O-].[NH4+]')
connorcoley commented 2 years ago

Your rule should be written as a pseudo-unimolecular reaction by grouping the two SMARTS fragments. See if this works:

rule = '([C:1]-[C;H0;D3;+0:2](-[O-;H0;D1:5])=[O;D1;H0:4].[NH4+;D0:3])>>[C:1]-[C;H0;D3;+0:2](-[NH2;D1;+0:3])=[O;D1;H0:4].[OH2;D0;+0:5]'
feiranl commented 2 years ago

Thanks!