Это пример использования ODDT (http://jcheminf.springeropen.com/articles/10.1186/s13321-015-0078-2) для проведения докинга и визуализации в брфузере Перед запуском Ipython Notebook сделайте следующие шаги :
export PATH=${PATH}:/home/preps/golovin/miniconda2/bin
source activate oddt
jupyter notebook --no-browser
from IPython.display import Image
import ipywidgets
from ipywidgets.widgets import HBox
import numpy as np
from IPython.display import SVG
#import rdkit.RDConfig
#rdkit.RDConfig.RDDataDir='/home/preps/golovin/rdkit/usr/share/RDKit/Data/'
import oddt
import oddt.docking
#from rdkit.Chem import Draw
#from rdkit.Chem.Draw import IPythonConsole
import simpletraj
import nglview
# lets define adaptors for 3d viewer
class oddt_trajectory(nglview.Structure, nglview.Trajectory):
ext = "pdb" # or gro, cif, mol2, sdf
params = {} # loading options passed to NGL
def __init__(self,prot,mol,res):
self.prot = prot
self.mol = mol
self.res = res
def get_structure_string(self):
out=''
for l in (self.prot.write('pdb')+self.mol.write('pdb')).split('\n'):
if 'ATOM' in l or 'HETATM' in l:
out+= l + '\n'
return out
def get_coordinates_list( self, index ):
return self.prot.coords.flatten().tolist() + self.res[index].coords.flatten().tolist()
# coors
# return list of coordinates in Angstrom for the frame at the given index
#return [x1, y1, z1, x2, y2, z2]
def get_frame_count( self ):
return len(self.res) # return number of frames
class ob_structure(nglview.Structure):
ext = 'pdb'
params = {}
def __init__(self,m):
self.m=m
def get_structure_string(self):
return self.m.write('pdb')
def show_ob_structure(m, **kwargs):
extension = 'pdb'
structure = nglview.OBStructure(m)
return nglview.NGLWidget(structure, **kwargs)
def show_ob_traj(p,l,r, **kwargs):
extension = 'pdb'
structure_trajectory = nglview.ODDTTrajectory(p,l,r)
return nglview.NGLWidget(structure_trajectory, **kwargs)
nglview.ODDTTrajectory=oddt_trajectory
nglview.OBStructure = ob_structure
nglview.show_ob_structure=show_ob_structure
#create objects for ligand(s) and protein
mol = oddt.toolkit.readstring('smi', 'c1cccc(O)c1')
if not mol.OBMol.Has3D():
mol.make3D(forcefield='mmff94', steps=150)
mol.localopt()
print mol.energy
mol.removeh()
mol.OBMol.AddPolarHydrogens()
prot = oddt.toolkit.readfile('pdb','/tmp/1lmp.pdb').next()
# some print
print prot.protein, prot.molwt
print mol, mol.molwt
mol
#create docking object
dock_obj= oddt.docking.AutodockVina.autodock_vina(
protein=prot,size=(20,20,20),center=(42.0,48.0,30.0),
executable='/usr/bin/vina',autocleanup=False, num_modes=20)
# do docking
res = dock_obj.dock([mol],prot)
# show 3D results
pres = [
{"type": "ball+stick", "params": {
"sele": "all"
}}
]
w3 = show_ob_traj(prot,res[0],res)
w3.representations = pres
w3
# print some data
for r in res:
print "%8.3f%8.3f\n" %(float(r.data['vina_rmsd_ub']),float(r.data['vina_affinity']))
# print docking params
" ".join(dock_obj.params)