聚类分子(Clustering molecules)
聚类是一种有价值的化学信息学技术,用于将大型化合物数据集合细分为单个小组相似化合物。其中一个优点是处理非常大的小分子数据集时特别有用。通常用于分析高通量筛选结果、虚拟筛选或对接研究的分析。
基于RDKit的Python脚本用于聚类分子
阅读原文查看完成代码:
#!/usr/bin/python3
def ClusterFps(fps,cutoff=0.2):
from rdkit import DataStructs
from rdkit.ML.Cluster import Butina
# first generate the distance matrix:
dists = []
nfps = len(fps)
for i in range(1,nfps):
sims = DataStructs.BulkTanimotoSimilarity(fps[i],fps[:i])
dists.extend([1-x for x in sims])
# now cluster the data:
cs = Butina.ClusterData(dists,nfps,cutoff,isDistData=True)
return cs
from rdkit import Chem
from rdkit.Chem import AllChem
#generate fingerprints
ms = [x for x in Chem.ForwardSDMolSupplier('ApprovedDrugs.sdf') if x is not None]
fps = [AllChem.GetMorganFingerprintAsBitVect(x,2,1024) for x in ms]
#cluster
clusters=ClusterFps(fps,cutoff=0.4)
# show one of the clusters
print(clusters[20])
#now display structures from one of the clusters
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
#look at a specific cluster
m1 = ms[1630]
m2 = ms[1010]
m3 = ms[1022]
m4 = ms[1023]
m5 = ms[1034]
m6 = ms[1043]
mols=(m1,m2,m3,m4,m5,m6)
Draw.MolsToGridImage(mols)
参考资料
http://www.rdkit.org/docs/Cookbook.html