On Mon, Apr 14, 2008 at 9:12 PM, Noel O'Boyle <[email protected]> wrote:
> If I found a bug earlier, it was completely by accident. The following
> though I think is also a bug. I find that I can invert the
> stereocenter by adding and removing Hs.
>
> >>> mol = rdk.readstring("smi", "C[C@@H](O)(Cl)c1ccccc1")
> >>> mol.write("iso")
> 'C[C@@H](O)(Cl)c1ccccc1'
> >>> mol.addh()
> >>> mol.write("iso")
> '[h]...@](Cl)(C([H])([H])[H])([H])c1c([H])c([H])c([H])c([H])c1[H]'
> >>> mol.removeh()
> >>> mol.write("iso")
> 'c...@h](O)(Cl)c1ccccc1'
>
> Can you tell whether the problem is when I add the Hs, or when I
> remove them? I might be able to workaround if the adding is working
> okay.
As discussed in your later message, this molecule has a 5-coordinate
C, so it probably shouldn't have the @ in the output SMILES at all.
(Sarcasm doesn't work in email: that "probably" is a joke, it
definitely shouldn't be in there; that's another nice bug).
I'm prepared to believe that there could be a bug that causes
inversion of chirality when Hs are added and removed (I wouldn't be
overly surprised), but it definitely doesn't always happen, as this
case demonstrates:
[18]>>> m = Chem.MolFromSmiles('o...@h](F)Cl')
[19]>>> Chem.MolToSmiles(m,1)
Out[19] 'o...@h](F)Cl'
[20]>>> m2=Chem.AddHs(m)
[21]>>> Chem.MolToSmiles(m2)
Out[21] '[H]OC(F)(Cl)[H]'
[22]>>> Chem.MolToSmiles(m2,True)
Out[22] '[h]...@](F)(Cl)[H]'
[23]>>> m3 = Chem.RemoveHs(m2)
[24]>>> Chem.MolToSmiles(m3,True)
Out[24] 'o...@h](F)Cl'
After playing around a bit with a model, I think this is also ok:
[25]>>> m = Chem.MolFromSmiles('C[C@@H](O)Cl')
[27]>>> Chem.MolToSmiles(m,True)
Out[27] 'C[C@@H](O)Cl'
[28]>>> m2 = Chem.AddHs(m)
[30]>>> Chem.MolToSmiles(m2,True)
Out[30] '[H]O[C@@](Cl)(C([H])([H])[H])[H]'
[31]>>> m3 = Chem.RemoveHs(m2)
[32]>>> Chem.MolToSmiles(m3,True)
Out[32] 'C[C@@H](O)Cl'
-greg