import numpy as np
import copy
# Отображение структур
import IPython.display
import ipywidgets
from IPython.display import display,display_svg,SVG,Image
# Open Drug Discovery Toolkit
import oddt
import oddt.docking
import oddt.interactions
# Органика
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
import pmx # Модуль для манипулирования pdb
pdb=pmx.Model('../hw6/model.B99990001.pdb')
for r in pdb.residues[-15:]:
print r #посмотрим остатки
# создание объектов белок и лиганда
newpdb = pdb.copy()
for r in newpdb.residues[-3:]:
newpdb.remove_residue(r)
newpdb.writePDB('myprot.pdb')
lig = pdb.copy()
del lig.residues[:-3]
lig_center = sum(map(lambda a: np.array(a.x), lig.atoms)) / len(lig.atoms)
lig_center
prot = oddt.toolkit.readfile('pdb','myprot.pdb').next()
prot.OBMol.AddPolarHydrogens()
prot.OBMol.AutomaticPartialCharge()
print 'is it the first mol in 1lmp is protein?',prot.protein,':) and MW of this mol is:', prot.molwt
NAG_smiles = 'CC(=O)NC1C(C(C(OC1O)CO)O)O'
smiles = ['OC(=O)NC1C(C(C(OC1O)CO)O)O', #OH
'[NH3+]C(=O)NC1C(C(C(OC1O)CO)O)O', #NH3+
'C(=O)NC1C(C(C(OC1O)CO)O)O', #H
'C1=CC=[C]C=C1C(=O)NC1C(C(C(OC1O)CO)O)O', #PH
'[O-]C(=O)C(=O)NC1C(C(C(OC1O)CO)O)O'] #COO
mols= []
images =[]
for s in smiles:
m = oddt.toolkit.readstring('smi', s)
if not m.OBMol.Has3D():
m.make3D(forcefield='mmff94', steps=150)
m.removeh()
m.OBMol.AddPolarHydrogens()
mols.append(m)
###with print m.OBMol.Has3D() was found that:
### deep copy needed to keep 3D , write svg make mols flat
images.append((SVG(copy.deepcopy(m).write('svg'))))
display_svg(*images)
dock_obj= oddt.docking.AutodockVina.autodock_vina(
protein=prot,size=(20,20,20),center=lig_center.tolist(),
executable='/usr/bin/vina',autocleanup=True, num_modes=9)
print dock_obj.tmp_dir
print " ".join(dock_obj.params) # Опишите выдачу
?dock_obj
protein: oddt.toolkit.Molecule object (default=None) Protein object to be used while generating descriptors.
auto_ligand: oddt.toolkit.Molecule object or string (default=None)
Ligand use to center the docking box. Either ODDT molecule or
a file (opened based on extesion and read to ODDT molecule).
Box is centered on geometric center of molecule.
size: tuple, shape=[3] (default=(20, 20, 20))
Dimentions of docking box (in Angstroms)
center: tuple, shape=[3] (default=(0,0,0))
The center of docking box in cartesian space.
exhaustiveness: int (default=8)
Exhaustiveness parameter of Autodock Vina
num_modes: int (default=9)
Number of conformations generated by Autodock Vina. The maximum
number of docked poses is 9 (due to Autodock Vina limitation).
energy_range: int (default=3)
Energy range cutoff for Autodock Vina
seed: int or None (default=None)
Random seed for Autodock Vina
prefix_dir: string (default=/tmp)
Temporary directory for Autodock Vina files
executable: string or None (default=None)
Autodock Vina executable location in the system.
It's realy necessary if autodetection fails.
autocleanup: bool (default=True)
Should the docking engine clean up after execution?
skip_bad_mols: bool (default=True)
Should molecules that crash Autodock Vina be skipped.
res = dock_obj.dock(mols,prot)
for i,r in enumerate(res):
print "%4d%10s%8s%8s%8s" %(i,r.formula, r.data['vina_affinity'], r.data['vina_rmsd_ub'], r.residues[0].name)
import pandas as pd
data = pd.DataFrame(np.array([
[i.formula for i in res],\
[i.data['vina_affinity'] for i in res],\
[i.data['vina_rmsd_ub'] for i in res],\
[i.residues[0].name for i in res],\
['OH']*9+['NH3+']*9+['H']*9+['Ph']*9+['COO']*9
]).T,columns = [['Formula','Affinity','RSMD','Name','Radical']])
data.sort_values(by='Affinity')
for i,r in enumerate(res):
hbs = oddt.interactions.hbonds(prot,r)
stack= oddt.interactions.pi_stacking(prot,r)
phob = oddt.interactions.hydrophobic_contacts(prot,r)
for i,r in enumerate(res):
r.write(filename='r%s.pdb' % i, format='pdb')
import time
import __main__
import os
import pymol
__main__.pymol_argv = [ 'pymol', '-cp' ]
pymol.finish_launching()
from pymol import cmd
from IPython.display import Image, display, HTML
FILE_NAME = 'img.png'
def prepareImage(width=550, height=550, sleep=1, filename=FILE_NAME):
cmd.ray(width, height)
cmd.png(filename)
time.sleep(sleep)
cmd.reinitialize()
cmd.load('myprot.pdb')
cmd.load('r35.pdb')
cmd.show('sticks','r35')
cmd.show('cartoon','myprot')
cmd.hide('lines','myprot')
cmd.orient()
prepareImage()
Image(FILE_NAME)
cmd.reinitialize()
cmd.load('myprot.pdb')
cmd.load('r8.pdb')
cmd.show('sticks','r8')
cmd.show('cartoon','myprot')
cmd.hide('lines','myprot')
cmd.orient()
prepareImage()
Image(FILE_NAME)
cmd.reinitialize()
cmd.load('myprot.pdb')
cmd.load('r26.pdb')
cmd.show('sticks','r26')
cmd.show('cartoon','myprot')
cmd.hide('lines','myprot')
cmd.orient()
prepareImage()
Image(FILE_NAME)
cmd.reinitialize()
cmd.load('myprot.pdb')
cmd.load('r44.pdb')
cmd.show('sticks','r44')
cmd.show('cartoon','myprot')
cmd.hide('lines','myprot')
cmd.orient()
prepareImage()
Image(FILE_NAME)
cmd.reinitialize()
cmd.load('myprot.pdb')
cmd.load('r16.pdb')
cmd.show('sticks','r16')
cmd.show('cartoon','myprot')
cmd.hide('lines','myprot')
cmd.orient()
prepareImage()
Image(FILE_NAME)
!jupyter nbconvert --to html rudakov_kirill_hw7.ipynb