{ "cells": [ { "cell_type": "markdown", "metadata": {}, "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": {}, "source": [ "\n", "< [How to Get Started](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/01.00-How-to-Get-Started.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [PyRosetta Google Drive Usage Example](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/01.02-PyRosetta-Google-Drive-Usage-Example.ipynb) >

\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# PyRosetta Google Drive Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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." ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "7avg_MNH3myr" }, "outputs": [], "source": [ "# Mounting Google Drive and add it to Python sys path \n", "\n", "google_drive_mount_point = '/content/google_drive'\n", "\n", "import os, sys, time\n", "\n", "if 'google.colab' in sys.modules:\n", " from google.colab import drive\n", " drive.mount(google_drive_mount_point)\n", "\n", "if not os.getenv(\"DEBUG\"):\n", " google_drive = google_drive_mount_point + '/My Drive'\n", " google_drive_prefix = google_drive + '/prefix'\n", "\n", " if not os.path.isdir(google_drive_prefix):\n", " os.mkdir(google_drive_prefix)\n", "\n", " pyrosetta_install_prefix_path = '/content/prefix'\n", " if os.path.islink(pyrosetta_install_prefix_path):\n", " os.unlink(pyrosetta_install_prefix_path)\n", " os.symlink(google_drive_prefix, pyrosetta_install_prefix_path)\n", "\n", " sys.path.insert(0, pyrosetta_install_prefix_path)" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "FYTdAhCGQBoa" }, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " os.environ[\"PYTHONPATH\"] = os.environ[\"PYTHONPATH\"] + ':' + pyrosetta_install_prefix_path" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "code_folding": [], "colab": {}, "colab_type": "code", "id": "hved7Vzd8FTm" }, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " #sys.path.insert(0, google_drive_packages_path)\n", "\n", " # installing PyRosetta\n", " if sys.version_info.major != 3 or sys.version_info.minor != 7:\n", " print('Need Python-3.7 to run!')\n", " sys.exit(1)\n", "\n", " import_start_time = time.time()\n", "\n", " # upload PyRosetta Linux package into your google drive and put it path here\n", " pyrosetta_distr_path = google_drive.replace(' ', '\\\\ ') + '/PyRosetta/*'\n", "\n", " # or alternatively you can download PyRosetta directly from GrayLab web site (but this might take some time!)\n", " #!mkdir $notebook_path/PyRosetta\n", " #!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 \n", " #pyrosetta_distr_path = notebook_path + '/PyRosetta/_PyRosetta_.tar.bz2'\n", "\n", " !mkdir _PyRosetta_\n", " !tar xjf $pyrosetta_distr_path -C _PyRosetta_ --strip-components=1\n", " !cd _PyRosetta_/setup && python setup.py install --install-lib=$pyrosetta_install_prefix_path\n", " !rm -rf _PyRosetta_\n", "\n", " import_end_time = time.time()\n", "\n", " print(f'PyRosetta setup took: {import_end_time - import_start_time:.1f}s...')" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "U3XT5Gza5kPj" }, "outputs": [], "source": [ "if not os.getenv(\"DEBUG\"):\n", " for e in os.listdir(pyrosetta_install_prefix_path):\n", " sys.path.append(pyrosetta_install_prefix_path + '/' + e)" ] }, { "cell_type": "code", "execution_count": 0, "metadata": { "colab": {}, "colab_type": "code", "id": "bZr-M0cnaOiE" }, "outputs": [], "source": [ "from pyrosetta import *\n", "pyrosetta.init()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Install third-party external packages" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, install third-party external packages using _either_ `pip` or `conda`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "##### Pip:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "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": {}, "source": [ "##### Conda:" ] }, { "cell_type": "markdown", "metadata": {}, "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": {}, "source": [ "\n", "< [How to Get Started](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/01.00-How-to-Get-Started.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [PyRosetta Google Drive Usage Example](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/01.02-PyRosetta-Google-Drive-Usage-Example.ipynb) >

\"Open" ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "_PyRosetta on google drive setup.ipynb", "provenance": [ { "file_id": "1o0Iu_f5HM9EdvhR3hqT5YCb-GnMkpBOL", "timestamp": 1563908223533 } ], "version": "0.3.2" }, "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.7.6" }, "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 }