3. Хемоинформатика

Загрузка модулей conda и rdkit.

In [5]:
conda install -c rdkit rdkit
Collecting package metadata: done
Solving environment: \ 
Warning: 4 possible package resolutions (only showing differing packages):
  - anaconda::ca-certificates-2019.1.23-0, anaconda::certifi-2019.3.9-py36_0
  - anaconda::certifi-2019.3.9-py36_0, defaults::ca-certificates-2019.1.23-0
  - anaconda::ca-certificates-2019.1.23-0, defaults::certifi-2019.3.9-py36_0
  - defaults::ca-certificates-2019.1.23-0, defaults::certifi-2019.3.9-py36done

## Package Plan ##

  environment location: /anaconda2

  added / updated specs:
    - rdkit


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-4.6.14               |           py36_0         2.1 MB
    rdkit-2019.03.1.0          |   py36h65625ec_1        22.1 MB  rdkit
    ------------------------------------------------------------
                                           Total:        24.2 MB

The following packages will be UPDATED:

  conda                        anaconda::conda-4.6.8-py36_0 --> pkgs/main::conda-4.6.14-py36_0
  rdkit                          2018.09.2.0-py36h8bdf8f1_1 --> 2019.03.1.0-py36h65625ec_1



Downloading and Extracting Packages
rdkit-2019.03.1.0    | 22.1 MB   | ##################################### | 100% 
conda-4.6.14         | 2.1 MB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Note: you may need to restart the kernel to use updated packages.
In [6]:
conda install -c jirinovo pubchempy
Collecting package metadata: done
Solving environment: | 
Warning: 4 possible package resolutions (only showing differing packages):
  - anaconda::ca-certificates-2019.1.23-0, anaconda::certifi-2019.3.9-py36_0
  - anaconda::ca-certificates-2019.1.23-0, defaults::certifi-2019.3.9-py36_0
  - anaconda::certifi-2019.3.9-py36_0, defaults::ca-certificates-2019.1.23-0
  - defaults::ca-certificates-2019.1.23-0, defaults::certifi-2019.3.9-py36done

# All requested packages already installed.


Note: you may need to restart the kernel to use updated packages.
In [2]:
from rdkit import Chem
In [3]:
from rdkit.Chem import AllChem
In [4]:
from rdkit import RDConfig
In [5]:
from rdkit.Chem.Draw import IPythonConsole 
In [6]:
from rdkit.Chem import Draw
In [7]:
import numpy as np
In [8]:
from IPython.display import display, Image

Изобразим молекулу ибупрофена.

In [9]:
ibu=Chem.MolFromSmiles('CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)

Подсчёт параметров с учётом правила Липинского.

In [10]:
import rdkit.Chem.Lipinski as Lipinsky
def lipinsky_check(molecule):
    if ((Lipinsky.NumHDonors(molecule) <= 5) \
    and (Lipinsky.NumHAcceptors(molecule) <= 10) \
    and (Lipinsky.rdMolDescriptors.CalcExactMolWt(molecule) < 500) \
    and (Lipinsky.rdMolDescriptors.CalcCrippenDescriptors(molecule)[0] <= 5)):
        return True
    else:
        return False
In [11]:
lipinsky_check(ibu)
Out[11]:
True

Необходимые условия выполнены.

Модифицируем ибупрофен.

In [12]:
#template_smiles = 'CC(C)CC1=CC=C(C=C1)C(C)C(=O)N=[N+]=[N-]'
template_smiles = 'N1N=NC(=C1)C(C)CC1=CC=C(C=C1)C(C)C(=O)O'
template = Chem.MolFromSmiles(template_smiles)
AllChem.Compute2DCoords(template)
display(template)
print(template)
<rdkit.Chem.rdchem.Mol object at 0x7f9fcc0f4530>

Далее в базе Pubchem был произведён поиск вручную радикалов с азидом, удовлетворяющих правилу Липинского. Отфильтруем скачанные SMILES.

In [14]:
strings = np.genfromtxt('result.txt', dtype = np.str)
smiles = []
for line in strings:
    if (len(line[1]) < 30) and not ('.' in line[1]):
        smiles.append(line[1])
len(smiles)
Out[14]:
55

Построим новые молекулы и отфильтруем их.

In [15]:
new_smiles = []
for smi in smiles:
    if 'N=[N+]=[N-]' in smi:
        newsmile = smi.replace('N=[N+]=[N-]', template_smiles)
        #print(newsmile)
        try:
            newsmi = Chem.MolFromSmiles(newsmile)
            #print(newsmi)
            if lipinsky_check(newsmi):
                new_smiles.append(newsmi)
        except Exception:
            pass
    else:
        continue
len(new_smiles)
Out[15]:
52
In [16]:
Chem.Draw.MolsToGridImage(new_smiles[20:40], molsPerRow=4, subImgSize=(300, 300))
Out[16]:

Сравним 5-ую производную с ибупрофеном.

In [17]:
from rdkit.Chem.Draw import SimilarityMaps
fp = SimilarityMaps.GetMorganFingerprint(new_smiles[5], fpType='bv')
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(ibu, new_smiles[5], SimilarityMaps.GetMorganFingerprint)
/home/polina997/anaconda3/lib/python3.6/site-packages/rdkit/Chem/Draw/__init__.py:285: MatplotlibDeprecationWarning: The bivariate_normal function was deprecated in version 2.2.
  Z = mlab.bivariate_normal(X, Y, a, a, mol._atomPs[0][0], mol._atomPs[0][1]) * weights[0]
/home/polina997/anaconda3/lib/python3.6/site-packages/rdkit/Chem/Draw/__init__.py:287: MatplotlibDeprecationWarning: The bivariate_normal function was deprecated in version 2.2.
  Zp = mlab.bivariate_normal(X, Y, a, a, mol._atomPs[i][0], mol._atomPs[i][1])

Построим 3D-структуру.

In [18]:
m3d=Chem.AddHs(new_smiles[5])
Chem.AllChem.EmbedMolecule(m3d)
AllChem.MMFFOptimizeMolecule(m3d,maxIters=500,nonBondedThresh=300)
m3d
Out[18]:

Загрузка NGL viewer.

In [148]:
conda install -c omnia nglview 
Collecting package metadata: done
Solving environment: - 
Warning: 4 possible package resolutions (only showing differing packages):
  - anaconda::ca-certificates-2019.1.23-0, anaconda::certifi-2019.3.9-py36_0
  - anaconda::ca-certificates-2019.1.23-0, defaults::certifi-2019.3.9-py36_0
  - anaconda::certifi-2019.3.9-py36_0, defaults::ca-certificates-2019.1.23-0
  - defaults::ca-certificates-2019.1.23-0, defaults::certifi-2019.3.9-py36done

## Package Plan ##

  environment location: /anaconda2

  added / updated specs:
    - nglview


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ipywidgets-5.2.2           |           py36_1          64 KB
    nglview-0.6.2.3            |           py36_1         5.2 MB  omnia
    ------------------------------------------------------------
                                           Total:         5.3 MB

The following NEW packages will be INSTALLED:

  nglview            omnia/osx-64::nglview-0.6.2.3-py36_1

The following packages will be SUPERSEDED by a higher-priority channel:

  ipywidgets             pkgs/main::ipywidgets-7.4.2-py36_0 --> pkgs/free::ipywidgets-5.2.2-py36_1



Downloading and Extracting Packages
nglview-0.6.2.3      | 5.2 MB    | ##################################### | 100% 
ipywidgets-5.2.2     | 64 KB     | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Note: you may need to restart the kernel to use updated packages.
In [19]:
import nglview as nv
In [20]:
nv.show_rdkit(m3d)
Widget Javascript not detected.  It may not be installed properly. Did you enable the widgetsnbextension? If not, then run "jupyter nbextension enable --py --sys-prefix widgetsnbextension"
In [1]:
#conda install jupyter_core notebook nbconvert ipykernel ipywidgets
In [21]:
to_pymol = Chem.MolToSmiles(m3d)
with open('ibu_modif.smi', 'w') as file:
    file.write(to_pymol)
In [22]:
import subprocess
subprocess.run('obgen ibu_modif.smi > new_mol.mol', shell = True)
Out[22]:
CompletedProcess(args='obgen ibu_modif.smi > new_mol.mol', returncode=1)
In [36]:
import __main__
__main__.pymol_argv = [ 'pymol', '-x' ]

import pymol
pymol.finish_launching()
from pymol import cmd,stored

from IPython.display import Image
import time
import sys
In [31]:
cmd.reinitialize()
cmd.load('new_mol.mol', 'structure')
In [37]:
cmd.do('''
bg_color white
util.cbaw
set ray_trace_mode, 3
set ray_opaque_background, 0
''')
cmd.png('ibu_modif.png')
time.sleep(3)
Image(filename='ibu_modif.png')
Out[37]: