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

On 25 April 2017 at 22:26, xh s <sxh....@gmail.com> wrote:
> 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
>
>
> ------------------------------------------------------------------------------
> 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
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
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
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to