{ "cells": [ { "cell_type": "markdown", "id": "98a65e59-67fa-492c-89ce-9e18fc12fed3", "metadata": {}, "source": [ "# Virtual Screening\n", "\n", "This notebook aims to demonstrate how to use AutoDock Vina (via Smina) and Ledock to dock multiple molecules in the same protein target and binding site. \n", "\n", "## Content of this notebook\n", "\n", "1. Feching system and cleanup\n", "2. System Visualization \n", "3. Docking with Smina\n", " - Receptor preparation\n", " - Ligand preparation\n", " - Docking box definition\n", " - Docking\n", " - 3D visualization of docking results\n", "4. Docking with LeDock\n", " - Receptor preparation\n", " - Ligand preparation\n", " - Docking box definition\n", " - Docking\n", " - DOK results file conversion to SDF\n", " - 3D visualization of docking results" ] }, { "cell_type": "code", "execution_count": 1, "id": "15b2c953-805a-4ff9-8095-a612df9629cd", "metadata": {}, "outputs": [], "source": [ "from pymol import cmd\n", "import py3Dmol\n", "\n", "from openbabel import pybel\n", "\n", "from rdkit import Chem\n", "from rdkit.Chem import AllChem\n", "\n", "import sys, os, random\n", "sys.path.insert(1, 'utilities/')\n", "\n", "from utils import getbox, generate_ledock_file, dok_to_sdf\n", "\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")\n", "\n", "%config Completer.use_jedi = False" ] }, { "cell_type": "code", "execution_count": 2, "id": "d8d7b03b-9b00-4ef8-947f-eefb350825db", "metadata": {}, "outputs": [], "source": [ "os.chdir('test/Virtual_Screening/')" ] }, { "cell_type": "markdown", "id": "c7fe56ca-6510-4892-9b7f-fd713744663d", "metadata": {}, "source": [ "## 1. Feching system and cleanup\n", "\n", "Implementing Pymol is a simple way to download PDB structures. The user can launch this or any other Jupyter Dock's protocol by providing his or her own files." ] }, { "cell_type": "code", "execution_count": 3, "id": "80ac6b11-21f7-4a27-82a5-e59e5ba3c0b1", "metadata": {}, "outputs": [], "source": [ "cmd.fetch(code='1X1R',type='pdb1')\n", "cmd.select(name='Prot',selection='polymer.protein')\n", "cmd.select(name='GDP',selection='organic')\n", "cmd.save(filename='1X1R_clean.pdb',format='pdb',selection='Prot')\n", "cmd.save(filename='1X1R_GDP.mol2',format='mol2',selection='GDP')\n", "cmd.delete('all')" ] }, { "cell_type": "markdown", "id": "bc5119bd-ab15-4952-accd-806dcba8df07", "metadata": {}, "source": [ "## 2. System Visualization\n", "\n", "A cool feature of Jupyter Dock is the posibility of visualize ligand-protein complexes and docking results into the notebbok. All this thanks to the powerful py3Dmol. \n", "\n", "Now the protein and ligand have been sanitized it would be recomended to vissualize the ligand-protein reference system." ] }, { "cell_type": "code", "execution_count": 4, "id": "1d90faf9-b7c1-4808-b5cc-c37e1849a2cf", "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "view = py3Dmol.view()\n", "view.removeAllModels()\n", "view.setViewStyle({'style':'outline','color':'black','width':0.1})\n", "\n", "view.addModel(open('1X1R_clean.pdb','r').read(),format='pdb')\n", "Prot=view.getModel()\n", "Prot.setStyle({'cartoon':{'arrows':True, 'tubes':True, 'style':'oval', 'color':'white'}})\n", "view.addSurface(py3Dmol.VDW,{'opacity':0.6,'color':'white'})\n", "\n", "view.addModel(open('1X1R_GDP.mol2','r').read(),format='mol2')\n", "ref_m = view.getModel()\n", "ref_m.setStyle({},{'stick':{'colorscheme':'greenCarbon','radius':0.2}})\n", "\n", "view.zoomTo()\n", "view.show()" ] }, { "cell_type": "markdown", "id": "93fbce64-ba7a-4ccf-8ed1-26267aa3f5a0", "metadata": {}, "source": [ "## 3. Docking with Smina\n", "\n", "Despite the presence of Python bindings in AutoDock Vina 1.2.0, other tools that incorporate AutoDock Vina allow for cool features such as custom score functions (smina), fast execution (qvina), and the use of wider boxes (qvina-w). Jupyter Dock can run such binaries in a notebook, giving users more options.\n", "\n", "Smina is a fork of AutoDock Vina that is customized to better support scoring function development and high-performance energy minimization. Smina is maintained by David Koes at the University of Pittsburgh and is not directly affiliated with the AutoDock project.\n", "\n", ">**Info:** The following cell contains an example of using Smina to run the current docking example. However, the executable files for qvina and qvina-w are available in the Jupyter Dock repo's bin directory. As a result, the user can use such a tool by adding the necessary cells or replacing the current docking engine.\n", "\n", "### 3.1. Receptor preparation\n", "\n", "Despite the fact that Smina is a modified version of AutoDock Vina, the input file for a receptor in Smina can be either a PDBQT file or a PDB file with explicit hydrogens in all residues. At this point, we can make use ofca protein structure from Jupyter Dock's _**fix_protein()**_ function or implementing LePro (for more information, see the 2.1 section of the Molecular Docking notebook). " ] }, { "cell_type": "code", "execution_count": 5, "id": "350a7304-09da-4032-8d4f-a4279c58d490", "metadata": {}, "outputs": [], "source": [ "!../../bin/lepro_linux_x86 {'1X1R_clean.pdb'}\n", "\n", "os.rename('pro.pdb','1X1R_clean_H.pdb') # Output from lepro is pro.pdb, this line will change the name to '1X1R_clean_H.pdb'" ] }, { "cell_type": "markdown", "id": "03fc33d2-2afe-406b-9d8a-176cecc71a9e", "metadata": {}, "source": [ "### 3.2. Ligand preparation\n", "\n", "The ligand molecules in Virtual Screening protocols could come from a variety of sources (i.e. [ZINC15](https://zinc15.docking.org/), [PubChem](https://pubchem.ncbi.nlm.nih.gov/), [DrugBank](https://go.drugbank.com/), etc) and diverse formats (i.e. SDF, PDB, MOL, MOL2, SMILES, etc). The cell below depicts one of the simplest approaches to using molecules from SMILES codes. Users, however, can use any known chemical format in their molecules thanks to the use of PyBel and RDKit.\n", "\n", "Regardless of the format of the molecules or the differences between docking algorithms, ligand preparation must achieve at least the following objectives:\n", "\n", "- Set the proper protonation and tautomeric state to the molecules.\n", "- Provide a valid 3D structure to initialize the conformational search.\n", "\n", "Jupyter Dock generates protonated neutral molecules and performs energy minimization under the MMFF94s force field using the pybel functions _make3D_ and _localopt_, respectively.\n", "\n", "It is recommended that users tune the pybel settings or use other preparation methods before running the molecular docking for special ligand needs." ] }, { "cell_type": "code", "execution_count": 6, "id": "c19e4a1d-ad27-457f-a56f-e7c6ed3050d1", "metadata": {}, "outputs": [], "source": [ "smiles=['C1=NC(=C2C(=N1)N(C=N2)CCOCP(=O)(O)O)N',\n", " 'C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)O)O)O)N',\n", " 'C[C@@H](C1=CC2=C(C(=CC=C2)Cl)C(=O)N1C3=CC=CC=C3)NC4=NC=NC5=C4NC=N5',\n", " 'C1=NC(=C2C(=N1)N(C=N2)C3C(C(C(O3)CO)O)O)N',\n", " 'C[C@H](CN1C=NC2=C(N=CN=C21)N)OC[P@@](=O)(N[C@@H]',\n", " 'C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)C[C@H](CC[C@@H](C(=O)O)N)N)O)O)N',\n", " 'C[S+](CC[C@@H](C(=O)O)N)C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O',\n", " 'CN1C=C(C(=N1)OC)NC2=C3C(=NC(=N2)N4C[C@H]([C@@H](C4)F)NC(=O)C=C)N(C=N3)C',\n", " 'C1COC[C@@H]1NC2=C3C(=NC=N2)N(C=N3)[C@H]4[C@@H]([C@@H]([C@H](O4)CO)O)O']" ] }, { "cell_type": "code", "execution_count": 7, "id": "afc6ac99-2b15-4076-99af-971f81a3a67e", "metadata": {}, "outputs": [], "source": [ "out=pybel.Outputfile(filename='InputMols.mol2',format='mol2',overwrite=True)\n", "for index,smi in enumerate(smiles):\n", " mol=pybel.readstring(string=smi,format='smiles')\n", " mol.title='mol_'+str(index)\n", " mol.make3D('mmff94s')\n", " mol.localopt(forcefield='mmff94s', steps=500)\n", " out.write(mol)\n", "out.close()" ] }, { "cell_type": "markdown", "id": "7b73e3ae-77ad-43c1-8b97-74bc82bb1baf", "metadata": {}, "source": [ "### 3.3. Docking box definition\n", "\n", "In this example, the natural ligand GDP of 1X1R will be used as a reference for box definition (Section 4.3 of the Molecular Docking Notebook contains more information about the _**getbox()**_ function)." ] }, { "cell_type": "code", "execution_count": 8, "id": "d06e91d4-f7af-46f2-a85e-1001b071bf7a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'center_x': 3.4204999953508377, 'center_y': 9.91599988937378, 'center_z': 11.27299976348877}\n", "{'size_x': 19.56700000166893, 'size_y': 18.30399990081787, 'size_z': 23.20599937438965}\n" ] } ], "source": [ "cmd.load(filename='1X1R_clean_H.pdb',format='pdb',object='prot') #Not needed but as reference of the system\n", "cmd.load(filename='1X1R_GDP.mol2',format='mol2',object='lig')\n", "\n", "center,size=getbox(selection='lig',extending=6.0,software='vina')\n", "cmd.delete('all')\n", "print(center)\n", "print(size)" ] }, { "cell_type": "markdown", "id": "55a12b38-09f1-41ef-a425-f3a602860c97", "metadata": {}, "source": [ "### 3.4. Docking\n", "\n", "Jupyter Dock comes with the smina executable for Linux and Mac OS. By running the binary file, the parameters can be accessed.\n", "\n", ">**Hint:** Smina also has the ability to use a multimodel file as input and then save the results to a single multimodel output file. Furthermore, the input and output molecule files can be tar.gz. sdf files, which is very useful when working with large databases." ] }, { "cell_type": "code", "execution_count": 9, "id": "bcf14750-d5af-474a-823b-089757c0f244", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " _______ _______ _________ _ _______ \n", " ( ____ \\( )\\__ __/( ( /|( ___ )\n", " | ( \\/| () () | ) ( | \\ ( || ( ) |\n", " | (_____ | || || | | | | \\ | || (___) |\n", " (_____ )| |(_)| | | | | (\\ \\) || ___ |\n", " ) || | | | | | | | \\ || ( ) |\n", " /\\____) || ) ( |___) (___| ) \\ || ) ( |\n", " \\_______)|/ \\|\\_______/|/ )_)|/ \\|\n", "\n", "\n", "smina is based off AutoDock Vina. Please cite appropriately.\n", "\n", "Weights Terms\n", "-0.035579 gauss(o=0,_w=0.5,_c=8)\n", "-0.005156 gauss(o=3,_w=2,_c=8)\n", "0.840245 repulsion(o=0,_c=8)\n", "-0.035069 hydrophobic(g=0.5,_b=1.5,_c=8)\n", "-0.587439 non_dir_h_bond(g=-0.7,_b=0,_c=8)\n", "1.923 num_tors_div\n", "\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -7.1 0.000 0.000 \n", "2 -7.0 4.222 6.100 \n", "3 -7.0 3.803 5.854 \n", "4 -7.0 2.995 4.131 \n", "5 -6.8 3.922 5.301 \n", "Refine time 8.195\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -9.8 0.000 0.000 \n", "2 -9.6 1.308 1.743 \n", "3 -9.0 4.473 7.254 \n", "4 -8.9 1.608 2.661 \n", "5 -8.5 1.643 2.583 \n", "Refine time 12.469\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -9.4 0.000 0.000 \n", "2 -9.1 2.616 5.000 \n", "3 -8.6 3.401 5.918 \n", "4 -8.0 4.080 6.302 \n", "5 -7.9 3.441 6.072 \n", "Refine time 19.370\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -8.1 0.000 0.000 \n", "2 -7.7 2.135 3.224 \n", "3 -7.7 3.180 6.236 \n", "4 -7.7 2.006 2.895 \n", "5 -7.5 2.097 2.856 \n", "Refine time 6.438\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -7.1 0.000 0.000 \n", "2 -7.0 3.900 8.314 \n", "3 -6.9 3.468 4.357 \n", "4 -6.8 3.781 8.216 \n", "5 -6.6 3.234 7.536 \n", "Refine time 10.387\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -10.1 0.000 0.000 \n", "2 -9.2 1.325 2.123 \n", "3 -8.9 2.481 8.154 \n", "4 -8.5 2.389 8.169 \n", "5 -8.1 3.390 8.328 \n", "Refine time 30.488\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -10.0 0.000 0.000 \n", "2 -8.9 1.616 2.461 \n", "3 -8.8 1.062 1.897 \n", "4 -8.8 2.865 8.326 \n", "5 -8.1 2.755 3.488 \n", "Refine time 29.620\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -8.0 0.000 0.000 \n", "2 -7.9 2.517 7.369 \n", "3 -7.9 2.125 7.234 \n", "4 -7.4 2.469 4.642 \n", "5 -7.2 3.771 6.174 \n", "Refine time 29.695\n", "Using random seed: 1174223054\n", "\n", "0% 10 20 30 40 50 60 70 80 90 100%\n", "|----|----|----|----|----|----|----|----|----|----|\n", "***************************************************\n", "\n", "mode | affinity | dist from best mode\n", " | (kcal/mol) | rmsd l.b.| rmsd u.b.\n", "-----+------------+----------+----------\n", "1 -8.9 0.000 0.000 \n", "2 -8.0 2.301 7.375 \n", "3 -8.0 2.840 7.385 \n", "4 -7.8 2.884 7.425 \n", "5 -7.7 2.384 3.749 \n", "Refine time 13.313\n", "Loop time 172.436\n" ] } ], "source": [ "!../../bin/smina -r {'1X1R_clean_H.pdb'} -l {'InputMols.mol2'} -o {'1X1R_lig_smina_out.sdf'} --center_x {center['center_x']} --center_y {center['center_y']} --center_z {center['center_z']} --size_x {size['size_x']} --size_y {size['size_y']} --size_z {size['size_z']} --exhaustiveness 8 --num_modes 5" ] }, { "cell_type": "markdown", "id": "dd315fa7-a93a-4007-bc9c-52d6526456ba", "metadata": {}, "source": [ "### 3.5. 3D visualization of docking results\n", "\n", "As with the system visualization (section 2), the docking results can be inspected and compared to the reference structure (if one exists). Smina saves the \"minimizedAffinity\" information corresponding to the docking score as the molecule's attribute." ] }, { "cell_type": "code", "execution_count": 10, "id": "202ab6a3-0f1e-43c6-84f2-02017e6f67be", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "mol_0 Score: -7.07914\n", "mol_1 Score: -9.79016\n", "mol_2 Score: -9.37383\n", "mol_3 Score: -8.05686\n", "mol_4 Score: -7.05481\n", "mol_5 Score: -10.09781\n", "mol_6 Score: -9.98733\n", "mol_7 Score: -8.02271\n", "mol_8 Score: -8.91059\n" ] }, { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "view = py3Dmol.view()\n", "view.removeAllModels()\n", "view.setViewStyle({'style':'outline','color':'black','width':0.1})\n", "\n", "view.addModel(open('1X1R_clean_H.pdb','r').read(),'pdb')\n", "Prot=view.getModel()\n", "Prot.setStyle({'cartoon':{'arrows':True, 'tubes':True, 'style':'oval', 'color':'white'}})\n", "view.addSurface(py3Dmol.VDW,{'opacity':0.8,'color':'white'})\n", "\n", "\n", "view.addModel(open('1X1R_GDP.mol2','r').read(),'mol2')\n", "ref_m = view.getModel()\n", "ref_m.setStyle({},{'stick':{'colorscheme':'greenCarbon','radius':0.2}})\n", "\n", "\n", "poses=Chem.SDMolSupplier('1X1R_lig_smina_out.sdf',True)\n", "for p in list(poses)[::5]:\n", " pose_1=Chem.MolToMolBlock(p)\n", " print(p.GetProp('_Name'),'Score: {}'.format(p.GetProp('minimizedAffinity')))\n", " color = [\"#\"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])]\n", " view.addModel(pose_1,'mol')\n", " z= view.getModel()\n", " z.setStyle({},{'stick':{'color':color[0],'radius':0.05,'opacity':0.6}})\n", "\n", "view.zoomTo()\n", "view.show()" ] }, { "cell_type": "markdown", "id": "12bc2c09-2ac6-4c70-9d07-3b256359d496", "metadata": {}, "source": [ "## 4. Docking with LeDock\n", "\n", "LeDock is designed for fast and accurate flexible docking of small molecules into a protein. It achieves a pose-prediction accuracy of greater than 90% on the Astex diversity set and takes about 3 seconds per run for a drug-like molecule. It has led to the discovery of novel kinase inhibitors and bromodomain antagonists from high-throughput virtual screening campaigns. It directly uses SYBYL Mol2 format as input for small molecules.\n", "\n", "### 4.1. Receptor preparation\n", "\n", "In LeDock, the input file for a receptor is a PDB file with explicit hydrogens in all residues. LePro was created as a tool for preparing protein structures for docking with LeDock. Thus, at this stage, we can use the file ater sanitization steps as well as a protein structure from Jupyter Dock's _**fix_protein()**_ function or implementing LePro (for more information, see the 2.1 section of the Molecular Docking notebook).\n", "\n", "### 4.2. Ligand preparation\n", "\n", "MOL2 is the ligand input format in LeDock. LeDock, on the other hand, cannot accept a multimodel MOL2 file as an input. To use LeDock, we can run the preparation in the same way as Smina (section 3.2), but generate one MOL2 file per ligand." ] }, { "cell_type": "code", "execution_count": 11, "id": "4ceef1ed-2759-4b08-a3a8-0cf3ab840b0e", "metadata": {}, "outputs": [], "source": [ "smiles=['C1=NC(=C2C(=N1)N(C=N2)CCOCP(=O)(O)O)N',\n", " 'C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)COP(=O)(O)O)O)O)N',\n", " 'C[C@@H](C1=CC2=C(C(=CC=C2)Cl)C(=O)N1C3=CC=CC=C3)NC4=NC=NC5=C4NC=N5',\n", " 'C1=NC(=C2C(=N1)N(C=N2)C3C(C(C(O3)CO)O)O)N',\n", " 'C[C@H](CN1C=NC2=C(N=CN=C21)N)OC[P@@](=O)(N[C@@H]',\n", " 'C1=NC(=C2C(=N1)N(C=N2)[C@H]3[C@@H]([C@@H]([C@H](O3)C[C@H](CC[C@@H](C(=O)O)N)N)O)O)N',\n", " 'C[S+](CC[C@@H](C(=O)O)N)C[C@@H]1[C@H]([C@H]([C@@H](O1)N2C=NC3=C(N=CN=C32)N)O)O',\n", " 'CN1C=C(C(=N1)OC)NC2=C3C(=NC(=N2)N4C[C@H]([C@@H](C4)F)NC(=O)C=C)N(C=N3)C',\n", " 'C1COC[C@@H]1NC2=C3C(=NC=N2)N(C=N3)[C@H]4[C@@H]([C@@H]([C@H](O4)CO)O)O']" ] }, { "cell_type": "code", "execution_count": 12, "id": "471b384d-ceb2-407a-8edb-56b983bcb14b", "metadata": {}, "outputs": [], "source": [ "for index,smi in enumerate(smiles):\n", " mol=pybel.readstring(string=smi,format='smiles')\n", " mol.title='mol_'+str(index)\n", " mol.make3D('mmff94s')\n", " mol.localopt(forcefield='mmff94s', steps=500)\n", " out=pybel.Outputfile(filename='ledock_inputfiles/'+'mol_'+str(index)+'.mol2',format='mol2',overwrite=True)\n", " out.write(mol)\n", " out.close()" ] }, { "cell_type": "markdown", "id": "75eb861c-e09e-4ae1-b186-fb3298597e28", "metadata": {}, "source": [ "### 4.3. Docking box definition\n", "\n", "This step can be completed in the same manner as the Smina box definition (section 3.3). To obtain the identical box from Smina docking but in LeDock format, the user only needs to change the parameter \"software\" from \"vina\" to \"ledock.\" \n", "\n", ">**Info:** The implementation of the _**getbox()**_ function allows for the easy replication of binding sites between AutoDock Vina and LeDock, with the goal of replicating and comparing results between both programs." ] }, { "cell_type": "code", "execution_count": 13, "id": "90a386aa-c5cc-4b41-a898-0fea4ec6b136", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'minX': -6.363000005483627, 'maxX': 13.203999996185303}\n", "{'minY': 0.7639999389648438, 'maxY': 19.067999839782715}\n", "{'minZ': -0.3299999237060547, 'maxZ': 22.875999450683594}\n" ] } ], "source": [ "cmd.load(filename='1X1R_clean_H.pdb',format='pdb',object='prot')\n", "cmd.load(filename='1X1R_GDP.mol2',format='mol2',object='lig')\n", "\n", "X,Y,Z=getbox(selection='lig',extending=6.0,software='ledock')\n", "cmd.delete('all')\n", "print(X)\n", "print(Y)\n", "print(Z)" ] }, { "cell_type": "markdown", "id": "80a54294-2a60-4ac8-9e70-ba5bc142983e", "metadata": {}, "source": [ "### 4.4 Docking\n", "\n", "Aside from one file per ligand, Ledock requires the user to create a file containing the docking paths for the ligands (ligand.list in Jupyter Dock). This file can be easily created by using the following cell and the _**generate_ledock_file()**_ function." ] }, { "cell_type": "code", "execution_count": 14, "id": "fa425610-28a7-4d67-a2e7-ebe3003fff78", "metadata": {}, "outputs": [], "source": [ "l_list=[]\n", "for file in os.listdir('ledock_inputfiles/'):\n", " if 'mol2' in file:\n", " l_list.append('ledock_inputfiles/'+file+'\\n')" ] }, { "cell_type": "code", "execution_count": 15, "id": "bb1b5936-9ccf-47aa-952c-25dcff70eca9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['ledock_inputfiles/mol_0.mol2\\n',\n", " 'ledock_inputfiles/mol_1.mol2\\n',\n", " 'ledock_inputfiles/mol_2.mol2\\n',\n", " 'ledock_inputfiles/mol_3.mol2\\n',\n", " 'ledock_inputfiles/mol_4.mol2\\n',\n", " 'ledock_inputfiles/mol_5.mol2\\n',\n", " 'ledock_inputfiles/mol_6.mol2\\n',\n", " 'ledock_inputfiles/mol_7.mol2\\n',\n", " 'ledock_inputfiles/mol_8.mol2\\n']" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "l_list" ] }, { "cell_type": "code", "execution_count": 16, "id": "cada4bcd-fd16-4c72-bc82-b9e96875000e", "metadata": {}, "outputs": [], "source": [ "generate_ledock_file(receptor='1X1R_clean_H.pdb',l_list=l_list,\n", " l_list_outfile='ligand.list',\n", " x=[X['minX'],X['maxX']],\n", " y=[Y['minY'],Y['maxY']],\n", " z=[Z['minZ'],Z['maxZ']],\n", " n_poses=10,\n", " rmsd=1.0,\n", " out='dock.in')" ] }, { "cell_type": "markdown", "id": "c36c8cc4-bc3a-4740-8a84-2efa6ab47f27", "metadata": {}, "source": [ "Once all of the docking parameters have been entered into a configuration file (dock.in), everything is ready to go." ] }, { "cell_type": "code", "execution_count": 17, "id": "22b68a10-7525-432b-a56b-c5b24386e229", "metadata": {}, "outputs": [], "source": [ "!../../bin/ledock_linux_x86 {'dock.in'}" ] }, { "cell_type": "markdown", "id": "55d81e6b-6251-4a43-8229-2c5903bc7cf3", "metadata": {}, "source": [ "### 4.5. DOK results file conversion to SDF\n", "\n", "LeDock produces a file with the dok extension that contains docking properties in the same way that a pdb file does. Despite this, the dok file is not widely used for representing chemical structures. As a result, Jupyter Dock is capable of converting dok files to the widely used sdf format. Jupyter Dock will save the \"Pose\" and \"Score\" results as molecule attributes while preserving the chemical features (more information in section 6.5 of the Molecular Docking notebook)." ] }, { "cell_type": "code", "execution_count": 18, "id": "d0e40a20-5562-4853-b5fb-4c871fd1ff89", "metadata": {}, "outputs": [], "source": [ "for file in os.listdir('ledock_inputfiles/'):\n", " if '.dok' in file:\n", " os.rename('ledock_inputfiles/'+file,'ledock_outfiles/'+file)\n", " dok_to_sdf(dok_file='ledock_outfiles/'+file,output='ledock_outfiles/'+file.replace('dok','sdf'))" ] }, { "cell_type": "markdown", "id": "248e4528-5db0-4bab-84fa-727ff5461539", "metadata": {}, "source": [ "### 4.5. 3D visualization of docking results\n", "\n", "As with the system visualization (section 2), the docking results can be inspected and compared to the reference structure (if one exists)." ] }, { "cell_type": "code", "execution_count": 19, "id": "b4dd622e-6122-436a-b1e8-b15c5b873f95", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Name: mol_0 | Pose: 2 | Score: -7.91\n", "Name: mol_1 | Pose: 5 | Score: -9.55\n", "Name: mol_2 | Pose: 3 | Score: -7.84\n", "Name: mol_3 | Pose: 1 | Score: -7.08\n", "Name: mol_4 | Pose: 1 | Score: -7.51\n", "Name: mol_5 | Pose: 2 | Score: -9.46\n", "Name: mol_6 | Pose: 4 | Score: -9.99\n", "Name: mol_7 | Pose: 1 | Score: -8.42\n", "Name: mol_8 | Pose: 2 | Score: -7.16\n" ] }, { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "view = py3Dmol.view()\n", "view.removeAllModels()\n", "view.setViewStyle({'style':'outline','color':'black','width':0.1})\n", "\n", "view.addModel(open('1X1R_clean_H.pdb','r').read(),'pdb')\n", "Prot=view.getModel()\n", "Prot.setStyle({'cartoon':{'arrows':True, 'tubes':True, 'style':'oval', 'color':'white'}})\n", "view.addSurface(py3Dmol.VDW,{'opacity':0.8,'color':'white'})\n", "\n", "\n", "view.addModel(open('1X1R_GDP.mol2','r').read(),'mol2')\n", "ref_m = view.getModel()\n", "ref_m.setStyle({},{'stick':{'colorscheme':'greenCarbon','radius':0.2}})\n", "\n", "for file in os.listdir('ledock_outfiles/'):\n", " if 'sdf' in file:\n", " pose_1=Chem.SDMolSupplier('ledock_outfiles/'+file,False)[0]\n", " p=Chem.MolToMolBlock(pose_1)\n", " print('Name: {} | Pose: {} | Score: {}'.format(file.split('.')[0],pose_1.GetProp('Pose'),pose_1.GetProp('Score')))\n", " color = [\"#\"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])]\n", " view.addModel(p,'mol')\n", " z= view.getModel()\n", " z.setStyle({},{'stick':{'color':color[0],'radius':0.05,'opacity':0.6}})\n", "\n", "view.zoomTo()\n", "view.show()" ] }, { "cell_type": "markdown", "id": "ff678e62-ed9a-49a2-9108-eba661c0fced", "metadata": {}, "source": [ ".. disqus::" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 5 }