If you are looking for something quick and dirty, you could stay in numpy
to calculate Tanimoto.

*from rdkit import Chem*
*from rdkit.Chem import AllChem*

*import numpy as np*
*from __future__ import division*

*mol1 = Chem.MolFromSmiles('CCO')*
*mol2 = Chem.MolFromSmiles('CCC')*

*fp1 = np.array(AllChem.GetMorganFingerprintAsBitVect(mol1, 8),
dtype='bool')*
*fp2 = np.array(AllChem.GetMorganFingerprintAsBitVect(mol2, 8),
dtype='bool')*

*def tanimoto(v1, v2):*
*    """*
*    Calculates tanimoto similarity for two bit vectors*
*    """*
*    return(np.bitwise_and(v1, v2).sum() / np.bitwise_or(v1, v2).sum())*

*tanimoto(fp1, fp2)*

*Out[4]:0.42857142857142855*


On Thu, Mar 16, 2017 at 7:28 AM, Thomas Evangelidis <teva...@gmail.com>
wrote:

> Hello,
>
> I created a numpyarray from a molecule using the following function:
>
> AllChem.GetMorganFingerprintAsBitVect()
>
>
> Now I would like to convert back to bit vector the numpy array, in order
> to calculate the Tanimoto similarity of two compounds. Is this possible?
>
> thanks
> Thomas
>
>
>
> --
>
> ======================================================================
>
> Thomas Evangelidis
>
> Research Specialist
> CEITEC - Central European Institute of Technology
> Masaryk University
> Kamenice 5/A35/1S081,
> 62500 Brno, Czech Republic
>
> email: tev...@pharm.uoa.gr
>
>           teva...@gmail.com
>
>
> website: https://sites.google.com/site/thomasevangelidishomepage/
>
>
> ------------------------------------------------------------
> ------------------
> 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

Reply via email to