{ "cells": [ { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "# Exploring conformational space of selected macrocycles - notes\n", "\n", "In this notebook we present and analyze selected structures, technical notes are [here](www.gitlab.com/user/gosia/icho)." ] }, { "cell_type": "code", "execution_count": 297, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "\n", "
" ], "text/plain": [ "" ] }, "execution_count": 297, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.display import HTML\n", "\n", "HTML('''\n", "
''')" ] }, { "cell_type": "code", "execution_count": 298, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2016.09.4\n", "Tue Mar 28 15:42:19 2017\n" ] } ], "source": [ "import glob\n", "import py3Dmol\n", "\n", "from rdkit import Chem\n", "from rdkit.Chem import AllChem\n", "from rdkit.Chem import Draw\n", "from rdkit.Chem import rdMolAlign\n", "from rdkit import rdBase\n", "print(rdBase.rdkitVersion)\n", "import os,time\n", "print( time.asctime())" ] }, { "cell_type": "code", "execution_count": 299, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Functions used in this notebook:\n", "def grep_energies_from_sdf_outputs(files):\n", " energies = []\n", " for inp in files:\n", " with open(inp,'r') as f:\n", " lines = f.readlines()\n", " for i, line in enumerate(lines):\n", " if \"M END\" in line:\n", " energies.append(float(lines[i+1]))\n", " return energies" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## \"M1\" macrocycle" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "The crystallographic structure of \"M1\" (shown below) was used as a starting geometry for generating various conformers." ] }, { "cell_type": "code", "execution_count": 300, "metadata": { "collapsed": false, "deletable": true, "editable": true, "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 300, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cm1 = open('/home/gosia/work/work_on_gitlab/icho/calcs/m1/m1_crystal.xyz','r').read()\n", "vcm1 = py3Dmol.view(width=400,height=400)\n", "vcm1.removeAllModels()\n", "vcm1.addModel(cm1,'xyz')\n", "vcm1.setStyle({'stick':{'radius':0.15,'color':'spectrum'}})\n", "vcm1.setBackgroundColor('0xeeeeee')\n", "vcm1.zoomTo()\n", "vcm1.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also read it in in smiles and sdf formats (both will be used below):" ] }, { "cell_type": "code", "execution_count": 301, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# decide what is the \"core\" - a part of molecule, which we wish to be most aligned (rmsd-wise) among all the structures\n", "# here: pyridine ring\n", "m1 = Chem.AddHs(Chem.MolFromSmiles('O=C1NCCNC(=O)c2nc(C(=O)NCCNC(=O)c3nc1ccc3)ccc2'))\n", "core_m1 = m1.GetSubstructMatch(Chem.MolFromSmiles('n1ccccc1'))" ] }, { "cell_type": "code", "execution_count": 302, "metadata": { "collapsed": true }, "outputs": [], "source": [ "templ_m1 = Chem.SDMolSupplier('/home/gosia/work/work_on_gitlab/icho/calcs/m1/balloon/m1_crystal.sdf')\n", "m1_crystal = templ_m1[0]" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Conformers generated with the Balloon software:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Description: [notes](link-to)" ] }, { "cell_type": "code", "execution_count": 303, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "inps_m1_balloon = glob.glob('/home/gosia/work/work_on_gitlab/icho/calcs/m1/balloon/results_crystal/*.sdf')" ] }, { "cell_type": "code", "execution_count": 304, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "e_m1_balloon = grep_energies_from_sdf_outputs(inps_m1_balloon)" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "Conformers:" ] }, { "cell_type": "code", "execution_count": 305, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m1_b1, E = m1_b2, E = m1_b3, E =
m1_b4, E = m1_b5, E = m1_b6, E =
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m1_b1, E = m1_b2, E = m1_b3, E =
m1_b4, E = m1_b5, E = m1_b6, E =
" ] }, { "cell_type": "code", "execution_count": 306, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "p1_b_handles=[]\n", "for inp in inps_m1_balloon:\n", " f1_b = open(inp, 'r').read()\n", " p1_b = py3Dmol.view(width=200,height=200)\n", " p1_b.removeAllModels()\n", " p1_b.addModel(f1_b,'sdf')\n", " p1_b.setStyle({'stick':{}})\n", " p1_b.setBackgroundColor('0xeeeeee')\n", " p1_b.zoomTo()\n", " p1_b_handles.append(p1_b)" ] }, { "cell_type": "code", "execution_count": 307, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 307, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_b_handles[0].insert('m1_b1')" ] }, { "cell_type": "code", "execution_count": 308, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 308, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_b_handles[1].insert('m1_b2')" ] }, { "cell_type": "code", "execution_count": 309, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 309, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_b_handles[2].insert('m1_b3')" ] }, { "cell_type": "code", "execution_count": 310, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 310, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_b_handles[3].insert('m1_b4')" ] }, { "cell_type": "code", "execution_count": 311, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 311, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_b_handles[4].insert('m1_b5')" ] }, { "cell_type": "code", "execution_count": 312, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 312, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_b_handles[5].insert('m1_b6')" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "We can now try to align all these structures (together with the crystal structure):" ] }, { "cell_type": "code", "execution_count": 313, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# write conformers as a list\n", "allmol_m1_balloon = []\n", "suppl_m1_balloon = Chem.SDMolSupplier('/home/gosia/work/work_on_gitlab/icho/calcs/m1/balloon/m1_crystal_out.sdf')\n", "\n", "# add crystal structure to the list:\n", "allmol_m1_balloon.append(m1_crystal)\n", "for mol in suppl_m1_balloon:\n", " allmol_m1_balloon.append(mol)" ] }, { "cell_type": "code", "execution_count": 314, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# align:\n", "for mol in allmol_m1_balloon:\n", " AllChem.AlignMolConformers(mol,atomIds=core_m1)" ] }, { "cell_type": "code", "execution_count": 315, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 315, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# view:\n", "p = py3Dmol.view(width=400,height=400)\n", "p.removeAllModels()\n", "for mol in allmol_m1_balloon:\n", " mb = Chem.MolToMolBlock(mol)\n", " p.addModel(mb,'sdf')\n", "p.setStyle({'stick':{'radius':'0.15'}})\n", "p.setBackgroundColor('0xeeeeee')\n", "p.zoomTo()\n", "p.show()" ] }, { "cell_type": "code", "execution_count": 316, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Heavy Atom RMS: 3.604550104229233e-07\n", "Heavy Atom RMS: 0.6621220451255674\n", "Heavy Atom RMS: 0.5174150250164391\n", "Heavy Atom RMS: 1.1744423515041509\n", "Heavy Atom RMS: 0.527526310182849\n", "Heavy Atom RMS: 0.8526332845365369\n", "Heavy Atom RMS: 0.8800960083230364\n" ] } ], "source": [ "# calculate RMSD /check that/:\n", "for mol in allmol_m1_balloon:\n", " # note that the first structure on \"allmol_m1_rdkit\" list is the crystal structure, \n", " # so the RMSD value calculated for the first structure (with respect to the crystal) will be 0 or almost 0\n", " print(\"Heavy Atom RMS:\",AllChem.GetBestRMS(Chem.RemoveHs(mol),Chem.RemoveHs(templ_m1[0])))" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Conformers generated with the RDKit software:" ] }, { "cell_type": "code", "execution_count": 317, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# create a list of all structures to be aligned\n", "allmol_m1_rdkit = []\n", "suppl_m1_rdkit = Chem.SDMolSupplier('/home/gosia/work/work_on_gitlab/icho/calcs/m1/rdkit/result_smiles_new.sdf')\n", "\n", "# add crystal structure to the list:\n", "#allmol_m1_rdkit.append(m1_crystal)\n", "for mol in suppl_m1_rdkit:\n", " allmol_m1_rdkit.append(mol)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "View conformers:" ] }, { "cell_type": "code", "execution_count": 318, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m1_r1, E = m1_r2, E = m1_r3, E =
m1_r4, E = m1_r5, E = m1_r6, E =
m1_r7, E = m1_r8, E = m1_r9, E =
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m1_r1, E = m1_r2, E = m1_r3, E =
m1_r4, E = m1_r5, E = m1_r6, E =
m1_r7, E = m1_r8, E = m1_r9, E =
" ] }, { "cell_type": "code", "execution_count": 319, "metadata": { "collapsed": true }, "outputs": [], "source": [ "inps_m1_rdkit = glob.glob('/home/gosia/work/work_on_gitlab/icho/calcs/m1/rdkit/results_crystal_from_smiles_new/*.sdf')\n", "p1_r_handles=[]\n", "for inp in inps_m1_rdkit:\n", " f1_r = open(inp, 'r').read()\n", " p1_r = py3Dmol.view(width=200,height=200)\n", " p1_r.removeAllModels()\n", " p1_r.addModel(f1_r,'sdf')\n", " p1_r.setStyle({'stick':{}})\n", " p1_r.setBackgroundColor('0xeeeeee')\n", " p1_r.zoomTo()\n", " p1_r_handles.append(p1_r)" ] }, { "cell_type": "code", "execution_count": 320, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 320, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[0].insert('m1_r1')" ] }, { "cell_type": "code", "execution_count": 321, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 321, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[1].insert('m1_r2')" ] }, { "cell_type": "code", "execution_count": 322, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 322, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[2].insert('m1_r3')" ] }, { "cell_type": "code", "execution_count": 323, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 323, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[3].insert('m1_r4')" ] }, { "cell_type": "code", "execution_count": 324, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 324, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[4].insert('m1_r5')" ] }, { "cell_type": "code", "execution_count": 325, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 325, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[5].insert('m1_r6')" ] }, { "cell_type": "code", "execution_count": 326, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 326, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[6].insert('m1_r7')" ] }, { "cell_type": "code", "execution_count": 327, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 327, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[7].insert('m1_r8')" ] }, { "cell_type": "code", "execution_count": 328, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 328, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p1_r_handles[8].insert('m1_r9')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now align all these structures:" ] }, { "cell_type": "code", "execution_count": 329, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# align:\n", "for mol in allmol_m1_rdkit:\n", " AllChem.AlignMolConformers(mol,atomIds=core_m1)" ] }, { "cell_type": "code", "execution_count": 330, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 330, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# view:\n", "p = py3Dmol.view(width=400,height=400)\n", "p.removeAllModels()\n", "for mol in allmol_m1_rdkit: \n", " mb = Chem.MolToMolBlock(mol)\n", " p.addModel(mb,'sdf') \n", "p.setStyle({'stick':{'radius':'0.15'}})\n", "p.setBackgroundColor('0xeeeeee')\n", "p.zoomTo()\n", "p.show()" ] }, { "cell_type": "code", "execution_count": 331, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Heavy Atom RMS: 1.461877955872602\n", "Heavy Atom RMS: 1.4214730604414139\n", "Heavy Atom RMS: 1.8999303358326163\n", "Heavy Atom RMS: 1.4813288602775967\n", "Heavy Atom RMS: 1.4248638894808567\n", "Heavy Atom RMS: 1.5474857037372614\n", "Heavy Atom RMS: 1.4688621809782134\n", "Heavy Atom RMS: 1.4939359811879294\n", "Heavy Atom RMS: 1.4176054292304114\n" ] } ], "source": [ "# calculate RMSD /check that/:\n", "for mol in allmol_m1_rdkit:\n", " # note that the first structure on \"allmol_m1_rdkit\" list is the crystal structure, \n", " # so the RMSD value calculated for the first structure (with respect to the crystal) will be 0 or almost 0\n", " print(\"Heavy Atom RMS:\",AllChem.GetBestRMS(Chem.RemoveHs(mol),Chem.RemoveHs(templ_m1[0])))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Summary" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's align all generated conformers: //todo fixme: align all conformers!//" ] }, { "cell_type": "code", "execution_count": 332, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 332, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = py3Dmol.view(width=400,height=400)\n", "p.removeAllModels()\n", "allmol = allmol_m1_balloon[1:]+allmol_m1_rdkit[1:]\n", "\n", "m1b = Chem.MolToMolBlock(m1_crystal)\n", "\n", "for i, mol in enumerate(allmol):\n", " AllChem.AlignMolConformers(mol,atomIds=core_m1)\n", " mq = Chem.MolToMolBlock(mol)\n", " p.addModel(mq,'sdf')\n", "p.setStyle({'stick':{'radius':'0.15'}})\n", "p.setBackgroundColor('0xeeeeee')\n", "p.zoomTo()\n", "p.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The selection of conformers of \"M1\" macrocycle:" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "## \"M7\" macrocycle\n", "\n", "start: crystal geometry" ] }, { "cell_type": "code", "execution_count": 333, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 333, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cm7 = open('/home/gosia/work/work_on_gitlab/icho/calcs/m7/m7_crystal.xyz','r').read()\n", "vcm7 = py3Dmol.view(width=400,height=400)\n", "vcm7.removeAllModels()\n", "vcm7.addModel(cm7,'xyz')\n", "vcm7.setStyle({'stick':{}})\n", "vcm7.setBackgroundColor('0xeeeeee')\n", "vcm7.zoomTo()\n", "vcm7.show()" ] }, { "cell_type": "code", "execution_count": 334, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# find \"core\" - a part of molecule, which we wish to be most aligned (rmsd-wise) among all the structures\n", "m7 = Chem.AddHs(Chem.MolFromSmiles('N1C(=O)c2nc(C(=O)NCCCNC(=O)c3nc(C(=O)NCCC1)ccc3)ccc2'))\n", "core_m7 = m7.GetSubstructMatch(Chem.MolFromSmiles('C(=O)c1nc(C=O)ccc1'))" ] }, { "cell_type": "code", "execution_count": 335, "metadata": { "collapsed": true }, "outputs": [], "source": [ "templ_m7 = Chem.SDMolSupplier('/home/gosia/work/work_on_gitlab/icho/calcs/m7/m7_crystal.sdf')\n", "m7_crystal = templ_m7[0]" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "### Conformers generated with the Balloon software:" ] }, { "cell_type": "code", "execution_count": 336, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "inps_m7_balloon = glob.glob('/home/gosia/work/work_on_gitlab/icho/calcs/m7/balloon/results_crystal/*.sdf')" ] }, { "cell_type": "code", "execution_count": 337, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [], "source": [ "e_m7_balloon = grep_energies_from_sdf_outputs(inps_m7_balloon)" ] }, { "cell_type": "code", "execution_count": 338, "metadata": { "collapsed": false, "deletable": true, "editable": true, "scrolled": true }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m7_b1, E = m7_b2, E = m7_b3, E = m7_b4, E =
m7_b5, E = m7_b6, E = m7_b7, E =
m7_b8, E = m7_b9, E = m7_b10, E =
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m7_b1, E = m7_b2, E = m7_b3, E = m7_b4, E =
m7_b5, E = m7_b6, E = m7_b7, E =
m7_b8, E = m7_b9, E = m7_b10, E =
" ] }, { "cell_type": "code", "execution_count": 339, "metadata": { "collapsed": true, "deletable": true, "editable": true }, "outputs": [], "source": [ "p7_b_handles=[]\n", "for inp in inps_m7_balloon:\n", " f7_b = open(inp, 'r').read()\n", " p7_b = py3Dmol.view(width=200,height=200)\n", " p7_b.removeAllModels()\n", " p7_b.addModel(f7_b,'sdf')\n", " p7_b.setStyle({'stick':{}})\n", " p7_b.setBackgroundColor('0xeeeeee')\n", " p7_b.zoomTo()\n", " p7_b_handles.append(p7_b)" ] }, { "cell_type": "code", "execution_count": 340, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 340, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[0].insert('m7_b1')" ] }, { "cell_type": "code", "execution_count": 341, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 341, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[1].insert('m7_b2')" ] }, { "cell_type": "code", "execution_count": 342, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 342, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[2].insert('m7_b3')" ] }, { "cell_type": "code", "execution_count": 343, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 343, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[3].insert('m7_b4')" ] }, { "cell_type": "code", "execution_count": 344, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 344, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[4].insert('m7_b5')" ] }, { "cell_type": "code", "execution_count": 345, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 345, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[5].insert('m7_b6')" ] }, { "cell_type": "code", "execution_count": 346, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 346, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[6].insert('m7_b7')" ] }, { "cell_type": "code", "execution_count": 347, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 347, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[7].insert('m7_b8')" ] }, { "cell_type": "code", "execution_count": 348, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 348, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[8].insert('m7_b9')" ] }, { "cell_type": "code", "execution_count": 349, "metadata": { "collapsed": false, "deletable": true, "editable": true }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 349, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_b_handles[9].insert('m7_b10')" ] }, { "cell_type": "markdown", "metadata": { "deletable": true, "editable": true }, "source": [ "We can now align all these structures against the crystal structure:" ] }, { "cell_type": "code", "execution_count": 350, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# write conformers as a list\n", "allmol_m7_balloon = []\n", "suppl_m7_balloon = Chem.SDMolSupplier('/home/gosia/work/work_on_gitlab/icho/calcs/m7/balloon/m7_crystal_out.sdf')\n", "\n", "# add crystal structure to the list:\n", "allmol_m7_balloon.append(m7_crystal)\n", "for mol in suppl_m7_balloon:\n", " allmol_m7_balloon.append(mol)" ] }, { "cell_type": "code", "execution_count": 351, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# align:\n", "for mol in allmol_m7_balloon:\n", " AllChem.AlignMolConformers(mol,atomIds=core_m7)" ] }, { "cell_type": "code", "execution_count": 352, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 352, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = py3Dmol.view(width=400,height=400)\n", "p.removeAllModels()\n", "for mol in allmol_m7_balloon:\n", " mb = Chem.MolToMolBlock(mol)\n", " p.addModel(mb,'sdf')\n", "p.setStyle({'stick':{'radius':'0.15'}})\n", "p.setBackgroundColor('0xeeeeee')\n", "p.zoomTo()\n", "p.show()" ] }, { "cell_type": "code", "execution_count": 353, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Heavy Atom RMS: 0.0\n", "Heavy Atom RMS: 0.5937868071467916\n", "Heavy Atom RMS: 0.2092299897502145\n", "Heavy Atom RMS: 2.0075607376161804\n", "Heavy Atom RMS: 1.840950977376659\n", "Heavy Atom RMS: 1.8774918734686699\n", "Heavy Atom RMS: 2.0163759964267918\n", "Heavy Atom RMS: 1.7994332303736011\n", "Heavy Atom RMS: 1.9216906406205834\n", "Heavy Atom RMS: 1.3635632583944308\n", "Heavy Atom RMS: 1.380050979571361\n" ] } ], "source": [ "for mol in allmol_m7_balloon:\n", " # note that the first structure on \"allmol_m1_rdkit\" list is the crystal structure, \n", " # so the RMSD value calculated for the first structure (with respect to the crystal) will be very small\n", " print(\"Heavy Atom RMS:\",AllChem.GetBestRMS(Chem.RemoveHs(mol),Chem.RemoveHs(m7_crystal)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Conformers generated with the RDKit software" ] }, { "cell_type": "code", "execution_count": 354, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# create a list of all structures to be aligned\n", "inps_m7_rdkit = glob.glob('/home/gosia/work/work_on_gitlab/icho/calcs/m7/rdkit/results_crystal_from_smiles/*.sdf')\n", "allmol_m7_rdkit = []\n", "suppl_m7_rdkit = Chem.SDMolSupplier('/home/gosia/work/work_on_gitlab/icho/calcs/m7/rdkit/result_smiles.sdf')\n", "\n", "# add crystal structure to the list:\n", "#allmol_m7_rdkit.append(m7_crystal)\n", "for mol in suppl_m7_rdkit:\n", " allmol_m7_rdkit.append(mol)" ] }, { "cell_type": "code", "execution_count": 355, "metadata": { "collapsed": false }, "outputs": [], "source": [ "e_m7_rdkit = grep_energies_from_sdf_outputs(inps_m7_rdkit)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "View conformers:" ] }, { "cell_type": "code", "execution_count": 356, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m7_r1, E = m7_r2, E = m7_r3, E =
m7_r4, E = m7_r5, E = m7_r6, E =
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "%%html\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
m7_r1, E = m7_r2, E = m7_r3, E =
m7_r4, E = m7_r5, E = m7_r6, E =
" ] }, { "cell_type": "code", "execution_count": 357, "metadata": { "collapsed": false }, "outputs": [], "source": [ "p7_r_handles=[]\n", "for inp in inps_m1_rdkit:\n", " f7_r = open(inp, 'r').read()\n", " p7_r = py3Dmol.view(width=200,height=200)\n", " p7_r.removeAllModels()\n", " p7_r.addModel(f7_r,'sdf')\n", " p7_r.setStyle({'stick':{}})\n", " p7_r.setBackgroundColor('0xeeeeee')\n", " p7_r.zoomTo()\n", " p7_r_handles.append(p7_r)\n" ] }, { "cell_type": "code", "execution_count": 358, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 358, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_r_handles[0].insert('m7_r1')" ] }, { "cell_type": "code", "execution_count": 359, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 359, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_r_handles[1].insert('m7_r2')" ] }, { "cell_type": "code", "execution_count": 360, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 360, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_r_handles[2].insert('m7_r3')" ] }, { "cell_type": "code", "execution_count": 361, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 361, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_r_handles[3].insert('m7_r4')" ] }, { "cell_type": "code", "execution_count": 362, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 362, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_r_handles[4].insert('m7_r5')" ] }, { "cell_type": "code", "execution_count": 363, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 363, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p7_r_handles[5].insert('m7_r6')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now align all these structures:" ] }, { "cell_type": "code", "execution_count": 364, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# align:\n", "for mol in allmol_m7_rdkit:\n", " AllChem.AlignMolConformers(mol,atomIds=core_m7)" ] }, { "cell_type": "code", "execution_count": 365, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 365, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# view:\n", "p = py3Dmol.view(width=400,height=400)\n", "p.removeAllModels()\n", "for mol in allmol_m7_rdkit: \n", " mb = Chem.MolToMolBlock(mol)\n", " p.addModel(mb,'sdf') \n", "p.setStyle({'stick':{'radius':'0.15'}})\n", "p.setBackgroundColor('0xeeeeee')\n", "p.zoomTo()\n", "p.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Summary" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's align all generated conformers: //todo fixme: align all conformers!//" ] }, { "cell_type": "code", "execution_count": 366, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "" ], "text/plain": [ "" ] }, "execution_count": 366, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = py3Dmol.view(width=400,height=400)\n", "p.removeAllModels()\n", "allmol = allmol_m7_balloon[1:]+allmol_m7_rdkit[1:]\n", "\n", "m7b = Chem.MolToMolBlock(m7_crystal)\n", "\n", "for i, mol in enumerate(allmol):\n", " AllChem.AlignMolConformers(mol,atomIds=core_m7)\n", " mq = Chem.MolToMolBlock(mol)\n", " p.addModel(mq,'sdf')\n", "p.setStyle({'stick':{'radius':'0.15'}})\n", "p.setBackgroundColor('0xeeeeee')\n", "p.zoomTo()\n", "p.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.5.3" } }, "nbformat": 4, "nbformat_minor": 2 }