Thanks Maciek and Greg!

I did some timing tests about this, with the following approaches:
1) building a new submol by copying each desired atom (and the bonds
between) to a new EditableMol in python side
2) using PathToSubmol in the way Maciek suggested
3) Similarly as in 1) but done in C++ (exposed to python, still)

Doing 150000 substructure extractions (5 to 8 atom fragments from
different molecules, with no conformers), the timings were
1) 27.44s
2) 6.73s
3) 2.80s

So some improvement is still possible, but not sure if the difference
between 2) & 3) is large enough to support the implementation of
another (overlapping) function for this task...

Juuso



On Thu, Nov 3, 2016 at 4:54 PM, Greg Landrum <greg.land...@gmail.com> wrote:
> Juuso,
>
> I think you will find Chem.PathToSubmol(), which takes a molecule and
> sequence of *bond* indices, useful:
>
> In [6]: m = Chem.MolFromSmiles('COCc1ccccc1')
>
> In [8]: sm = Chem.PathToSubmol(m,(0,1))
>
> In [9]: sm.UpdatePropertyCache()
>
> In [10]: sm.Debug()
> Atoms:
> 0 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
> 1 8 O chg: 0  deg: 2 exp: 2 imp: 0 hyb: 4 arom?: 0 chi: 0
> 2 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
> Bonds:
> 0 0->1 order: 1 conj?: 0 aromatic?: 0
> 1 1->2 order: 1 conj?: 0 aromatic?: 0
>
>
> Best,
> -greg
>
>
> On Tue, Nov 1, 2016 at 11:00 AM, Juuso Lehtivarjo
> <juuso.lehtiva...@gmail.com> wrote:
>>
>> Hi All,
>>
>> Is there a python function (or any simple way whatsoever) to create a
>> substructure mol object from another one based on the given atom
>> indices? In C++ this could apparently be done with
>> getMolFragsWithQuery, but that does not seem to be much used in python
>> wrappers...
>>
>> Best,
>>    Juuso
>>
>>
>> ------------------------------------------------------------------------------
>> Developer Access Program for Intel Xeon Phi Processors
>> Access to Intel Xeon Phi processor-based developer platforms.
>> With one year of Intel Parallel Studio XE.
>> Training and support from Colfax.
>> Order your platform today. http://sdm.link/xeonphi
>> _______________________________________________
>> Rdkit-discuss mailing list
>> Rdkit-discuss@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to