Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm committed Dec 17, 2024
1 parent 198c103 commit 53daa83
Showing 1 changed file with 19 additions and 59 deletions.
78 changes: 19 additions & 59 deletions notebooks/molstarview_trajectory_player.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9a1cea1e38644ea8aca1813ed5196761",
"version_major": 2,
"version_minor": 0
},
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"from nglview.widget_molstar import MolstarView\n",
"import nglview as nv\n",
"\n",
"from ipywidgets import HBox\n",
"\n",
"class FiveFrameTrajectory(nv.SimpletrajTrajectory):\n",
" @property\n",
Expand All @@ -31,69 +18,42 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "31eea2a9c5dc46a3bf52df9d724c507a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"MolstarView()"
]
},
"metadata": {},
"output_type": "display_data"
"ename": "NameError",
"evalue": "name 'FiveFrameTrajectory' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m traj \u001b[38;5;241m=\u001b[39m \u001b[43mFiveFrameTrajectory\u001b[49m(nv\u001b[38;5;241m.\u001b[39mdatafiles\u001b[38;5;241m.\u001b[39mXTC, nv\u001b[38;5;241m.\u001b[39mdatafiles\u001b[38;5;241m.\u001b[39mPDB)\n\u001b[1;32m 3\u001b[0m view \u001b[38;5;241m=\u001b[39m MolstarView()\n\u001b[1;32m 4\u001b[0m view\u001b[38;5;241m.\u001b[39madd_trajectory(traj) \u001b[38;5;66;03m# having data\u001b[39;00m\n",
"\u001b[0;31mNameError\u001b[0m: name 'FiveFrameTrajectory' is not defined"
]
}
],
"source": [
"traj = FiveFrameTrajectory(nv.datafiles.XTC, nv.datafiles.PDB)\n",
"\n",
"view = MolstarView()\n",
"view.add_trajectory(traj)\n",
"view"
"view.add_trajectory(traj) # having data\n",
"view2 = MolstarView() # Expected to be empty\n",
"HBox([view, view2])"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"view.set_coordinates({0: traj.get_coordinates(4)})\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "83c1a31ff6bc414caae9e3b574e35b4c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"MolstarView()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"view2 = MolstarView()\n",
"view2"
"view.set_coordinates({0: traj.get_coordinates(7)})\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit 53daa83

Please sign in to comment.