Re: [Rdkit-discuss] changing atomic charges with ReactionFromSmarts

2018-01-25 Thread Chris Earnshaw
Hi Jan

Your code doesn't change the charges because the reaction SMARTS doesn't
tell it to. If you say -

rxn_smarts = ['[N+:1]=[*:2]-[O-:3]>>[N+0:1]-[*:2]=[O+0:3]']

- the charges in the product are explicitly defined and you should get the
result you expect.

Best regards,
Chris

On 25 January 2018 at 10:18, Jan Halborg Jensen  wrote:

>
> The following code changes the bond order correctly but does not change
> the charges accordingly
>
> Any idea what I am doing wrong?
>
> Thanks, Jan
>
>
> def clean_charges(mol):
> rxn_smarts = ['[N+:1]=[*:2]-[O-:3]>>[N:1]-[*:2]=[O:3]']
>
> for smarts in rxn_smarts:
> rxn = AllChem.ReactionFromSmarts(smarts)
> ps = rxn.RunReactants((mol,))
> for x in ps:
> mol = x[0]
>
> #rdmolops.SanitizeMol(mol)
> return mol
>
> mol = Chem.MolFromSmiles("C[NH+]=C(C)[O-]")
>
> mol = clean_charges(mol)
> print Chem.MolToSmiles(mol)
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] changing atomic charges with ReactionFromSmarts

2018-01-25 Thread Jan Halborg Jensen

The following code changes the bond order correctly but does not change the 
charges accordingly

Any idea what I am doing wrong?

Thanks, Jan


def clean_charges(mol):
rxn_smarts = ['[N+:1]=[*:2]-[O-:3]>>[N:1]-[*:2]=[O:3]']

for smarts in rxn_smarts:
rxn = AllChem.ReactionFromSmarts(smarts)
ps = rxn.RunReactants((mol,))
for x in ps:
mol = x[0]

#rdmolops.SanitizeMol(mol)
return mol

mol = Chem.MolFromSmiles("C[NH+]=C(C)[O-]")

mol = clean_charges(mol)
print Chem.MolToSmiles(mol)
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss