Step 1: Get your PyRosetta license. Go to https://www.pyrosetta.org/home/licensing-pyrosetta 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.
!pip install pyrosettacolabsetup
import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()
import pyrosetta; pyrosetta.init()
Now that you've completed the installation, you can use PyRosetta in any Colab notebook by running the following lines of code:
!pip install pyrosettacolabsetup
import pyrosettacolabsetup; pyrosettacolabsetup.install_pyrosetta()
import pyrosetta; pyrosetta.init()
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
Pip
#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
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:
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
Step 4.1:
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.
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:PASSWORD@conda.graylab.jhu.edu" >> $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.
Known Limitations:
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
).Example:
def my_function(packed_pose):
import pyrosetta
pyrosetta.MoveMap()
return packed_pose
client.submit(my_function, packed_pose)
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.
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.
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:
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.
Chapter contributors: