Hi Curt,

On Fri, Jul 10, 2015 at 11:40 PM, Curt Fischer <[email protected]>
wrote:

>
> I use rdkit through its Python API.  As part of an iterative computation
> on a molecule, I have to repeatedly remove different combinations of bonds
> from it.  I noticed that the calls to Chem.EditableMol() to create the em,
> to em.GetMol() to get back the new molecule, and to em.RemoveBonds() to
> remove the bonds were taking the most time in my code that loops over
> different combinations of bonds.  To speed things up, I though about
> storing copies of intermediate ems in a dictionary, but unfortunately no
> methods for pickling EditableMol() objects seems to be available.
>
> For example, this code...
>
> trp_inchi =
>> 'InChI=1S/C11H12N2O2/c12-9(11(14)15)5-7-6-13-10-4-2-1-3-8(7)10/h1-4,6,9,13H,5,12H2,(H,14,15)/t9-/m0/s1'
>> trp = Chem.MolFromInchi(trp_inchi)
>> e_trp = Chem.EditableMol(trp)
>> from copy import copy, deepcopy
>> for mol in [trp, e_trp]:
>>     try:
>>         copy(mol); print '%s can be copied' % mol
>>         deepcopy(mol); print '%s can be deep copied' % mol
>>         mol.ToBinary(); print '%s can be serialized by converting to
>> binary' % mol
>>     except RuntimeError:
>>         print 'These methods are not available for %s' % mol
>
>
> ...results in
>
> <rdkit.Chem.rdchem.Mol object at 0x11334ee60> can be copied
>> <rdkit.Chem.rdchem.Mol object at 0x11334ee60> can be deep copied
>> <rdkit.Chem.rdchem.Mol object at 0x11334ee60> can be serialized by
>> converting to binary
>> These methods are not available for <rdkit.Chem.rdchem.EditableMol object
>> at 0x11334f7e0>
>
>
> Is there an easy way to "roll my own" serialization or pickle method for
> this class, if I have extremely limited knowledge of C++ but an OK to good
> knowledge of Python?
>

The last release of the RDKit included a new class, RWMol, that should be
useable for what you want to do. There's a bit of explanation in the
documentation:
http://rdkit.org/docs/GettingStartedInPython.html#editing-molecules
but basically you can just treat an RWMol as a normal Mol object.

If you want a normal Mol object, you can do the conversion directly:
    nm = Chem.Mol(rwmol)

EditableMols will eventually be deprecated and shouldn't be used any more
in new code.


> Also, I'm new to the rdkit community and hope I'm sending my message to
> the right place.  Would rdkit-devel be better for this sort of question?
>

rdkit-discuss is the right place for this kind of thing.

Best,
-greg
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to