Discussion:
[Open Babel] change charge of a atom in a OBMol
xh s
2017-04-25 21:26:07 UTC
Permalink
Hi,

I'm just wondering what's the best way to change the charge of certain atom
in a OBMol.

For example, I want to find a way to represent the reaction [Cl-] + CH3OH
---> [OH-] + CH3Cl. Once I've converted the SMILES [Cl-].CO to a OBMol
through OBConversion, what's the best way to transform it to the products
and also keep track of everything going on in the molecule, such as bonds,
formal charges and all the bookkeeping stuff?

Here's how I do it now (pseudo code):

mol.DeleteBond(C - O);
mol.NewBond(C - Cl);

However this leave me with OH + [CH3Cl]-, i.e. the charge is on the wrong
fragment. Is there a way to fix this? or I should've done it a completely
different way?



Thanks in advance for any help!

Xianghai
Noel O'Boyle
2017-04-27 15:34:14 UTC
Permalink
Open Babel looks after the hydrogens, but the charges don't change no
matter how many bonds you make or break. So you need to increment or
decrement the charges yourself via OBAtom::Get/SetFormalCharge.

I note that there may be a way to do this automatically with reaction
smiles or whatever we call it, but I've no experience with this.

- Noel
Post by xh s
Hi,
I'm just wondering what's the best way to change the charge of certain atom
in a OBMol.
For example, I want to find a way to represent the reaction [Cl-] + CH3OH
---> [OH-] + CH3Cl. Once I've converted the SMILES [Cl-].CO to a OBMol
through OBConversion, what's the best way to transform it to the products
and also keep track of everything going on in the molecule, such as bonds,
formal charges and all the bookkeeping stuff?
mol.DeleteBond(C - O);
mol.NewBond(C - Cl);
However this leave me with OH + [CH3Cl]-, i.e. the charge is on the wrong
fragment. Is there a way to fix this? or I should've done it a completely
different way?
Thanks in advance for any help!
Xianghai
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenBabel-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Loading...