Files
ScanNet/Visualize spatio-chemical filters.ipynb
2022-05-25 16:17:10 +03:00

1208 lines
33 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualizing spatio-chemical filters with pythreejs\n",
"\n",
"\n",
"## Important: Cells must be executed one at time (rather than with Cell -> Run All)\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Calculate filter specificities (precomputed)\n",
"The first step is to calculate the filter specificities.\n",
"For the atomic filters, we must simply extract the neighborhood embedding layer parameters from the keras model object.\n",
"For the amino acid filters, since the amino-acid specificity of individual gaussian components is *non-linear*, we must first determine it on a set of test proteins. This is done as follows:\n",
"1. Calculate, for each gaussian component of each filter, the distribution of activities.\n",
"2. Identify the top-1/5\\% activating residues.\n",
"3. Determine their amino acid type, secondary structure and accessible surface area.\n",
"4. Determine the mean activity across the top-activating residues.\n",
"\n",
"For the trained networks, the specificities are precomputed. Otherwise, calculating the amino acid filter specificities takes about 1-2 hour on a laptop\n",
"To avoid this step and visualize only the atom filters, specify only_atom=True\n",
"\n",
"Then, for a given filter, display the gaussians with highest mean activity (threshold1 = 33\\% of the maximum mean activity), and show attribute specificity as inset.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Using TensorFlow backend.\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:541: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:542: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:543: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:544: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:545: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n",
"/opt/anaconda3/envs/py36/lib/python3.6/site-packages/tensorboard/compat/tensorflow_stub/dtypes.py:550: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
" np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n",
"/Users/jerometubiana/Documents/GitHub/ScanNet/utilities/dataset_utils.py:71: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
" list_labels = np.array(list_labels)\n",
"/Users/jerometubiana/Documents/GitHub/ScanNet/utilities/dataset_utils.py:72: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
" list_resids = np.array(list_resids)\n"
]
}
],
"source": [
"from visualizations import show_3d_filters,weight_logo_3d\n",
"from utilities import dataset_utils\n",
"import numpy as np\n",
"\n",
"mode = 'epitope' # Prediction mode: 'interface' (protein-protein binding sites), 'epitope' (B-cell epitopes), 'idp' (protein - intrinsically disordered proteins binding sites)\n",
"use_MSA = True # Whether to use evolutionary information or not.\n",
"\n",
"\n",
"\n",
"if mode == 'interface':\n",
" top_percent = 5\n",
" if use_MSA:\n",
" model_name = 'ScanNet_PPI'\n",
" else:\n",
" model_name = 'ScanNet_PPI_noMSA'\n",
" dataset_name = 'PPBS_validation'\n",
" list_origins = np.concatenate([dataset_utils.read_labels('datasets/PPBS/labels_%s.txt'%dataset)[0]\n",
" for dataset in ['validation_70','validation_homology','validation_topology','validation_none']\n",
" ])\n",
" \n",
"elif mode == 'epitope':\n",
" top_percent = 5\n",
" if use_MSA:\n",
" model_name = 'ScanNet_PAI_0'\n",
" else:\n",
" model_name = 'ScanNet_PAI_noMSA_0'\n",
" dataset_name = 'BCE_fold1'\n",
" list_origins = dataset_utils.read_labels('datasets/BCE/labels_fold1.txt')[0]\n",
" \n",
"elif mode == 'idp':\n",
" top_percent = 5\n",
" if use_MSA:\n",
" model_name = 'ScanNet_PIDPI_0'\n",
" else:\n",
" model_name = 'ScanNet_PIDPI_noMSA_0'\n",
" dataset_name = 'PIDPBS_fold0'\n",
" list_origins = None\n",
"# list_origins = dataset_utils.read_labels('datasets/PIDP/labels_fold0.txt')[0]\n",
" \n",
" \n",
"\n",
"\n",
"filter_specificities = show_3d_filters.calculate_filter_specificities(\n",
" model_name,\n",
" dataset_name = dataset_name,\n",
" dataset_origins = list_origins,\n",
" biounit=False,\n",
" ncores=4,\n",
" only_atom=False,\n",
" top_percent = top_percent,\n",
" fresh = False,\n",
" Lmax = 1024\n",
"\n",
")\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Instantiate sphere geometry\n",
"This cell must be executed first"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"sg = weight_logo_3d.make_sphere_geometry(30)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Interactive visualization of one amino acid filter"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "031d5e4dbe3c432b9143a75fea62a673",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(position=(19.200000000000003, 12.0, 19.200000000000003), projectionMatrix=(1…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"renderer = show_3d_filters.plot_aminoacid_filter(filter_specificities,117,sg=sg);\n",
"display(renderer)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Interactive visualization of one atomic filter"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"renderer = show_3d_filters.plot_atomic_filter(filter_specificities,119,sg=sg,threshold1=0.33);\n",
"display(renderer)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Filter visualization with custom camera position"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"renderer = show_3d_filters.plot_atomic_filter(filter_specificities,30,sg=sg,\n",
" camera_position=[-0.3, 0.6, 1.0]);\n",
"\n",
"display(renderer)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Filter visualization with custom camera position, take screenshot"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"renderer = show_3d_filters.plot_atomic_filter(filter_specificities,119,sg=sg,\n",
" camera_position=[-0.3, 0.6, 1.0]);\n",
"recorder=weight_logo_3d.make_screenshot(renderer,'screenshot_filter1.png')\n",
"display(renderer)\n",
"recorder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Visualize atomic neighborhood"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parsing /Users/jerometubiana/PDB/pdb7jvb.ent\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5b8f12e2161842d295cf722cfe6b54d6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(position=(-3.0, 6.0, 10.0), projectionMatrix=(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b6f8b49b647d4451ada77efe7dda76d9",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ImageRecorder(autosave=True, filename='screenshot_atomicneighborhood1.png', image=Image(value=b''), recording=…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from visualizations import show_3d_neighborhoods\n",
"pdbid = '7jvb' # Spike protein RBD\n",
"modelid = 0\n",
"chainid = 'A'\n",
"residue = 493 # ACE2 binding site.\n",
"atom = 'N'\n",
"\n",
" \n",
"atom_positions,atom_types,atom_bonds = show_3d_neighborhoods.get_neighborhood(\n",
" pdb = pdbid[:4],\n",
" model = modelid,\n",
" chain = chainid,\n",
" resnumber = residue,\n",
" atom = atom,\n",
" assembly=False,\n",
" biounit=False,\n",
")\n",
"\n",
"renderer = show_3d_neighborhoods.show_atoms(atom_positions,atom_types,atom_bonds,render=True,\n",
" radius_scale = 0.15,show_frame=True,\n",
" camera_position=[-0.3, 0.6, 1.0]);\n",
"recorder=weight_logo_3d.make_screenshot(renderer,'screenshot_atomicneighborhood1.png')\n",
"display(renderer)\n",
"recorder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Atomic neighborhood superimposed with filter"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parsing /Users/jerometubiana/PDB/pdb7jvb.ent\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d15180ac0031464cb307328df01350a6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(position=(8.0, 5.0, 8.0), projectionMatrix=(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 288x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 288x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from visualizations import show_3d_neighborhoods\n",
"pdbid = '7jvb' # Spike protein RBD\n",
"modelid = 0\n",
"chainid = 'A'\n",
"residue = 493 # ACE2 binding site.\n",
"atom = 'N'\n",
"filter_index =56\n",
"\n",
" \n",
"atom_positions,atom_types,atom_bonds = show_3d_neighborhoods.get_neighborhood(\n",
" pdb = pdbid[:4],\n",
" model = modelid,\n",
" chain = chainid,\n",
" resnumber = residue,\n",
" atom = atom,\n",
" assembly=False,\n",
" biounit=False,\n",
")\n",
"\n",
"\n",
"list_objects = show_3d_neighborhoods.show_atoms(atom_positions,atom_types,atom_bonds,render=False,\n",
" radius_scale = 0.15)\n",
"renderer = show_3d_filters.plot_atomic_filter(filter_specificities,\n",
" filter_index,\n",
" y_offset = 0.25,\n",
" sg=sg,\n",
" list_additional_objects=list_objects,\n",
" threshold1=0.33);\n",
"\n",
"display(renderer)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Amino acid neighborhood"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parsing /Users/jerometubiana/PDB/pdb7jvb.ent\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "895f4dc8023640578673d94d14d665f2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(position=(19.200000000000003, 12.0, 19.200000000000003), projectionMatrix=(1…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "231ad4e5d0e0491c9f51794c200e7b72",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ImageRecorder(autosave=True, filename='screenshot_aminoacidneighborhood1.png', image=Image(value=b''), recordi…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from visualizations import show_3d_neighborhoods\n",
"pdbid = '7jvb' # Spike protein RBD\n",
"modelid = 0\n",
"chainid = 'A'\n",
"residue = 493 # ACE2 binding site.\n",
"MSA_file = '/Users/jerometubiana/Downloads/MSA_7jvb_A_0_A.fasta' # None\n",
"\n",
" \n",
"aa_positions,aa_types,aa_bonds = show_3d_neighborhoods.get_neighborhood_aa(\n",
" pdb = pdbid[:4],\n",
" model = modelid,\n",
" chain = chainid,\n",
" resnumber = residue,\n",
" assembly=False,\n",
" biounit=False,\n",
" MSA_file=MSA_file\n",
")\n",
"\n",
"renderer = show_3d_neighborhoods.show_aminoacids(aa_positions,aa_types,aa_bonds,render=True,\n",
" sg=sg);\n",
"recorder=weight_logo_3d.make_screenshot(renderer,'screenshot_aminoacidneighborhood1.png')\n",
"display(renderer)\n",
"recorder"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Amino acid neighborhood with filter superimposed"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Parsing /Users/jerometubiana/PDB/pdb7jvb.ent\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/jerometubiana/Documents/GitHub/ScanNet/visualizations/weight_logo_3d.py:373: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).\n",
" fig, ax = plt.subplots(1,nplots,figsize=figsize)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0e93743a21fe4c2ab2011702ac93e17b",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(position=(19.200000000000003, 12.0, 19.200000000000003), projectionMatrix=(1…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from visualizations import show_3d_neighborhoods\n",
"pdbid = '7jvb' # Spike protein RBD\n",
"modelid = 0\n",
"chainid = 'A'\n",
"residue = 490 # ACE2 binding site.\n",
"MSA_file = '/Users/jerometubiana/Downloads/MSA_7jvb_A_0_A.fasta' # None\n",
"\n",
" \n",
"aa_positions,aa_types,aa_bonds = show_3d_neighborhoods.get_neighborhood_aa(\n",
" pdb = pdbid[:4],\n",
" model = modelid,\n",
" chain = chainid,\n",
" resnumber = residue,\n",
" assembly=False,\n",
" biounit=False,\n",
" MSA_file=MSA_file\n",
")\n",
"\n",
"list_objects = show_3d_neighborhoods.show_aminoacids(aa_positions,aa_types,aa_bonds,sg=sg,render=False);\n",
"\n",
"renderer = show_3d_filters.plot_aminoacid_filter(filter_specificities,\n",
" 117,\n",
" sg=sg,\n",
" list_additional_objects=list_objects,\n",
" threshold1=0.33,scale=3.0);\n",
"display(renderer)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<module 'visualizations.show_3d_neighborhoods' from '/Users/jerometubiana/Documents/GitHub/ScanNet/visualizations/show_3d_neighborhoods.py'>"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"importlib.reload(show_3d_neighborhoods)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "52186c4aceda4a8eb11f034c4436cde2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Renderer(camera=PerspectiveCamera(position=(-7.199999999999999, 24.0, 24.0), projectionMatrix=(1.0, 0.0, 0.0, …"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3c356828ecda43e2970bed860cd34ce8",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ImageRecorder(autosave=True, filename='screenshot_aminoacidfilter2.png', image=Image(value=b''), recording=Tru…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Figure size 144x576 with 0 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"renderer = show_3d_filters.plot_aminoacid_filter(filter_specificities,112,sg=sg,scale=3.0,\n",
" camera_position=[-0.3,1.0,1.0]);\n",
"recorder=weight_logo_3d.make_screenshot(renderer,'screenshot_aminoacidfilter2.png')\n",
"display(renderer)\n",
"recorder"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.6.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}