Dear JP,

If you want to write a compressed SD file that includes molecular
properties, you can use a function like this:

#----------
def MolToSDFBlock(mol):
    res=[Chem.MolToMolBlock(mol)]
    for pn in mol.GetPropNames():
        pv = mol.GetProp(pn)
        res.append('>  <%s>\n%s\n'%(pn,pv))
    res.append('$$$$\n')
    return '\n'.join(res)

#----------
A little demonstration of using it:

>>> ms = [x for x in Chem.SDMolSupplier('hERG_inhibition_dataset.sdf') if x is 
>>> not None]
>>> from cStringIO import StringIO
>>> sio = StringIO()
>>> for m in ms: sio.write(util.MolToSDFBlock(m))
...
>>> suppl2 = Chem.SDMolSupplier()
>>> suppl2.SetData(txt)
>>> ms2 = [x for x in suppl2]
>>> len(ms)==len(ms2)
True

I hope this helps,
-greg

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to