rexgen_direct icon indicating copy to clipboard operation
rexgen_direct copied to clipboard

How can we get the bond breaking and forming information (numbers at the end of each reaction) from our own smiles datesets?

Open Frank-LIU-520 opened this issue 5 years ago • 21 comments

If we only have the reaction 'CH2:15[Mg+:19].[CH2:20]1[O:21][CH2:22][CH2:23][CH2:24]1.[Cl-:14].[OH:1][c:2]1[n:3][cH:4]c:5[cH:12][cH:13]1>>[OH:1][c:2]1[n:3][cH:4]c:5[cH:12][cH:13]1 ' , how can we get the bond changing information 6-8-0.0;15-6-1.0;15-19-0.0 at the end of reaction in datesets. That's important for us to train the neural networks. Can you show us your codes and post them to your rexgen_direct issue? Much thanks.

Frank-LIU-520 avatar Mar 06 '19 05:03 Frank-LIU-520

Hi @Mario-Liu ,

You only need the atom-mapped reaction SMILES as input (note: what you've written isn't valid SMILES due to missing square brackets). The script at rexgen_direct/scripts/prep_data.py takes care of preparing the bond changing information. This is the difference between the example data files that do or do not contain .proc

connorcoley avatar Mar 06 '19 15:03 connorcoley

Much thanks for your reply.Here is another question: What if part of the molecules like C1(C)C=CC=CC=1 and C1(P(=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])(C2C=CC=CC=2)C2C=CC=CC=2)C=CC=CC=1 does not have the mapped atom numbers in your own reaction like C1(C)C=CC=CC=1.[CH2:1]([O:8][C:9]1[CH:10]=[C:11]([CH:12]=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])[CH:14]=[C:15]([O:17][CH3:18])[CH:16]=1)[C:2]1[CH:7]=[CH:6][CH:5]=[CH:4][CH:3]=1>>[CH2:1]([O:8][C:9]1[CH:10]=[C:11]([CH:14]=[C:15]([O:17][CH3:18])[CH:16]=1)[CH:12]=O)[C:2]1[CH:7]=[CH:6][CH:5]=[CH:4][CH:3]=1.C1(P(=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])(C2C=CC=CC=2)C2C=CC=CC=2)C=CC=CC=1 ? When I run rexgen_direct/scripts/prep_data.py ,it gets

 line 22, in get_changed_bonds
    [bond.GetBeginAtom().GetProp('molAtomMapNumber'),
KeyError: 'molAtomMapNumber'

How can I solve this?

Frank-LIU-520 avatar Mar 07 '19 17:03 Frank-LIU-520

You'll need to complete the atom mapping on the product side for this code; that is a consequence of using this graph-based representation where we enforce atom conservation and thus need to understand the atom-to-atom correspondence. Any reactant leaving groups can be assigned dummy atom map numbers that do not appear in the products.

There are a number of ways to assign atom mapping. The USPTO dataset was prepared (not by me) using Indigo. This is an open source toolkit and should be straightforward to apply as a pre-processing step

connorcoley avatar Mar 07 '19 18:03 connorcoley

How can I enforce atom conservation?

WYejian avatar Jul 18 '20 15:07 WYejian

非常感谢您的回复。这里有另一个问题 :如果像分子的一部分没有映射的原子数在你自己的反应像呢?

当我跑的时候,它得到C1(C)C=CC=CC=1 and C1(P(=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])(C2C=CC=CC=2)C2C=CC=CC=2)C=CC=CC=1``C1(C)C=CC=CC=1.[CH2:1]([O:8][C:9]1[CH:10]=[C:11]([CH:12]=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])[CH:14]=[C:15]([O:17][CH3:18])[CH:16]=1)[C:2]1[CH:7]=[CH:6][CH:5]=[CH:4][CH:3]=1>>[CH2:1]([O:8][C:9]1[CH:10]=[C:11]([CH:14]=[C:15]([O:17][CH3:18])[CH:16]=1)[CH:12]=O)[C:2]1[CH:7]=[CH:6][CH:5]=[CH:4][CH:3]=1.C1(P(=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])(C2C=CC=CC=2)C2C=CC=CC=2)C=CC=CC=1``rexgen_direct/scripts/prep_data.py

 line 22, in get_changed_bonds
    [bond.GetBeginAtom().GetProp('molAtomMapNumber'),
KeyError: 'molAtomMapNumber'

我怎样才能解决这个问题?

Did you solve this problem?

WYejian avatar Jul 19 '20 06:07 WYejian

Hi @WYejian , completing the atom mapping so that all product atoms are mapped will solve this problem

connorcoley avatar Jul 19 '20 16:07 connorcoley

Hi @WYejian , completing the atom mapping so that all product atoms are mapped will solve this problem

Thanks for your reply. I want to know how you numbered the unmapped leaving group in the reaction.

WYejian avatar Jul 20 '20 01:07 WYejian

Leaving groups in the reactants can have arbitrary (but unique) atom map numbers that do not appear in the product

connorcoley avatar Jul 20 '20 01:07 connorcoley

Leaving groups in the reactants can have arbitrary (but unique) atom map numbers that do not appear in the product

Can indigo be used to number the atoms of the leaving group?

WYejian avatar Jul 20 '20 01:07 WYejian

Leaving groups in the reactants can have arbitrary (but unique) atom map numbers that do not appear in the product

Can indigo be used to number the atoms of the leaving group?

Yes, and there are other papers and algrithoms to do this. Check it with google.

Frank-LIU-520 avatar Jul 20 '20 01:07 Frank-LIU-520

Can i add your wechat? This is my WeChat ID:1527808346

发自我的iPhone

------------------ Original ------------------ From: Mario-Liu <[email protected]> Date: 周一,7月 20,2020 09:28 To: connorcoley/rexgen_direct <[email protected]> Cc: WYejian <[email protected]>, Mention <[email protected]> Subject: Re: [connorcoley/rexgen_direct] How can we get the bond breaking and forming information (numbers at the end of each reaction) from our own smiles datesets? (#4)

Leaving groups in the reactants can have arbitrary (but unique) atom map numbers that do not appear in the product

Can indigo be used to number the atoms of the leaving group?

Yes, and there are other papers and algrithoms to do this. Check it with google.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

WYejian avatar Jul 20 '20 05:07 WYejian

Much thanks for your reply.Here is another question: What if part of the molecules like does not have the mapped atom numbers in your own reaction like ? When I run ,it getsC1(C)C=CC=CC=1 and C1(P(=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])(C2C=CC=CC=2)C2C=CC=CC=2)C=CC=CC=1``C1(C)C=CC=CC=1.[CH2:1]([O:8][C:9]1[CH:10]=[C:11]([CH:12]=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])[CH:14]=[C:15]([O:17][CH3:18])[CH:16]=1)[C:2]1[CH:7]=[CH:6][CH:5]=[CH:4][CH:3]=1>>[CH2:1]([O:8][C:9]1[CH:10]=[C:11]([CH:14]=[C:15]([O:17][CH3:18])[CH:16]=1)[CH:12]=O)[C:2]1[CH:7]=[CH:6][CH:5]=[CH:4][CH:3]=1.C1(P(=[CH:38][C:39]([O:41][CH2:42][CH3:43])=[O:40])(C2C=CC=CC=2)C2C=CC=CC=2)C=CC=CC=1``rexgen_direct/scripts/prep_data.py

 line 22, in get_changed_bonds
    [bond.GetBeginAtom().GetProp('molAtomMapNumber'),
KeyError: 'molAtomMapNumber'

Have you solved this problem? I still can't solve it, can you help me?

liuyifei11 avatar Jul 23 '20 02:07 liuyifei11

You'll need to complete the atom mapping on the product side for this code; that is a consequence of using this graph-based representation where we enforce atom conservation and thus need to understand the atom-to-atom correspondence. Any reactant leaving groups can be assigned dummy atom map numbers that do not appear in the products.

There are a number of ways to assign atom mapping. The USPTO dataset was prepared (not by me) using Indigo. This is an open source toolkit and should be straightforward to apply as a pre-processing step

I still don't know how to number the unmapped atoms, do you have any method?

liuyifei11 avatar Jul 23 '20 02:07 liuyifei11

See "Reaction Atom-to-Atom Mapping" in Indigo

connorcoley avatar Jul 23 '20 13:07 connorcoley

You'll need to complete the atom mapping on the product side for this code; that is a consequence of using this graph-based representation where we enforce atom conservation and thus need to understand the atom-to-atom correspondence. Any reactant leaving groups can be assigned dummy atom map numbers that do not appear in the products. There are a number of ways to assign atom mapping. The USPTO dataset was prepared (not by me) using Indigo. This is an open source toolkit and should be straightforward to apply as a pre-processing step

I still don't know how to number the unmapped atoms, do you have any method?

There are many other algorithoms to define atom mapping. Indigo is not the best choice already. see "ReactionMap: An Efficient Atom-Mapping Algorithm for Chemical Reactions" in JCIM for clear comparison

Frank-LIU-520 avatar Jul 23 '20 13:07 Frank-LIU-520

I would like to ask whether the graph convolutional neural networks can be used to predict compounds with chirality?

liuyifei11 avatar Aug 05 '20 05:08 liuyifei11

Currently, the code is designed to work only with achiral compounds. Some additional comments:

  • Chirality can be included as an atom-level feature, although one can debate how meaningful this representation is
  • The function that applies predicted graph edits could be changed to ensure that tetrahedral chirality is preserved upon reacting
  • Handling changes in chirality (introduction or inversion of a tetrahedral center or introduction of cis/trans isomerism) would require allowing an additional type of "graph edit" to be predicted

connorcoley avatar Aug 05 '20 13:08 connorcoley

Thank you for your reply

On 08/05/2020 21:50, Connor Coley wrote:

Currently, the code is designed to work only with achiral compounds. Some additional comments:

Chirality can be included as an atom-level feature, although one can debate how meaningful this representation is The function that applies predicted graph edits could be changed to ensure that tetrahedral chirality is preserved upon reacting Handling changes in chirality (introduction or inversion of a tetrahedral center or introduction of cis/trans isomerism) would require allowing an additional type of "graph edit" to be predicted

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

liuyifei11 avatar Aug 05 '20 13:08 liuyifei11

Hi I have tried Indigo for atom mapping and I still get the error in preparing data step:

File "", line 28, in get_changed_bonds [bond.GetBeginAtom().GetProp('molAtomMapNumber'),

KeyError: 'molAtomMapNumber'

Here is my code for preparing the atom mapping in indigo: rxn = indigo.createReaction(); rxn.addReactant(mol1); rxn.addProduct(mol2); rxn.automap("discard"); result = rxn.smiles()

Here is my input reaction:'C(=O)(N([H])[H])N([H])C(=O)O[H]>>C(=O)=O'

And here is the output of indigo: 'C(=[O:4])(N([H])[H])N([H])C:5O[H]>>C:5=[O:4]'

Can you give me some idea about how to fix this or what alternative software I can use to solve this? Thanks a lot! @Mario-Liu @liuyifei11 @wengong-jin @connorcoley @WYejian

crazythor123 avatar Aug 25 '20 18:08 crazythor123

These tools aren't meant to work with explicit hydrogen atoms in your SMILES strings.

Are you sure that's the direct output of Indigo? That isn't a well-formed SMILES string at all. Ignoring the atom mapping, neither the reactant side or the product side are valid SMILES.

connorcoley avatar Aug 26 '20 14:08 connorcoley

Thanks for your reply. I just recheck Indigo and I think I forget to choose canonicalSmiles. After choose that I get: '[O:1]=C:3[OH:7]>>[O:1]=[C:3]=[O:2]' Which I think will be a valid SMILE string for the software input. Thanks again for the quick response!

crazythor123 avatar Aug 27 '20 11:08 crazythor123