Run this notebook to install PyRosetta in Colab. You will only need to do this once. Afterwards, you will be able to initialize and use PyRosetta in any notebook in Colab.
# Mounting Google Drive and add it to Python sys path
google_drive_mount_point = '/content/google_drive'
import os, sys, time
if 'google.colab' in sys.modules:
from google.colab import drive
drive.mount(google_drive_mount_point)
if not os.getenv("DEBUG"):
google_drive = google_drive_mount_point + '/My Drive'
google_drive_prefix = google_drive + '/prefix'
if not os.path.isdir(google_drive_prefix):
os.mkdir(google_drive_prefix)
pyrosetta_install_prefix_path = '/content/prefix'
if os.path.islink(pyrosetta_install_prefix_path):
os.unlink(pyrosetta_install_prefix_path)
os.symlink(google_drive_prefix, pyrosetta_install_prefix_path)
sys.path.insert(0, pyrosetta_install_prefix_path)
if not os.getenv("DEBUG"):
os.environ["PYTHONPATH"] = os.environ["PYTHONPATH"] + ':' + pyrosetta_install_prefix_path
if not os.getenv("DEBUG"):
#sys.path.insert(0, google_drive_packages_path)
# installing PyRosetta
if sys.version_info.major != 3 or sys.version_info.minor != 7:
print('Need Python-3.7 to run!')
sys.exit(1)
import_start_time = time.time()
# upload PyRosetta Linux package into your google drive and put it path here
pyrosetta_distr_path = google_drive.replace(' ', '\\ ') + '/PyRosetta/*'
# or alternatively you can download PyRosetta directly from GrayLab web site (but this might take some time!)
#!mkdir $notebook_path/PyRosetta
#!cd $notebook_path/PyRosetta && wget -O _PyRosetta_.tar.bz2 --user USERNAME --password PASSWORD http://graylab.jhu.edu/download/PyRosetta4/archive/release/PyRosetta4.MinSizeRel.python37.linux/PyRosetta4.MinSizeRel.python37.linux.release-227.tar.bz2
#pyrosetta_distr_path = notebook_path + '/PyRosetta/_PyRosetta_.tar.bz2'
!mkdir _PyRosetta_
!tar xjf $pyrosetta_distr_path -C _PyRosetta_ --strip-components=1
!cd _PyRosetta_/setup && python setup.py install --install-lib=$pyrosetta_install_prefix_path
!rm -rf _PyRosetta_
import_end_time = time.time()
print(f'PyRosetta setup took: {import_end_time - import_start_time:.1f}s...')
if not os.getenv("DEBUG"):
for e in os.listdir(pyrosetta_install_prefix_path):
sys.path.append(pyrosetta_install_prefix_path + '/' + e)
from pyrosetta import *
pyrosetta.init()
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
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