{ "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", "< [Examples Using the `dask` Module](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/16.04-dask.delayed-Via-Slurm.ipynb) | [Contents](toc.ipynb) | [Index](index.ipynb) | [PyRosettaCluster Tutorial 1A. Simple protocol](http://nbviewer.jupyter.org/github/RosettaCommons/PyRosetta.notebooks/blob/master/notebooks/16.06-PyRosettaCluster-Simple-protocol.ipynb) >
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Part I: Parallelized Global Ligand Docking with `pyrosetta.distributed`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Warning*: This notebook uses `pyrosetta.distributed.viewer` code, which runs in `jupyter notebook` and might not run if you're using `jupyterlab`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Note:* This Jupyter notebook uses parallelization and is **not** meant to be executed within a Google Colab environment."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"*Note:* This Jupyter notebook requires the PyRosetta distributed layer which is obtained by building PyRosetta with the `--serialization` flag or installing PyRosetta from the RosettaCommons conda channel\n",
"\n",
"**Please see the setup instructions in Chapter 16.00**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"logging.basicConfig(level=logging.INFO)\n",
"import json\n",
"import matplotlib\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline\n",
"import numpy as np\n",
"import os\n",
"import pandas as pd\n",
"import pyrosetta\n",
"import pyrosetta.distributed.dask\n",
"import pyrosetta.distributed.io as io\n",
"import pyrosetta.distributed.packed_pose as packed_pose\n",
"import pyrosetta.distributed.tasks.rosetta_scripts as rosetta_scripts\n",
"import pyrosetta.distributed.tasks.score as score\n",
"import pyrosetta.distributed.viewer as viewer\n",
"import seaborn\n",
"seaborn.set()\n",
"import sys\n",
"\n",
"from dask_jobqueue import SLURMCluster\n",
"from dask.distributed import Client, progress, as_completed\n",
"from IPython import display\n",
"\n",
"if 'google.colab' in sys.modules:\n",
" print(\"This Jupyter notebook uses parallelization and is therefore not set up for the Google Colab environment.\")\n",
" sys.exit(0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Setup PyRosetta command line flags:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ligand_params = \"inputs/TPA.am1-bcc.fa.params\"\n",
"flags = f\"\"\"\n",
"-extra_res_fa {ligand_params}\n",
"-ignore_unrecognized_res 1\n",
"-out:level 200\n",
"\"\"\"\n",
"pyrosetta.distributed.init(flags)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Setup `dask` workers to run ligand docking simulations:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if not os.getenv(\"DEBUG\"):\n",
" scratch_dir = os.path.join(\"/net/scratch\", os.environ[\"USER\"]) # Change to your scratch directory\n",
" cluster = SLURMCluster(cores=1,\n",
" processes=1,\n",
" job_cpu=1,\n",
" memory=\"3GB\",\n",
" queue=\"short\",\n",
" walltime=\"02:59:00\",\n",
" local_directory=scratch_dir,\n",
" job_extra=[\"-o {}\".format(os.path.join(scratch_dir, \"slurm-%j.out\"))],\n",
" extra=pyrosetta.distributed.dask.worker_extra(init_flags=flags))\n",
" n_workers = 20\n",
" cluster.scale(n_workers)\n",
" client = Client(cluster)\n",
"else:\n",
" cluster, client = None, None"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Setup global ligand docking RosettaScripts protocol within `pyrosetta.distributed`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xml = \"\"\"\n",
"
"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:PyRosetta.notebooks]",
"language": "python",
"name": "conda-env-PyRosetta.notebooks-py"
},
"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": 2
}