Hi there,

This must be really easy -- but anything I am trying is failing and I am
losing my mind.  I want to add a charge (+ / -) to an atom and add or
delete a connected H accordingly.

I thought an easy way to do this was to remove all Hs from the molecule
(removeHs), add a charge (SetFormalCharge), and re-add all Hs (AddHs).
 This doesn't work (the sanitization check fails in AddHs, incorrect
valence - which I understand) - what is the best way to do this?

Also,

>>> m = Chem.MolFromSmiles('C(=O)O')
>>> m.Debug()
Atoms:
0 6 C chg: 0  deg: 2 exp: 3 imp: 1 hyb: 3 arom?: 0 chi: 0
 1 8 O chg: 0  deg: 1 exp: 2 imp: 0 hyb: 3 arom?: 0 chi: 0
2 8 O chg: 0  deg: 1 exp: 1 imp: 1 hyb: 3 arom?: 0 chi: 0
Bonds:
0 0->1 order: 2 conj?: 1 aromatic?: 0
1 0->2 order: 1 conj?: 1 aromatic?: 0
>>> m_noHs = Chem.RemoveHs(m)
>>> m_noHs.Debug()
Atoms:
0 6 C chg: 0  deg: 2 exp: 3 imp: 1 hyb: 3 arom?: 0 chi: 0
1 8 O chg: 0  deg: 1 exp: 2 imp: 0 hyb: 3 arom?: 0 chi: 0
 2 8 O chg: 0  deg: 1 exp: 1 imp: 1 hyb: 3 arom?: 0 chi: 0
Bonds:
0 0->1 order: 2 conj?: 1 aromatic?: 0
 1 0->2 order: 1 conj?: 1 aromatic?: 0

>>> m_noHs.GetAtomWithIdx(2).GetNumExplicitHs()
0
>>> m_noHs.GetAtomWithIdx(2).GetNumImplicitHs()
1

Why is there still an implicit H after I "removed" them?

I have tried to use ReplaceSubstructs() for this (a bit of an overkill) but
I then lose the 3D information of the original atom.

Many Thanks... and sorry for the repeated spamming :((((

-
Jean-Paul Ebejer
Early Stage Researcher
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to