Re: [Rdkit-discuss] Properties through Pickle

2017-10-26 Thread Lionel Colliandre

Hi Maciek,

Many thanks for your answer. I completely missed this function. Now all 
work perfectly.


Lionel


Le 26/10/2017 à 16:01, Maciek Wójcikowski a écrit :

Hi Lionel,

There is PropertyMol class which does what you want, see 
http://www.rdkit.org/Python_Docs/rdkit.Chem.PropertyMol.PropertyMol-class.html



Pozdrawiam,  |  Best regards,
Maciek Wójcikowski
mac...@wojcikowski.pl 

2017-10-26 15:17 GMT+02:00 Lionel Colliandre >:


Hi everyone,

I have molecules from a SDfile to store in Pickle format.

So I read the SDfile and with mol.GetProp() function, I can access
to a property of the molecule included in the SDfile.
Unfortunately, when I convert the molecule in Pickle and come back
to the rdkit mol format, the property is lost.

What I am doing wrong?

Here is my script. I am using RDKit 2015_03_1 on Windows 10, 64bit.


---

from __future__ import print_function
from rdkit import Chem
import cPickle as pickle


SDfile = "sdfile.sdf"

suppl = Chem.SDMolSupplier(SDfile, sanitize=True)

ms = [x for x in suppl if x is not None]

## Convert in Pickle
pklsuppl = []
for mol in suppl:
    if mol is None: continue
    if mol.HasProp('Code'):
    print('Prop ok in Mol')
    else:
    print('No Prop in Mol')
    pkl = pickle.dumps(mol, protocol=pickle.HIGHEST_PROTOCOL)
    newmol = pickle.loads(pkl)
    if newmol.HasProp('Code'):
    print('Prop ok in NewMol')
    else:
    print('No Prop in NewMol')
---


I obtain "Prop ok in Mol" and "No Prop in NewMol".

Thanks for your help,

Lionel



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/rdkit-discuss





--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


Re: [Rdkit-discuss] Properties through Pickle

2017-10-26 Thread Maciek Wójcikowski
Hi Lionel,

There is PropertyMol class which does what you want, see
http://www.rdkit.org/Python_Docs/rdkit.Chem.PropertyMol.PropertyMol-class.html


Pozdrawiam,  |  Best regards,
Maciek Wójcikowski
mac...@wojcikowski.pl

2017-10-26 15:17 GMT+02:00 Lionel Colliandre :

> Hi everyone,
>
> I have molecules from a SDfile to store in Pickle format.
>
> So I read the SDfile and with mol.GetProp() function, I can access to a
> property of the molecule included in the SDfile. Unfortunately, when I
> convert the molecule in Pickle and come back to the rdkit mol format, the
> property is lost.
>
> What I am doing wrong?
>
> Here is my script. I am using RDKit 2015_03_1 on Windows 10, 64bit.
>
>
> ---
>
> from __future__ import print_function
> from rdkit import Chem
> import cPickle as pickle
>
>
> SDfile = "sdfile.sdf"
>
> suppl = Chem.SDMolSupplier(SDfile, sanitize=True)
>
> ms = [x for x in suppl if x is not None]
>
> ## Convert in Pickle
> pklsuppl = []
> for mol in suppl:
> if mol is None: continue
> if mol.HasProp('Code'):
> print('Prop ok in Mol')
> else:
> print('No Prop in Mol')
> pkl = pickle.dumps(mol, protocol=pickle.HIGHEST_PROTOCOL)
> newmol = pickle.loads(pkl)
> if newmol.HasProp('Code'):
> print('Prop ok in NewMol')
> else:
> print('No Prop in NewMol')
> ---
>
>
> I obtain "Prop ok in Mol" and "No Prop in NewMol".
>
> Thanks for your help,
>
> Lionel
>
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss