One minor refinement to Christos' answer. If you create an SDWriter and do
not call SetProps(), it *should* write all non-computed properties each
molecule has. This should work from both Python and Java
Here's a very simple example of that from Python, the Java should behave
the same way:
In [1]: from rdkit import Chem
In [2]: import StringIO
In [3]: sio = StringIO.StringIO()
In [4]: m = Chem.MolFromSmiles('C')
In [5]: m.SetProp('p1','1')
In [7]: m2 = Chem.MolFromSmiles('C')
In [8]: m2.SetProp('p2','2')
In [9]: m2.SetProp('p3','1')
In [10]: w = Chem.SDWriter(sio)
In [12]: w.write(m)
In [13]: w.write(m2)
In [14]: w.flush()
In [15]: w=None
In [16]: print sio.getvalue()
RDKit
1 0 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
M END
> <p1> (1)
1
$$$$
RDKit
1 0 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
M END
> <p2> (2)
2
> <p3> (2)
1
$$$$
The property values getting lost while pickling molecules is a known
shortcoming of the RDKit that is probably fixable in a future version
(there are a few other good reasons to make the changes required for that).
Best,
-greg
On Thu, Mar 12, 2015 at 4:46 PM, Christos Kannas <[email protected]>
wrote:
> Hi Mathew,
>
> In order to store the tags and the data associated with them prior to
> writing the molecule to SDF/SMILES file you have to use SetProps(props)
> e.g. outfile.SetProps(props), where props is a list of the tags names your
> molecules have.
>
> In regards to when you pickle molecules you loose that extra
> information,you can convert your molecules to PropertyMol, e.g. from
> rdkit.Chem.PropertyMol import PropertyMol pmol = PropertyMol(mol)
>
> Hope the information above helps a bit.
>
> Regards,
>
> Christos
>
> Christos Kannas
>
> Researcher
> Ph.D Student
>
> [image: View Christos Kannas's profile on LinkedIn]
> <http://cy.linkedin.com/in/christoskannas>
>
> On 12 March 2015 at 15:33, Matthew Lardy <[email protected]> wrote:
>
>> Hi,
>>
>> I've noticed some strangeness between the Java and Python wrappers that I
>> have spent some time battling. If I load a SD file, via the SDMolSupplier
>> and then write out the file with SDWriter I lose all of the tags for the
>> molecules. Also if I pickle an SD file, reload it and then iterate over it
>> the tags are missing again. Is this the expected behaviour, or I am doing
>> something wrong?
>>
>> Thanks in advance!
>> Matthew
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website,
>> sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub
>> for all
>> things parallel software development, from weekly thought leadership
>> blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> _______________________________________________
>> Rdkit-discuss mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>
>>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss