Sorry if this is a simple question, but I am having trouble returning the molecule attributes when I pickle and unpickle a molecule.

The simplest example I can come up with is:

import cPickle as pickle
from rdkit import Chem

>>> m = MolFromSmiles( 'c1ccccc1' )
>>> m.SetProp( '_Name', 'benzene' )
>>> p = pickle.dumps( m )
>>> m2 = pickle.loads( p )
>>> Chem.MolToSmiles( m2 )
'c1ccccc1'
>>> m2.GetProp( '_Name' )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: '_Name'
>>> m.GetProp( '_Name' )
'benzene'
>>>

I use the name when I am searching the SMILES to provide feedback as to what molecules hit the search. Loading the ASCII files of SMILES is slow. So I thought I would pickle the molecules.

Is there something I am missing or a better way to associate a name with a molecule?

Jon T. Swanson, Ph.D.

ChemModeling, LLC
Suite 101, 500 Huber Park Ct.
Weldon Spring, MO 63304

(636) 329-0300
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to