{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "e1a8d51a", "metadata": {}, "outputs": [], "source": [ "import py3Dmol" ] }, { "cell_type": "code", "execution_count": 3, "id": "65c56235", "metadata": {}, "outputs": [], "source": [ "benz='''\n", " RDKit 3D\n", "\n", " 6 6 0 0 0 0 0 0 0 0999 V2000\n", " -0.9517 0.7811 -0.6622 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.2847 1.3329 -0.3121 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 1.2365 0.5518 0.3512 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 0.9517 -0.7811 0.6644 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " -0.2847 -1.3329 0.3144 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " -1.2365 -0.5518 -0.3489 C 0 0 0 0 0 0 0 0 0 0 0 0\n", " 1 2 2 0\n", " 2 3 1 0\n", " 3 4 2 0\n", " 4 5 1 0\n", " 5 6 2 0\n", " 6 1 1 0\n", "M END\n", "$$$$'''" ] }, { "cell_type": "code", "execution_count": null, "id": "e8c69a5b", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 4, "id": "e0e64ef1", "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" }, { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view = py3Dmol.view(query='pdb:1dc9',linked=False,viewergrid=(2,2))\n", "view.setViewStyle({'style':'outline','color':'black','width':0.1})\n", "view.setStyle({'cartoon':{'arrows':True, 'tubes':True, 'style':'oval', 'color':'white'}},viewer=(0,1))\n", "view.setStyle({'stick':{'colorscheme':'greenCarbon'}},viewer=(1,0))\n", "view.setStyle({'cartoon':{'color':'spectrum'}},viewer=(1,1))\n", "view.removeAllModels(viewer=(0,0))\n", "view.addModel(benz,'sdf',viewer=(0,0))\n", "view.setStyle({'stick':{}},viewer=(0,0))\n", "view.zoomTo(viewer=(0,0))\n", "view.render()" ] }, { "cell_type": "code", "execution_count": 10, "id": "5c274e26", "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" }, { "data": { "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view = py3Dmol.view(query='',linked=False,viewergrid=(2,2))\n", "#view.setViewStyle({'style':'outline','color':'black','width':0.1})\n", "#view.setStyle({'cartoon':{'arrows':True, 'tubes':True, 'style':'oval', 'color':'white'}},viewer=(0,1))\n", "#view.setStyle({'stick':{'colorscheme':'greenCarbon'}},viewer=(1,0))\n", "#view.setStyle({'cartoon':{'color':'spectrum'}},viewer=(1,1))\n", "view.removeAllModels(viewer=(0,0))\n", "view.addModel(benz,'sdf',viewer=(0,0))\n", "view.addModel(benz,'sdf',viewer=(0,1))\n", "view.addModel(benz,'sdf',viewer=(1,0))\n", "view.addModel(benz,'sdf',viewer=(1,1))\n", "view.setStyle({'stick':{}},viewer=(0,0))\n", "view.setStyle({'stick':{}},viewer=(0,1))\n", "view.setStyle({'stick':{}},viewer=(1,0))\n", "view.setStyle({'stick':{}},viewer=(1,1))\n", "view.zoomTo(viewer=(0,0))\n", "view.render()" ] }, { "cell_type": "code", "execution_count": 11, "id": "c41ad7fc", "metadata": {}, "outputs": [], "source": [ "dens = open('dummy_struct_dens.cub', \"r\").read()" ] }, { "cell_type": "code", "execution_count": 22, "id": "4ff28831", "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()#,style={'stick':{'colorscheme':'cyanCarbon'}})\n", "view.addVolumetricData(dens, \"cube\", {'isoval': 0.01, 'color': \"red\", 'opacity': 0.75})\n", "view.show()" ] }, { "cell_type": "code", "execution_count": 14, "id": "218a79e3", "metadata": {}, "outputs": [], "source": [ "py3Dmol.view?" ] }, { "cell_type": "code", "execution_count": null, "id": "d7687d67", "metadata": {}, "outputs": [], "source": [] } ], "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.10.13" } }, "nbformat": 4, "nbformat_minor": 5 }