Импорт всего необходимого
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit import RDConfig
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
import numpy as np
from IPython.display import display,Image
import rdkit.Chem.Lipinski as Lipinksy
import pubchempy as pcp
Изображение ибупрофена
ibu=Chem.MolFromSmiles('CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)
Скачаем список из азидов
compounds = []
per_page = 1000
for smiles in ["N=[N+]=[N-]", "N=N=N", "NN#N"]:
for i in range(2):
try:
a = pcp.get_properties(properties = "CanonicalSMILES",
identifier = smiles, namespace="smiles",
searchtype = "substructure",
RingsNotEmbedded = True,
listkey_count = per_page,
listkey_start = i*per_page)
except:
None
print ("Retrieved page {} of {} search".format(i+1, smiles))
compounds.extend(a)
Retrieved page 1 of N=[N+]=[N-] search Retrieved page 2 of N=[N+]=[N-] search Retrieved page 1 of N=N=N search Retrieved page 2 of N=N=N search Retrieved page 1 of NN#N search Retrieved page 2 of NN#N search
smiles_list = [k['CanonicalSMILES'] for k in compounds]#создадим список из SMILES
template = 'N1N=NC(=C1)C(C)(C(=O)O)C1=CC=C(C=C1)CC(C)C'
template_mol = Chem.MolFromSmiles('N1N=NC(=C1)C(C)(C(=O)O)C1=CC=C(C=C1)CC(C)C')
AllChem.Compute2DCoords(template_mol)
display(template_mol)
new_smiles = []
for smi in smiles_list:
for a in ["N=[N+]=[N-]", "N=N=N", "NN#N"]:
if a in smi:
newsmi = smi.replace(a, template)
new_smiles.append(newsmi)
Создадим функцию которая будет проверять соответствие правилу Липински
def is_lipinsky(smiles, parameters=(5, 10, 500, 5)):
return all(i < j for i, j in zip([Lipinksy.NumHDonors(smiles),
Lipinksy.NumHAcceptors(smiles),
Lipinksy.rdMolDescriptors.CalcExactMolWt(smiles),
Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(smiles)[0]], parameters))
is_lipinsky(ibu)
True
#проверим на отобранных молекулах правило Липински
lep_mol = []
for smi in new_smiles:
try:
newmol=Chem.MolFromSmiles(smi)
if is_lipinsky(newmol) == True:
lep_mol.append(newmol)
except:
pass
RDKit ERROR: [20:42:35] Explicit valence for atom # 8 Cl, 3, is greater than permitted RDKit ERROR: [20:42:38] Explicit valence for atom # 8 Cl, 3, is greater than permitted
print("Молекул, удовлетворяющих правилу Липински, {} шт. из {} найденных по шаблону.".format(len(lep_mol),len(new_smiles)))
Молекул, удовлетворяющих правилу Липински, 446 шт. из 4001 найденных по шаблону.
Построим большую картинку
from IPython.display import SVG
for mol in good_mol:
AllChem.Compute2DCoords(mol)
display(Draw.MolsToGridImage(good_mol[:64],useSVG=True, molsPerRow=3, subImgSize=(200, 200)))
/mnt/scratch/mm-course/miniconda3/envs/molsim/lib/python3.6/site-packages/rdkit/Chem/Draw/IPythonConsole.py:188: UserWarning: Truncating the list of molecules to be displayed to 50. Change the maxMols value to display more. % (maxMols))
Similiraty Map ибупрофена с 5-ым веществом
from rdkit.Chem.Draw import SimilarityMaps
fp = SimilarityMaps.GetMorganFingerprint(lep_mol[5], fpType='bv')
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(ibu, lep_mol[5], SimilarityMaps.GetMorganFingerprint)
conda install -c omnia nglview
Collecting package metadata (current_repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.8.2 latest version: 4.10.1 Please update conda by running $ conda update -n base -c defaults conda ## Package Plan ## environment location: /mnt/scratch/mm-course/miniconda3/envs/molsim added / updated specs: - nglview The following packages will be downloaded: package | build ---------------------------|----------------- ca-certificates-2021.4.13 | h06a4308_1 114 KB nglview-0.6.2.3 | py36_0 5.2 MB omnia openssl-1.1.1k | h27cfd23_0 2.5 MB ------------------------------------------------------------ Total: 7.8 MB The following packages will be UPDATED: ca-certificates conda-forge::ca-certificates-2020.12.~ --> pkgs/main::ca-certificates-2021.4.13-h06a4308_1 openssl 1.1.1j-h27cfd23_0 --> 1.1.1k-h27cfd23_0 The following packages will be SUPERSEDED by a higher-priority channel: nglview conda-forge/noarch::nglview-2.7.7-pyh~ --> omnia/linux-64::nglview-0.6.2.3-py36_0 Downloading and Extracting Packages ca-certificates-2021 | 114 KB | ##################################### | 100% nglview-0.6.2.3 | 5.2 MB | ##################################### | 100% openssl-1.1.1k | 2.5 MB | ##################################### | 100% Preparing transaction: done Verifying transaction: failed EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: /mnt/scratch/mm-course/miniconda3/envs/molsim uid: 10517 gid: 1018 Note: you may need to restart the kernel to use updated packages.
import nglview as nv
Сделаем конформацию лиганда
m3d=Chem.AddHs(lep_mol[5])
Chem.AllChem.EmbedMolecule(m3d)
AllChem.MMFFOptimizeMolecule(m3d,maxIters=500,nonBondedThresh=200 )
m3d
nv.show_rdkit(m3d)