Step 1: Get your PyRosetta license. Go to http://www.pyrosetta.org/home/LicensingPyRosetta for more information.
Step 2: Upload the PyRosetta Jupyter Notebooks (including this one) to your Google Drive.
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.
# Notebook setup import sys if 'google.colab' in sys.modules: !pip install pyrosettacolabsetup import pyrosettacolabsetup pyrosettacolabsetup.mount_pyrosetta_install() pyrosettacolabsetup.install_pyrosetta() exit()
import sys if 'google.colab' in sys.modules: !pip install pyrosettacolabsetup import pyrosettacolabsetup pyrosettacolabsetup.mount_pyrosetta_install() # importing PyRosetta from pyrosetta import * init()
Now that you've completed the installation, you can use PyRosetta in any Colab notebook by running the following lines of code:
#import sys #if 'google.colab' in sys.modules: # !pip install pyrosettacolabsetup # import pyrosettacolabsetup # pyrosettacolabsetup.mount_pyrosetta_install() #from pyrosetta import * #init()
Step 4: Finally, install third-party external packages using either pip or conda.
if not os.getenv("DEBUG"): !pip install attrs billiard biopython blosc dask dask-jobqueue distributed GitPython graphviz jupyter matplotlib numpy pandas py3Dmol scipy seaborn traitlets --user
conda can be used to install required third-party external packages specified in the
environment.yml file. For installation of the new
conda env create -f environment.yml
then activate it:
conda activate PyRosetta.notebooks
For your new conda environment to show up as a kernel option in Jupyter, you may have to register your custom kernel with Jupyter:
python -m ipykernel install --user --name PyRosetta.notebooks
Installed kernels are listed with:
jupyter kernelspec list
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 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.
You will need to pass the username and password of PyRosetta to conda.
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.
Here, instead of USERNAME and PASSWORD, enter the USERNAME and PASSWORD you were given while gaining access to PyRosetta.
echo "channels:" >> $HOME/.condarc echo " - https://USERNAME:[email protected]" >> $HOME/.condarc echo " - defaults" >> $HOME/.condarc conda env create -f environment.yml conda activate PyRosetta.notebooks
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.
NOTE: 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!
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.
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.distributedand other
pyrosettaimports to the serialized functions, i.e. any functions passed to
def my_function(packed_pose): import pyrosetta pyrosetta.MoveMap() return packed_pose client.submit(my_function, packed_pose)
LocalCluster(n_workers=2, threads_per_worker=2), you may need to adjust to
threads_per_worker=1if you encounter errors on some systems.
LocalCluster(n_workers=2, threads_per_worker=2)in a standalone python script, the
LocalClusterinstance must be called within the
if __name__ == "__main__"block.
Jupyter Lab, the
py3Dmolbindings 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:
jupyter labextension install jupyterlab_3dmol
jupyter labextension install @jupyter-widgets/jupyterlab-manager
Step 1: Please install extensions nbgrader and nbpages.
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.)
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.