Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpocket notebook/ directory restructure #22

Merged
merged 7 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /app
ENV NODE_VERSION=16.13.1

RUN apt-get --allow-releaseinfo-change update && apt-get -y upgrade
RUN apt-get install -y curl
RUN apt-get install -y curl build-essential

# Set up jupyter conda environment
RUN conda update conda
Expand Down
10 changes: 2 additions & 8 deletions cookbook/00_Template.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"outputs": [],
"source": [
"# Load a TYL into your workspace\n",
"# Full set of functions for plugin available at \n",
"# https://nanome.readthedocs.io/en/latest/nanome.beta.redis_interface.html#module-nanome.beta.redis_interface\n",
"tyl_pdb = 'test_data/1tyl.pdb'\n",
"plugin.send_files_to_load([tyl_pdb])\n"
]
Expand Down Expand Up @@ -180,14 +182,6 @@
"plugin.update_structures_deep([comp])\n",
"plugin.apply_color_scheme(enums.ColorScheme.DonorAcceptor, enums.ColorSchemeTarget.All)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14ee53ec-6ae8-4704-be1e-aa56e3de3dfc",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
28 changes: 14 additions & 14 deletions cookbook/notebooks/01_Basics.ipynb → cookbook/01_Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Read using filepath\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"\n",
"# benzenes contain 12 atoms\n",
Expand All @@ -66,7 +66,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Read using filepath\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"\n",
"# Write complex to new pdb file\n",
Expand Down Expand Up @@ -110,7 +110,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Read using filepath\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"comp.name = 'Benzene'\n",
"\n",
Expand All @@ -133,7 +133,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Read using filepath\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"comp.name = 'Benzene'\n",
"\n",
Expand Down Expand Up @@ -167,7 +167,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Read using filepath\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"\n",
"comp.new_property = 'blah blah blah'\n",
Expand All @@ -191,7 +191,7 @@
"source": [
"from nanome.api.structure import Complex\n",
"\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"atom = next(comp.atoms)\n",
"\n",
Expand All @@ -214,7 +214,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Get list of atoms bonded to selected one\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"atom = next(comp.atoms)\n",
"\n",
Expand Down Expand Up @@ -251,7 +251,7 @@
"source": [
"from nanome.api.structure import Complex\n",
"\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"bond = next(comp.bonds)\n",
"print(bond.kind)"
Expand All @@ -276,7 +276,7 @@
"from nanome.api.structure import Complex\n",
"\n",
"# Read using filepath\n",
"input_dir = 'assets/cookbook/1tyl.pdb'\n",
"input_dir = 'test_data/1tyl.pdb'\n",
"comp = Complex.io.from_pdb(path=input_dir)\n",
"\n",
"for i, chain in enumerate(comp.chains):\n",
Expand All @@ -301,7 +301,7 @@
"source": [
"from nanome.api.structure import Complex\n",
"\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"\n",
"print(list(comp.bonds))\n"
Expand All @@ -322,7 +322,7 @@
"source": [
"from nanome.api.structure import Complex\n",
"\n",
"input_dir = 'assets/cookbook/benzene_241.sdf'\n",
"input_dir = 'test_data/benzene_241.sdf'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"\n",
"print(list(comp.residues))\n"
Expand All @@ -343,7 +343,7 @@
"source": [
"from nanome.api.structure import Complex\n",
"\n",
"input_dir = 'assets/cookbook/1tyl.pdb'\n",
"input_dir = 'test_data/1tyl.pdb'\n",
"comp = Complex.io.from_sdf(path=input_dir)\n",
"\n",
"print(list(comp.molecules))"
Expand Down Expand Up @@ -371,7 +371,7 @@
"source": [
"from nanome.api.structure import Complex\n",
"\n",
"input_dir = 'assets/cookbook/1tyl.pdb'\n",
"input_dir = 'test_data/1tyl.pdb'\n",
"comp = Complex.io.from_pdb(path=input_dir)\n",
"\n",
"atom_count = len(list(comp.atoms))\n",
Expand Down Expand Up @@ -402,7 +402,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.9.18"
},
"toc-autonumbering": false,
"toc-showcode": false,
Expand Down
100 changes: 100 additions & 0 deletions cookbook/02_ColorChangerStream.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "381bc757-d397-4a2f-b9ef-74dd0def85ba",
"metadata": {},
"outputs": [],
"source": [
"from nanome.beta.redis_interface import PluginInstanceRedisInterface\n",
"from nanome.util.enums import StreamType\n",
"import os\n",
"import itertools\n",
"\n",
"# Set up redis credentials\n",
"redis_host = os.environ.get(\"REDIS_HOST\")\n",
"redis_port = os.environ.get(\"REDIS_PORT\")\n",
"redis_password = os.environ.get(\"REDIS_PASSWORD\")\n",
"redis_channel = \"\" # Use room id code received when activating cookbook plugin\n",
"\n",
"plugin = PluginInstanceRedisInterface(redis_host, redis_port, redis_password, redis_channel)\n",
"plugin.connect()\n",
"print('Plugin Connected')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b82a3ae-c281-4cb9-9435-7dd57b0407ef",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"comps = plugin.request_complex_list()\n",
"[comp] = plugin.request_complexes([comps[0].index])\n",
"print(comp)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a07c480-b68a-41d0-b60e-ec333f932dd4",
"metadata": {},
"outputs": [],
"source": [
"roygbiv = [\n",
" (255, 0, 0), # Red\n",
" (255, 127, 0), # Orange\n",
" (255, 255, 0), # Yellow\n",
" (0, 255, 0), # Green\n",
" (0, 0, 255), # Blue\n",
" (75, 0, 130), # Indigo\n",
" (148, 0, 211), # Violet\n",
"]\n",
"\n",
"\n",
"def set_color_stream_data(atom_indices, color):\n",
" \"\"\"Set the color for every atom in the stream.\"\"\"\n",
" stream_data = [None] * (len(atom_indices) * 3)\n",
" color_vals = itertools.cycle(color)\n",
" for i in range(len(stream_data)):\n",
" stream_data[i] = next(color_vals)\n",
" return stream_data\n",
"\n",
"\n",
"# Create a writing stream to sets color for every atom in the complex.\n",
"atom_indices = [atom.index for atom in comp.atoms]\n",
"stream_type = StreamType.color\n",
"stream = plugin.create_writing_stream(atom_indices, stream_type)\n",
"\n",
"color_cycle = itertools.cycle(roygbiv)\n",
"for color in color_cycle:\n",
" stream_data = set_color_stream_data(atom_indices, color)\n",
" plugin.update_stream(stream, stream_data)\n"
]
}
],
"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.9.18"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading