Dear JP,

On Tue, Aug 2, 2011 at 11:36 AM, JP <[email protected]> wrote:
> I would just like to re-iterate how useful and nice (and expected
> behaviour)  it would be if when I have a mol instance with properties
> (which I painstakingly computed) and the .write() method in SDWriter
> actually writes them to file.
> I know there is a SetProps method ... but why do I have to do this
> everytime?  Can it be a default? Or an optional parameter in the
> SDWriter constructor e.g. "writeProps=True" ?

By default an SDWriter should write out all properties of a molecule
that have not been flagged as "computed" when you call mol.SetProp().
Here's an example:

[1]>>> from rdkit import Chem

[2]>>> m = Chem.MolFromSmiles('c1ccccc1')

[3]>>> m.SetProp('_Name','benzene')

[4]>>> m.SetProp('Prop1','4')

[9]>>> m2 = Chem.MolFromSmiles('c1ccccc1C')

[10]>>> m2.SetProp('_Name','toluene')

[11]>>> m2.SetProp('Prop2','5')

[12]>>> w = Chem.SDWriter('test.sdf')

[13]>>> w.write(m)

[14]>>> w.write(m2)

[15]>>> w.close()

[16]>>> !cat test.sdf
benzene
     RDKit

  6  6  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  2  0
  2  3  1  0
  3  4  2  0
  4  5  1  0
  5  6  2  0
  6  1  1  0
M  END
>  <Prop1>  (1)
4

$$$$
toluene
     RDKit

  7  7  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  2  0
  2  3  1  0
  3  4  2  0
  4  5  1  0
  5  6  2  0
  6  7  1  0
  6  1  1  0
M  END
>  <Prop2>  (2)
5

$$$$

[17]>>>

If you're seeing different behavior, and you are using SetProp without
the optional third argument set to True, then I'd love to see some
sample code, because it's a bug.

> Related discussion:
> http://www.mail-archive.com/[email protected]/msg01712.html

That was a different request: the question was how to write a
compressed SD file from the RDKit without first generating a standard
SD file.

-greg

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to