Menu

#910 OBStereoFacade do not update after AddHydrogens

2.3.x
open
nobody
1
2014-01-27
2014-01-25
No

I use python binding, executing the following code:

mol = openbabel.OBMol()
conversion = openbabel.OBConversion()
conversion.SetInFormat('sdf')
conversion.ReadFile(mol, 'at-406-s2754.SDF')
# <http://file.selleck.cn/downloads/product-sdf/at-406-s2754.SDF>
mol.AddHydrogens()
stereofacade = openbabel.OBStereoFacade(mol)
for atom in openbabel.OBMolAtomIter(mol):
    atomid = atom.GetId() # unsigned long atomId (0-based)
    if not stereofacade.HasTetrahedralStereo(atomid):
        continue
    tetrahedralstereo = stereofacade.GetTetrahedralStereo(atomid)
    config = tetrahedralstereo.GetConfig() 
    print '!!Config:', atomid, config.view, config.winding, \
        config.center, config.refs, config.from_or_towards, \
        config.specified

The output:

!!Config: 16 1 1 16 (14L, 17L, 20L) 4294967294 True
!!Config: 19 1 1 19 (21L, 20L, 18L) 4294967294 True
!!Config: 25 1 1 25 (27L, 26L, 24L) 4294967294 True
!!Config: 29 1 1 29 (38L, 28L, 37L) 4294967294 True

I think the value 4294967294 for config.from_or_towards is something like -1 or NaN translated from C++. However, from atom.GetId() I know that all atoms, including the new added H, have a id, from 1 to 83. The value 4294967294 may disturb comparison of config objects (not shown). And further, if I save the mol with H and load the saved file, config.from_or_towards is nolonger 4294967294 but a meaningful integer.

I think that is a bug, steming from the lazy updating of OBStereoFacade, which should update automatically when running AddHydrogens.

Discussion

  • Noel O'Boyle

    Noel O'Boyle - 2014-01-25

    Does this occur with the latest OB release?

     
  • Alexander Huang

    Alexander Huang - 2014-01-27

    The version installed by Debian should be 2.3.2. apt-cache show libopenbabel4 shows:

    Package: libopenbabel4
    Source: openbabel (2.3.2+dfsg-1)
    Version: 2.3.2+dfsg-1+b1
    Installed-Size: 11264
    Maintainer: Debichem Team debichem-devel@lists.alioth.debian.org
    Architecture: amd64