In [1]:
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
from rdkit.Chem import MACCSkeys
import numpy as np
In [2]:
mol1 = Chem.MolFromSmiles('COc1cc2c(cc1OCCCN3CCOCC3)c(ncn2)Nc4ccc(c(c4)Cl)F')
In [3]:
mol2 = Chem.MolFromSmiles('COCCOc1cc2c(cc1OCCOC)ncnc2Nc3cccc(c3)C#C')
In [4]:
mol1
Out[4]:
In [5]:
Draw.MolsToGridImage([mol1,mol2])
Out[5]:
In [6]:
fp1 = MACCSkeys.GenMACCSKeys(mol1)
fp2 = MACCSkeys.GenMACCSKeys(mol2)
In [7]:
fp1.ToBitString()
Out[7]:
In [8]:
fp2.ToBitString()
Out[8]:
In [9]:
fp_a1 = np.array(map(int, fp1.ToBitString()))
fp_a2 = np.array(map(int, fp2.ToBitString()))
In [10]:
from scipy.spatial.distance import dice
Distance
In [11]:
dice(fp_a1, fp_a2)
Out[11]:
Similarity
In [12]:
1 - dice(fp_a1, fp_a2)
Out[12]:
In [13]:
from rdkit.Chem.Draw import SimilarityMaps
In [14]:
%matplotlib inline
In [15]:
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(mol1, mol2, SimilarityMaps.GetMorganFingerprint)
In [ ]:
In [16]:
from rdkit.Chem import PandasTools
In [17]:
import pandas as pd
In [18]:
df = PandasTools.LoadSDF('../data/test.sdf')
In [19]:
df.head(1)
Out[19]:
In [20]:
from rdkit.Chem import Descriptors
In [21]:
df['HAC'] = df['ROMol'].map(Descriptors.HeavyAtomCount)
df['HBD'] = df['ROMol'].map(Descriptors.NumHDonors)
In [22]:
df.head(1)
Out[22]:
In [23]:
df['HAC'].head(5) > 15
Out[23]:
In [24]:
df[(df['HAC'] > 22) & df['HBD'] == 1]
Out[24]:
In [ ]:
In [25]:
from ipywidgets import interact, fixed
from IPython.display import display
Helper function that displays something
In [26]:
def show_frame(df, sort_by, ascending=True, num=2):
display(df.sort_values(sort_by, ascending=ascending).head(num))
In [27]:
show_frame(df, 'logp')
In [28]:
interact(show_frame, df=fixed(df), sort_by={'HAC':'HAC', 'HBD':'HBD'}, num=[1,3])
Out[28]:
In [ ]: