{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "bB5hxLd90i_K" }, "source": [ "\n", "*This notebook contains material from [PyRosetta](https://RosettaCommons.github.io/PyRosetta.notebooks);\n", "content is available [on Github](https://github.com/RosettaCommons/PyRosetta.notebooks.git).*" ] }, { "cell_type": "markdown", "metadata": { "id": "mYSCfXqf0i_T" }, "source": [ "\n", "| [Contents](toc.ipynb) | [Index](index.ipynb) | [How to Get PyRosetta on Your Personal Computer](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/01.01-How-to-Get-Local-PyRosetta.ipynb) >

\"Open" ] }, { "cell_type": "markdown", "metadata": { "id": "EAD3YgU-0i_U" }, "source": [ "# How to Get Started" ] }, { "cell_type": "markdown", "metadata": { "id": "sORfjI_I0i_U" }, "source": [ "## Students" ] }, { "cell_type": "markdown", "metadata": { "id": "SUf2tVgj0i_X" }, "source": [ "**Step 1:** Get your PyRosetta license. Go to https://www.pyrosetta.org/home/licensing-pyrosetta for more information.\n", "\n", "**Step 2:** Upload the PyRosetta Jupyter Notebooks (including this one) to your Google Drive.\n", "\n", "**Step 3:** Run the following cells to install and import PyRosetta. It will ask you to copy and paste a code to authorize. You will also need to type your PyRosetta license information. Note: It will take ~10 mins to run, but you only need to do this once. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "kftZF45O4z59" }, "outputs": [], "source": [ "!pip install pyrosettacolabsetup\n", "import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()\n", "import pyrosetta; pyrosetta.init()\n" ] }, { "cell_type": "markdown", "metadata": { "id": "ciXxFlsO88Zt" }, "source": [ "Now that you've completed the installation, you can use PyRosetta in any Colab notebook by running the following lines of code:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "executionInfo": { "elapsed": 795, "status": "ok", "timestamp": 1620141683995, "user": { "displayName": "Kat L", "photoUrl": "", "userId": "01926048829550148225" }, "user_tz": 420 }, "id": "cP7tcrIu9_bQ" }, "outputs": [], "source": [ "!pip install pyrosettacolabsetup\n", "import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()\n", "import pyrosetta; pyrosetta.init()\n" ] }, { "cell_type": "markdown", "metadata": { "id": "rHvg9fG57vDG" }, "source": [ "**Step 4:** Finally, install third-party external packages using either pip or conda. Note that this step is optional so UNCOMMENT CODE BELOW ONLY IF YOU NEED THESE PACKAGES" ] }, { "cell_type": "markdown", "metadata": { "id": "iNvWKwjc76VF" }, "source": [ "Pip" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "4aXfms_N7pF6" }, "outputs": [], "source": [ "#if not os.getenv(\"DEBUG\"):\n", "# !pip install attrs billiard biopython blosc dask dask-jobqueue distributed GitPython graphviz jupyter matplotlib numpy pandas py3Dmol scipy seaborn traitlets --user" ] }, { "cell_type": "markdown", "metadata": { "id": "23XjtWw17747" }, "source": [ "Conda" ] }, { "cell_type": "markdown", "metadata": { "id": "7dvMmk8R8RTi" }, "source": [ "Rather than `pip`, `conda` can be used to install required third-party external packages specified in the `environment.yml` file. For installation of the new `conda` environment:\n", "\n", "> conda env create -f environment.yml\n", "\n", "then activate it:\n", "\n", "> conda activate PyRosetta.notebooks\n", "\n", "For your new conda environment to show up as a kernel option in Jupyter, you may have to register your custom kernel with Jupyter:\n", "\n", "> python -m ipykernel install --user --name PyRosetta.notebooks\n", "\n", "Installed kernels are listed with:\n", "\n", "> jupyter kernelspec list\n" ] }, { "cell_type": "markdown", "metadata": { "id": "09KpmKaE0i_a" }, "source": [ "**Step 4.1:**\n", "\n", "**For Chapter 16, Running PyRosetta in Parallel (and a few other notebooks), you will need to use a specific version of PyRosetta that is built for parallelization.** This is the serialization build. Besides manually building it from the Rosetta C++ source code, the general way to obtain this is through the use of a `conda` environment. \n", "\n", "A `conda` environment is a way to run code that has specific versions of required packages, that instead of being installed globally, will be installed as a local virtual environment that you may run whenever you wish. This is extremely useful when some packages require specific versions of other packages, as is the case for some rosetta distributed code. \n", "\n", "You will need to pass the username and password of PyRosetta to conda. \n", "In order to do this, we will create a file in your home directory called `.condarc`. If you already have this file, please edit it instead of overriding it below. \n", "\n", "**Here, instead of USERNAME and PASSWORD, enter the USERNAME and PASSWORD you were given while gaining access to PyRosetta.**\n", "\n", "```\n", "echo \"channels:\" >> $HOME/.condarc\n", "echo \" - https://USERNAME:PASSWORD@conda.graylab.jhu.edu\" >> $HOME/.condarc\n", "echo \" - defaults\" >> $HOME/.condarc\n", "conda env create -f environment.yml\n", "conda activate PyRosetta.notebooks\n", "```\n", "\n", "Each time you wish to run this environment, use `conda activate PyRosetta.notebooks` to create the local virtual environment BEFORE running the jupyter notebook. You may wish to put this in your system configuration on startup. It is recommended to activate conda before you run the notebooks in general. The correct kernel is set for them. \n", "\n", "**NOTE:**\n", "When using a notebook with this environment - the python **Kernel** must be set to this env. *In Chapter 16 and other parellel notebooks, this is done for you*, but if you wish to use this environment in other notebooks, make sure to run conda manually change this! \n", "\n", "You can do this by looking at the jupyter menu - `Kernel` is after `Cell` and before `Widgets`. The option is 'Change Kernel`. This is how you would run python2 vs python3 or run a kernal with other conda environments you have installed on your computer. " ] }, { "cell_type": "markdown", "metadata": { "id": "QHzPRzXN0i_b" }, "source": [ "**Known Limitations:**\n", "\n", "- If you receive the error `AttributeError: module 'pyrosetta.rosetta' has no attribute '__path__'` or `TypeError: int returned non-int (type str)` then serialized functions need to locally import libraries (specifically, add `import pyrosetta`, `import pyrosetta.distributed` and other `pyrosetta` imports to the serialized functions, i.e. any functions passed to `client.submit` or `dask.delayed`).\n", "\n", "Example:\n", "\n", "```\n", "def my_function(packed_pose): \n", " import pyrosetta\n", " pyrosetta.MoveMap()\n", " return packed_pose\n", "client.submit(my_function, packed_pose)\n", "```\n", "\n", "\n", "- If running dask's `LocalCluster(n_workers=2, threads_per_worker=2)`, you may need to adjust to `n_workers=1` and `threads_per_worker=1` if you encounter errors on some systems.\n", "\n", "\n", "- If running dask's `LocalCluster(n_workers=2, threads_per_worker=2)` in a standalone python script, the `LocalCluster` instance must be called within the `if __name__ == \"__main__\"` block.\n", "\n", "\n", "- If using `Jupyter Lab`, the `pyrosetta.distributed.viewer` visualizer with `py3Dmol` bindings may not function correctly (i.e. the interactive scrollbar widget may not work or the visualizer doesn't appear). To fix this, you may have to install the following Jupyter Lab extensions:\n", "\n", "`jupyter labextension install jupyterlab_3dmol`\n", "\n", "`jupyter labextension install @jupyter-widgets/jupyterlab-manager`\n" ] }, { "cell_type": "markdown", "metadata": { "id": "aQJeOjhn0i_b" }, "source": [ "## Instructors" ] }, { "cell_type": "markdown", "metadata": { "id": "wkIajJ8M0i_c" }, "source": [ "**Step 1:** Please install extensions nbgrader and nbpages.\n", "\n", "**Step 2:** Make any changes to the workshops in the \"notebooks\" folder. (You can follow the directions for students and edit them in Google Colab or on your own computer using a Jupyter Notebooks browser.)\n", "\n", "**Step 3:** When you are done making changes, run make-student-nb.bash to automatically generate the student notebooks in a separate folder, the table of contents, and the keyword index. The student notebooks are copies of the instructor's version that have omitted solutions." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "5yC3n3XZ0i_c" }, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": { "id": "wVeFw3fL0i_c" }, "source": [ "**Chapter contributors:**\n", "\n", "- Kathy Le (Johns Hopkins University)\n", "- Sergey Lyskov (Johns Hopkins University)\n", "- Jason C. Klima (University of Washington; Lyell Immunopharma)" ] }, { "cell_type": "markdown", "metadata": { "id": "DU-NFT2D0i_d" }, "source": [ "\n", "| [Contents](toc.ipynb) | [Index](index.ipynb) | [How to Get PyRosetta on Your Personal Computer](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/01.01-How-to-Get-Local-PyRosetta.ipynb) >

\"Open" ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "01.00-How-to-Get-Started.ipynb", "provenance": [] }, "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.8.5" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 1 }