Example Jupyter notebook with Binder & Colab integration
Updated 09 Nov 2018: This code can also be run in Code Ocean. Click here (or the button above) to launch the notebook on that platform. Thanks to Code Ocean's Simon Adar (@SimonAdar) and Seth Green for the help!
This simple Jupyter notebook -- written to accompany a Nature Toolbox feature published on 30 October 2018 -- demonstrates how the computational notebook format allows users to interleave text, code, and results in a single file.
But, unless you have Jupyter notebook installed on your computer, all you can do is view the notebooks, not play with them. (See for yourself: If you click My_sample_notebook.ipynb in this GitHub repository, you will be able to read the notebook, but only as a static document.) This is where Binder, Google's Colaboratory environment, and Code Ocean come in. Binder is a free, open-source web service that packages Jupyter notebooks inside an executable container, which can be run within a web browser, no installation required. Colab allows users with Google accounts to execute Jupyter notebooks on the Google cloud. Code Ocean is a commercial code-execution and -sharing service.
To execute the notebook in Binder:
Click the launch binder button above. Once the demo launches, click My_sample_notebook.ipynb in the file listing.
Run the notebook by selecting Cell > Run All.
Take a look at the graph below the fifth cell (labeled 'The First 25 Fibonacci Numbers').
Uncomment the line in the fifth cell that reads # ax.plot (range(25), ar) by removing the leading hashtag (#)
Click Cell > Run All again. You should see a change in the graph below that cell.
To execute the notebook in Colab:
Click the Open in Colab button above. It will launch the notebook directly.
Make the notebook live by clicking 'Connect' in the Colab toolbar.
You'll need to uncomment a few lines of code to make the notebook work. Navigate to the first cell, which reads: # !pip install biopython # !pip install folium # !curl -O https://raw.githubusercontent.com/jperkel/example_notebook/master/NC_005816.gb
Uncomment this cell by removing the three leading #.
Select Runtime > Run All in the menu to execute the notebook. (You may get a warning that the page was not authored by Google.)
Take a look at the graph below the fifth cell (labeled 'The First 25 Fibonacci Numbers').
Uncomment the line in the fifth cell that reads # ax.plot (range(25), ar) by removing the leading hashtag (#)
Click Runtime > Run All again. You should see a change in the graph below that cell.
请发表评论