Skip to content

Commit 2e190d9

Browse files
committed
switching viewing molecules to NGLview
1 parent 0398e2a commit 2e190d9

17 files changed

+143
-218
lines changed

01_jupyter_howto.ipynb

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,50 @@
100100
"source": [
101101
"# Interactive Graphics\n",
102102
"\n",
103-
"In addition to mixing documentation with interactive Python, the notebook also allows Python modules to embed interactive graphics. For example, the [BioSimSpace Project](https://biosimspace.org) provides a easy wrapper around the Python molecular viewer [nglview](https://github.com/arose/nglview). This can be used to view molecules from within a notebook.\n",
103+
"In addition to mixing documentation with interactive Python, the notebook also allows Python modules to embed interactive graphics. For example, the Python molecular viewer [nglview](https://github.com/arose/nglview) can be used to view molecules from within a notebook.\n",
104104
"\n",
105-
"Execute the cell below by selecting it and pressing SHIFT+Return. This will import the `viewMolecules` function from BioSimSpace, which will load the molecules contained in the file `data/complex.pdb` and will display it below."
105+
"Execute the cell below by selecting it and pressing SHIFT+Return. This will import NGLView, load the molecules contained in the file `data/complex.pdb` and display it below."
106106
]
107107
},
108108
{
109109
"cell_type": "code",
110-
"execution_count": null,
111-
"metadata": {},
112-
"outputs": [],
113-
"source": [
114-
"from BioSimSpace import viewMolecules\n",
115-
"v = viewMolecules(\"data/complex.pdb\")"
110+
"execution_count": 1,
111+
"metadata": {},
112+
"outputs": [
113+
{
114+
"data": {
115+
"application/vnd.jupyter.widget-view+json": {
116+
"model_id": "542c63f3308f423ea336bc210f8a07e2",
117+
"version_major": 2,
118+
"version_minor": 0
119+
},
120+
"text/html": [
121+
"<p>Failed to display Jupyter Widget of type <code>NGLWidget</code>.</p>\n",
122+
"<p>\n",
123+
" If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
124+
" that the widgets JavaScript is still loading. If this message persists, it\n",
125+
" likely means that the widgets JavaScript library is either not installed or\n",
126+
" not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
127+
" Widgets Documentation</a> for setup instructions.\n",
128+
"</p>\n",
129+
"<p>\n",
130+
" If you're reading this message in another frontend (for example, a static\n",
131+
" rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
132+
" it may mean that your frontend doesn't currently support widgets.\n",
133+
"</p>\n"
134+
],
135+
"text/plain": [
136+
"NGLWidget()"
137+
]
138+
},
139+
"metadata": {},
140+
"output_type": "display_data"
141+
}
142+
],
143+
"source": [
144+
"import nglview as nv\n",
145+
"view = nv.show_file(\"data/complex.pdb\")\n",
146+
"view"
116147
]
117148
},
118149
{
@@ -343,8 +374,9 @@
343374
"metadata": {},
344375
"outputs": [],
345376
"source": [
346-
"from BioSimSpace import viewMolecules # importing again in case we restarted the kernel\n",
347-
"viewMolecules(\"dioxin.pdb\")"
377+
"import nglview as nv # importing again in case we restarted the kernel\n",
378+
"view =nv.show_file(\"dioxin.pdb\")\n",
379+
"view"
348380
]
349381
},
350382
{
@@ -361,7 +393,7 @@
361393
"\n",
362394
"If you click \"File | Save and Checkpoint\", or click the \"Save\" icon (floppy disk icon on the far left), then the current state of the notebook will be saved. This includes not just the code and documentation you have written, but also all of the outputs and graphs that you have created. This is really useful, as it lets you save your work, and then come back later.\n",
363395
"\n",
364-
"For example, what don't you save now, and then close this window and then open the notebook again? You should see that everything you have done, and everything that was output is restored. Did it work?\n",
396+
"For example, why don't you save now, and then close this window and then open the notebook again? You should see that everything you have done, and everything that was output is restored. Did it work?\n",
365397
"\n",
366398
"The notebook was saved to a file called `01_jupyter_howto.ipynb`. The `.ipynb` signifies that the file is a Jupyter notebook (formerly called an interactive python notebook). You can change the name by clicking on the name of the notebook above, and then choosing a different name in the window that opens.\n",
367399
"\n",
@@ -410,34 +442,6 @@
410442
"![Bash in the browser](images/jupyter_shell.jpeg)\n"
411443
]
412444
},
413-
{
414-
"cell_type": "markdown",
415-
"metadata": {},
416-
"source": [
417-
"The cloud server on which this is running comes with lots of useful software that you can run from within the bash shell. For example you have;\n",
418-
"\n",
419-
"* `update_workshops` : This command will update all of the software and workshop material to the latest version. Useful if you delete anything by accident or the tutor needs to make a last-minute fix\n",
420-
"* `git` : Git is installed. The workshop material is downloaded and updated from git repositories, e.g. https://github.com/ccpbiosim/python_and_data. You could also use git to push things back to the cloud, e.g. if you want to download lots of files.\n",
421-
"* `anaconda python3` : A full anaconda python3 is installed, with pandas, matplotlib, numpy etc. etc.\n",
422-
"* `wget` : This tool lets you quickly download (or should that be sideload?) files onto the cloud server\n",
423-
"* `top` : Process monitor. You can use this to see which processes are consuming lots of resources. Any process that uses more than 1.8 GB of memory will automatically be killed by the cloud server. You can kill them yourself using the `kill` command.\n",
424-
"* `tar` and `bzip2` : useful for packing/unpacking and compressing/uncompressing files\n",
425-
"* `AmberTools` : The full [AmberTools](http://ambermd.org/AmberTools.php) suite is installed in directory `$AMBERHOME`\n",
426-
"* `ProtoMS` : The full [ProtoMS](http://protoms.org) package is installed in directory `$PROTOMSHOME`\n",
427-
"* `wham` and `wham-2d` : Tools used for weighted histogram analysis\n",
428-
"* `Sire` and `BioSimSpace` : The [Sire](https://siremol.org) and [BioSimSpace](https://biosimspace.org) python simulation framework and workflow node packages.\n",
429-
"\n",
430-
"The cloud server was build with docker. If you want to download it yourself to run on your own computer at home after the workshop then please install docker and type\n",
431-
"\n",
432-
"```\n",
433-
"docker run -it --rm -p 8888:8888 chryswoods/bss-workshop:latest\n",
434-
"```\n",
435-
"\n",
436-
"This will download and run the image from dockerhub and will make it available at the web address that will be printed to the screen (e.g. it will look something like `http://localhost:8888/?token=641396480e6421eae8b18261d82a75f958fe166e1c8b20a8`). Simply open that address in your browser :-). You can see and download the DockerFile used to generate this image [from here](https://github.com/michellab/BioSimSpaceWebsite/tree/master/docker/bss-workshop).\n",
437-
"\n",
438-
"Thanks to the [Microsoft Azure Kubernetes Service](https://docs.microsoft.com/en-us/azure/aks/) on which this Jupyter image is running."
439-
]
440-
},
441445
{
442446
"cell_type": "code",
443447
"execution_count": null,
@@ -448,21 +452,21 @@
448452
],
449453
"metadata": {
450454
"kernelspec": {
451-
"display_name": "Python 3",
455+
"display_name": "Python 2",
452456
"language": "python",
453-
"name": "python3"
457+
"name": "python2"
454458
},
455459
"language_info": {
456460
"codemirror_mode": {
457461
"name": "ipython",
458-
"version": 3
462+
"version": 2
459463
},
460464
"file_extension": ".py",
461465
"mimetype": "text/x-python",
462466
"name": "python",
463467
"nbconvert_exporter": "python",
464-
"pygments_lexer": "ipython3",
465-
"version": "3.5.2"
468+
"pygments_lexer": "ipython2",
469+
"version": "2.7.15+"
466470
}
467471
},
468472
"nbformat": 4,

02_lists.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,21 @@
355355
],
356356
"metadata": {
357357
"kernelspec": {
358-
"display_name": "Python 3",
358+
"display_name": "Python 2",
359359
"language": "python",
360-
"name": "python3"
360+
"name": "python2"
361361
},
362362
"language_info": {
363363
"codemirror_mode": {
364364
"name": "ipython",
365-
"version": 3
365+
"version": 2
366366
},
367367
"file_extension": ".py",
368368
"mimetype": "text/x-python",
369369
"name": "python",
370370
"nbconvert_exporter": "python",
371-
"pygments_lexer": "ipython3",
372-
"version": "3.5.3"
371+
"pygments_lexer": "ipython2",
372+
"version": "2.7.12"
373373
}
374374
},
375375
"nbformat": 4,

03_dictionaries.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,21 +296,21 @@
296296
],
297297
"metadata": {
298298
"kernelspec": {
299-
"display_name": "Python 3",
299+
"display_name": "Python 2",
300300
"language": "python",
301-
"name": "python3"
301+
"name": "python2"
302302
},
303303
"language_info": {
304304
"codemirror_mode": {
305305
"name": "ipython",
306-
"version": 3
306+
"version": 2
307307
},
308308
"file_extension": ".py",
309309
"mimetype": "text/x-python",
310310
"name": "python",
311311
"nbconvert_exporter": "python",
312-
"pygments_lexer": "ipython3",
313-
"version": "3.5.3"
312+
"pygments_lexer": "ipython2",
313+
"version": "2.7.12"
314314
}
315315
},
316316
"nbformat": 4,

04_functions.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,21 +358,21 @@
358358
],
359359
"metadata": {
360360
"kernelspec": {
361-
"display_name": "Python 3",
361+
"display_name": "Python 2",
362362
"language": "python",
363-
"name": "python3"
363+
"name": "python2"
364364
},
365365
"language_info": {
366366
"codemirror_mode": {
367367
"name": "ipython",
368-
"version": 3
368+
"version": 2
369369
},
370370
"file_extension": ".py",
371371
"mimetype": "text/x-python",
372372
"name": "python",
373373
"nbconvert_exporter": "python",
374-
"pygments_lexer": "ipython3",
375-
"version": "3.5.3"
374+
"pygments_lexer": "ipython2",
375+
"version": "2.7.12"
376376
}
377377
},
378378
"nbformat": 4,

05_objects.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,21 +300,21 @@
300300
],
301301
"metadata": {
302302
"kernelspec": {
303-
"display_name": "Python 3",
303+
"display_name": "Python 2",
304304
"language": "python",
305-
"name": "python3"
305+
"name": "python2"
306306
},
307307
"language_info": {
308308
"codemirror_mode": {
309309
"name": "ipython",
310-
"version": 3
310+
"version": 2
311311
},
312312
"file_extension": ".py",
313313
"mimetype": "text/x-python",
314314
"name": "python",
315315
"nbconvert_exporter": "python",
316-
"pygments_lexer": "ipython3",
317-
"version": "3.5.3"
316+
"pygments_lexer": "ipython2",
317+
"version": "2.7.12"
318318
}
319319
},
320320
"nbformat": 4,

06_classes.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,21 +604,21 @@
604604
],
605605
"metadata": {
606606
"kernelspec": {
607-
"display_name": "Python 3",
607+
"display_name": "Python 2",
608608
"language": "python",
609-
"name": "python3"
609+
"name": "python2"
610610
},
611611
"language_info": {
612612
"codemirror_mode": {
613613
"name": "ipython",
614-
"version": 3
614+
"version": 2
615615
},
616616
"file_extension": ".py",
617617
"mimetype": "text/x-python",
618618
"name": "python",
619619
"nbconvert_exporter": "python",
620-
"pygments_lexer": "ipython3",
621-
"version": "3.5.3"
620+
"pygments_lexer": "ipython2",
621+
"version": "2.7.12"
622622
}
623623
},
624624
"nbformat": 4,

07_documentation.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,21 +318,21 @@
318318
],
319319
"metadata": {
320320
"kernelspec": {
321-
"display_name": "Python 3",
321+
"display_name": "Python 2",
322322
"language": "python",
323-
"name": "python3"
323+
"name": "python2"
324324
},
325325
"language_info": {
326326
"codemirror_mode": {
327327
"name": "ipython",
328-
"version": 3
328+
"version": 2
329329
},
330330
"file_extension": ".py",
331331
"mimetype": "text/x-python",
332332
"name": "python",
333333
"nbconvert_exporter": "python",
334-
"pygments_lexer": "ipython3",
335-
"version": "3.5.3"
334+
"pygments_lexer": "ipython2",
335+
"version": "2.7.12"
336336
}
337337
},
338338
"nbformat": 4,

08_class_documentation.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,21 @@
377377
],
378378
"metadata": {
379379
"kernelspec": {
380-
"display_name": "Python 3",
380+
"display_name": "Python 2",
381381
"language": "python",
382-
"name": "python3"
382+
"name": "python2"
383383
},
384384
"language_info": {
385385
"codemirror_mode": {
386386
"name": "ipython",
387-
"version": 3
387+
"version": 2
388388
},
389389
"file_extension": ".py",
390390
"mimetype": "text/x-python",
391391
"name": "python",
392392
"nbconvert_exporter": "python",
393-
"pygments_lexer": "ipython3",
394-
"version": "3.5.3"
393+
"pygments_lexer": "ipython2",
394+
"version": "2.7.12"
395395
}
396396
},
397397
"nbformat": 4,

09_exceptions.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,21 +294,21 @@
294294
],
295295
"metadata": {
296296
"kernelspec": {
297-
"display_name": "Python 3",
297+
"display_name": "Python 2",
298298
"language": "python",
299-
"name": "python3"
299+
"name": "python2"
300300
},
301301
"language_info": {
302302
"codemirror_mode": {
303303
"name": "ipython",
304-
"version": 3
304+
"version": 2
305305
},
306306
"file_extension": ".py",
307307
"mimetype": "text/x-python",
308308
"name": "python",
309309
"nbconvert_exporter": "python",
310-
"pygments_lexer": "ipython3",
311-
"version": "3.5.3"
310+
"pygments_lexer": "ipython2",
311+
"version": "2.7.12"
312312
}
313313
},
314314
"nbformat": 4,

10_error_handling.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,21 +291,21 @@
291291
],
292292
"metadata": {
293293
"kernelspec": {
294-
"display_name": "Python 3",
294+
"display_name": "Python 2",
295295
"language": "python",
296-
"name": "python3"
296+
"name": "python2"
297297
},
298298
"language_info": {
299299
"codemirror_mode": {
300300
"name": "ipython",
301-
"version": 3
301+
"version": 2
302302
},
303303
"file_extension": ".py",
304304
"mimetype": "text/x-python",
305305
"name": "python",
306306
"nbconvert_exporter": "python",
307-
"pygments_lexer": "ipython3",
308-
"version": "3.5.3"
307+
"pygments_lexer": "ipython2",
308+
"version": "2.7.12"
309309
}
310310
},
311311
"nbformat": 4,

0 commit comments

Comments
 (0)