导入库

    1. from rdkit import Chem
    2. from rdkit.Chem import Draw
    3. from rdkit.Chem.Draw import SimilarityMaps
    4. from IPython.display import SVG
    5. import numpy as np
    6. import rdkit
    7. print(rdkit.__version__)

    image.gif

    2020.09.1

    基于Morgan指纹的相似图绘制

    1. atorvastatin = Chem.MolFromSmiles('O=C(O)C[C@H](O)C[C@H](O)CCn2c(c(c(c2c1ccc(F)cc1)c3ccccc3)C(=O)Nc4ccccc4)C(C)C')
    2. rosuvastatin = Chem.MolFromSmiles('OC(=O)C[C@H](O)C[C@H](O)\C=C\c1c(C(C)C)nc(N(C)S(=O)(=O)C)nc1c2ccc(F)cc2')
    3. Draw.MolsToGridImage((atorvastatin,rosuvastatin))

    image.gif
    RDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图3image.gif

    1. d = Draw.MolDraw2DSVG(400, 400)
    2. _, maxWeight = SimilarityMaps.GetSimilarityMapForFingerprint(atorvastatin, rosuvastatin,
    3. lambda m, i: SimilarityMaps.GetMorganFingerprint(m, i, radius=2, fpType='bv'),
    4. draw2d=d)
    5. d.FinishDrawing()
    6. SVG(d.GetDrawingText())

    image.gif
    RDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图6
    image.gif

    1. d = Draw.MolDraw2DSVG(400, 400)
    2. _, maxWeight = SimilarityMaps.GetSimilarityMapForFingerprint(atorvastatin, rosuvastatin,
    3. lambda m, i: SimilarityMaps.GetMorganFingerprint(m, i, radius=2, fpType='count'),
    4. draw2d=d)
    5. d.FinishDrawing()
    6. SVG(d.GetDrawingText())

    image.gif
    RDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图9
    image.gif

    1. from rdkit.Chem import rdMolDescriptors
    2. ator_contribs = rdMolDescriptors._CalcCrippenContribs(atorvastatin)
    3. d = Draw.MolDraw2DSVG(400, 400)
    4. SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin,[x[0] for x in ator_contribs],draw2d=d)
    5. d.FinishDrawing()
    6. SVG(d.GetDrawingText())

    image.gif
    RDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图12
    image.gif

    1. from rdkit.Chem import rdEHTTools
    2. from rdkit.Chem import rdDistGeom
    3. mh = Chem.AddHs(atorvastatin)
    4. rdDistGeom.EmbedMolecule(mh)
    5. _,res = rdEHTTools.RunMol(mh)
    6. static_chgs = res.GetAtomicCharges()[:atorvastatin.GetNumAtoms()]
    7. d = Draw.MolDraw2DSVG(400, 400)
    8. SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin,list(static_chgs),draw2d=d)
    9. d.FinishDrawing()
    10. SVG(d.GetDrawingText())

    image.gif
    RDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图15
    image.gif

    1. mh = Chem.AddHs(atorvastatin)
    2. ps = rdDistGeom.ETKDGv2()
    3. ps.pruneRmsThresh = 0.5
    4. ps.randomSeed = 0xf00d
    5. rdDistGeom.EmbedMultipleConfs(mh,10,ps)
    6. print(f'Found {mh.GetNumConformers()} conformers')
    7. chgs = []
    8. for conf in mh.GetConformers():
    9. _,res = rdEHTTools.RunMol(mh,confId=conf.GetId())
    10. chgs.append(res.GetAtomicCharges()[:atorvastatin.GetNumAtoms()])
    11. chgs = np.array(chgs)
    12. mean_chgs = np.mean(chgs,axis=0)
    13. std_chgs = np.std(chgs,axis=0)
    14. d = Draw.MolDraw2DSVG(400, 400)
    15. SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin,list(mean_chgs),draw2d=d)
    16. d.FinishDrawing()
    17. SVG(d.GetDrawingText())

    image.gif
    RDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图18
    image.gif

    1. print(std_chgs)
    2. print(max(std_chgs),min(std_chgs))
    3. d = Draw.MolDraw2DSVG(400, 400)
    4. SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin,list(std_chgs),draw2d=d)
    5. d.FinishDrawing()
    6. SVG(d.GetDrawingText())

    image.gifRDKit | 基于RDKit(≥2020.09.1)的相似图绘制新方法 - 图21