<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "pc5-mbsX9PZC"
   },
   "source": [
    "# AlphaFold Colab\n",
    "\n",
    "This Colab notebook allows you to easily predict the structure of a protein using a slightly simplified version of [AlphaFold v2.0](https://doi.org/10.1038/s41586-021-03819-2). \n",
    "\n",
    "**Differences to AlphaFold v2.0**\n",
    "\n",
    "In comparison to AlphaFold v2.0, this Colab notebook uses **no templates (homologous structures)** and a selected portion of the [BFD database](https://bfd.mmseqs.com/). We have validated these changes on several thousand recent PDB structures. While accuracy will be near-identical to the full AlphaFold system on many targets, a small fraction have a large drop in accuracy due to the smaller MSA and lack of templates. For best reliability, we recommend instead using the [full open source AlphaFold](https://github.com/deepmind/alphafold/), or the [AlphaFold Protein Structure Database](https://alphafold.ebi.ac.uk/).\n",
    "\n",
    "Please note that this Colab notebook is provided as an early-access prototype and is not a finished product. It is provided for theoretical modelling only and caution should be exercised in its use. \n",
    "\n",
    "**Citing this work**\n",
    "\n",
    "Any publication that discloses findings arising from using this notebook should [cite](https://github.com/deepmind/alphafold/#citing-this-work) the [AlphaFold paper](https://doi.org/10.1038/s41586-021-03819-2).\n",
    "\n",
    "**Licenses**\n",
    "\n",
    "This Colab uses the [AlphaFold model parameters](https://github.com/deepmind/alphafold/#model-parameters-license) and its outputs are thus for non-commercial use only, under the Creative Commons Attribution-NonCommercial 4.0 International ([CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)) license. The Colab itself is provided under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). See the full license statement below.\n",
    "\n",
    "**More information**\n",
    "\n",
    "You can find more information about how AlphaFold works in our two Nature papers:\n",
    "\n",
    "*   [AlphaFold methods paper](https://www.nature.com/articles/s41586-021-03819-2)\n",
    "*   [AlphaFold predictions of the human proteome paper](https://www.nature.com/articles/s41586-021-03828-1)\n",
    "\n",
    "FAQ on how to interpret AlphaFold predictions are [here](https://alphafold.ebi.ac.uk/faq)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "form",
    "id": "woIxeCPygt7K"
   },
   "outputs": [],
   "source": [
    "#@title Install third-party software\n",
    "\n",
    "#@markdown Please execute this cell by pressing the _Play_ button \n",
    "#@markdown on the left to download and import third-party software \n",
    "#@markdown in this Colab notebook. (See the [acknowledgements](https://github.com/deepmind/alphafold/#acknowledgements) in our readme.)\n",
    "\n",
    "#@markdown **Note**: This installs the software on the Colab \n",
    "#@markdown notebook in the cloud and not on your computer.\n",
    "\n",
    "from IPython.utils import io\n",
    "import os\n",
    "import subprocess\n",
    "import tqdm.notebook\n",
    "\n",
    "TQDM_BAR_FORMAT = '{l_bar}{bar}| {n_fmt}/{total_fmt} [elapsed: {elapsed} remaining: {remaining}]'\n",
    "\n",
    "try:\n",
    "  with tqdm.notebook.tqdm(total=100, bar_format=TQDM_BAR_FORMAT) as pbar:\n",
    "    with io.capture_output() as captured:\n",
    "      %shell sudo apt install --quiet --yes hmmer\n",
    "      pbar.update(6)\n",
    "\n",
    "      # Install py3dmol.\n",
    "      %shell pip install py3dmol\n",
    "      pbar.update(2)\n",
    "\n",
    "      # Install OpenMM and pdbfixer.\n",
    "      %shell rm -rf /opt/conda\n",
    "      %shell wget -q -P /tmp \\\n",
    "        https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \\\n",
    "          && bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \\\n",
    "          && rm /tmp/Miniconda3-latest-Linux-x86_64.sh\n",
    "      pbar.update(9)\n",
    "\n",
    "      PATH=%env PATH\n",
    "      %env PATH=/opt/conda/bin:{PATH}\n",
    "      %shell conda update -qy conda \\\n",
    "          && conda install -qy -c conda-forge \\\n",
    "            python=3.7 \\\n",
    "            openmm=7.5.1 \\\n",
    "            pdbfixer\n",
    "      pbar.update(80)\n",
    "\n",
    "      # Create a ramdisk to store a database chunk to make Jackhmmer run fast.\n",
    "      %shell sudo mkdir -m 777 --parents /tmp/ramdisk\n",
    "      %shell sudo mount -t tmpfs -o size=9G ramdisk /tmp/ramdisk\n",
    "      pbar.update(2)\n",
    "\n",
    "      %shell wget -q -P /content \\\n",
    "        https://git.scicore.unibas.ch/schwede/openstructure/-/raw/7102c63615b64735c4941278d92b554ec94415f8/modules/mol/alg/src/stereo_chemical_props.txt\n",
    "      pbar.update(1)\n",
    "except subprocess.CalledProcessError:\n",
    "  print(captured)\n",
    "  raise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "form",
    "id": "VzJ5iMjTtoZw"
   },
   "outputs": [],
   "source": [
    "#@title Download AlphaFold\n",
    "\n",
    "#@markdown Please execute this cell by pressing the *Play* button on \n",
    "#@markdown the left.\n",
    "\n",
    "GIT_REPO = 'https://github.com/deepmind/alphafold'\n",
    "\n",
    "SOURCE_URL = 'https://storage.googleapis.com/alphafold/alphafold_params_2021-07-14.tar'\n",
    "PARAMS_DIR = './alphafold/data/params'\n",
    "PARAMS_PATH = os.path.join(PARAMS_DIR, os.path.basename(SOURCE_URL))\n",
    "\n",
    "try:\n",
    "  with tqdm.notebook.tqdm(total=100, bar_format=TQDM_BAR_FORMAT) as pbar:\n",
    "    with io.capture_output() as captured:\n",
    "      %shell rm -rf alphafold\n",
    "      %shell git clone {GIT_REPO} alphafold\n",
    "      pbar.update(8)\n",
    "      %shell pip3 install ./alphafold\n",
    "      pbar.update(10)\n",
    "\n",
    "      # Apply OpenMM patch.\n",
    "      %shell pushd /opt/conda/lib/python3.7/site-packages/ && \\\n",
    "          patch -p0 < /content/alphafold/docker/openmm.patch && \\\n",
    "          popd\n",
    "          \n",
    "      %shell mkdir -p /content/alphafold/common\n",
    "      %shell cp -f /content/stereo_chemical_props.txt /content/alphafold/common\n",
    "\n",
    "      %shell mkdir --parents \"{PARAMS_DIR}\"\n",
    "      %shell wget -O \"{PARAMS_PATH}\" \"{SOURCE_URL}\"\n",
    "      pbar.update(27)\n",
    "\n",
    "      %shell tar --extract --verbose --file=\"{PARAMS_PATH}\" \\\n",
    "        --directory=\"{PARAMS_DIR}\" --preserve-permissions\n",
    "      %shell rm \"{PARAMS_PATH}\"\n",
    "      pbar.update(55)\n",
    "except subprocess.CalledProcessError:\n",
    "  print(captured)\n",
    "  raise\n",
    "\n",
    "import jax\n",
    "if jax.local_devices()[0].platform == 'tpu':\n",
    "  raise RuntimeError('Colab TPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')\n",
    "elif jax.local_devices()[0].platform == 'cpu':\n",
    "  raise RuntimeError('Colab CPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')"
   ]
  },
  {<commit_msg>Set versions of libraries AlphaFold Colab notebook depends on.<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "id": "pc5-mbsX9PZC"
   },
   "source": [
    "# AlphaFold Colab\n",
    "\n",
    "This Colab notebook allows you to easily predict the structure of a protein using a slightly simplified version of [AlphaFold v2.0](https://doi.org/10.1038/s41586-021-03819-2). \n",
    "\n",
    "**Differences to AlphaFold v2.0**\n",
    "\n",
    "In comparison to AlphaFold v2.0, this Colab notebook uses **no templates (homologous structures)** and a selected portion of the [BFD database](https://bfd.mmseqs.com/). We have validated these changes on several thousand recent PDB structures. While accuracy will be near-identical to the full AlphaFold system on many targets, a small fraction have a large drop in accuracy due to the smaller MSA and lack of templates. For best reliability, we recommend instead using the [full open source AlphaFold](https://github.com/deepmind/alphafold/), or the [AlphaFold Protein Structure Database](https://alphafold.ebi.ac.uk/).\n",
    "\n",
    "Please note that this Colab notebook is provided as an early-access prototype and is not a finished product. It is provided for theoretical modelling only and caution should be exercised in its use. \n",
    "\n",
    "**Citing this work**\n",
    "\n",
    "Any publication that discloses findings arising from using this notebook should [cite](https://github.com/deepmind/alphafold/#citing-this-work) the [AlphaFold paper](https://doi.org/10.1038/s41586-021-03819-2).\n",
    "\n",
    "**Licenses**\n",
    "\n",
    "This Colab uses the [AlphaFold model parameters](https://github.com/deepmind/alphafold/#model-parameters-license) and its outputs are thus for non-commercial use only, under the Creative Commons Attribution-NonCommercial 4.0 International ([CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/legalcode)) license. The Colab itself is provided under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). See the full license statement below.\n",
    "\n",
    "**More information**\n",
    "\n",
    "You can find more information about how AlphaFold works in our two Nature papers:\n",
    "\n",
    "*   [AlphaFold methods paper](https://www.nature.com/articles/s41586-021-03819-2)\n",
    "*   [AlphaFold predictions of the human proteome paper](https://www.nature.com/articles/s41586-021-03828-1)\n",
    "\n",
    "FAQ on how to interpret AlphaFold predictions are [here](https://alphafold.ebi.ac.uk/faq)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "form",
    "id": "woIxeCPygt7K"
   },
   "outputs": [],
   "source": [
    "#@title Install third-party software\n",
    "\n",
    "#@markdown Please execute this cell by pressing the _Play_ button \n",
    "#@markdown on the left to download and import third-party software \n",
    "#@markdown in this Colab notebook. (See the [acknowledgements](https://github.com/deepmind/alphafold/#acknowledgements) in our readme.)\n",
    "\n",
    "#@markdown **Note**: This installs the software on the Colab \n",
    "#@markdown notebook in the cloud and not on your computer.\n",
    "\n",
    "from IPython.utils import io\n",
    "import os\n",
    "import subprocess\n",
    "import tqdm.notebook\n",
    "\n",
    "TQDM_BAR_FORMAT = '{l_bar}{bar}| {n_fmt}/{total_fmt} [elapsed: {elapsed} remaining: {remaining}]'\n",
    "\n",
    "try:\n",
    "  with tqdm.notebook.tqdm(total=100, bar_format=TQDM_BAR_FORMAT) as pbar:\n",
    "    with io.capture_output() as captured:\n",
    "      %shell sudo apt install --quiet --yes hmmer\n",
    "      pbar.update(6)\n",
    "\n",
    "      # Install py3dmol.\n",
    "      %shell pip install py3dmol\n",
    "      pbar.update(2)\n",
    "\n",
    "      # Install OpenMM and pdbfixer.\n",
    "      %shell rm -rf /opt/conda\n",
    "      %shell wget -q -P /tmp \\\n",
    "        https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \\\n",
    "          && bash /tmp/Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \\\n",
    "          && rm /tmp/Miniconda3-latest-Linux-x86_64.sh\n",
    "      pbar.update(9)\n",
    "\n",
    "      PATH=%env PATH\n",
    "      %env PATH=/opt/conda/bin:{PATH}\n",
    "      %shell conda update -qy conda \\\n",
    "          && conda install -qy -c conda-forge \\\n",
    "            python=3.7 \\\n",
    "            openmm=7.5.1 \\\n",
    "            pdbfixer\n",
    "      pbar.update(80)\n",
    "\n",
    "      # Create a ramdisk to store a database chunk to make Jackhmmer run fast.\n",
    "      %shell sudo mkdir -m 777 --parents /tmp/ramdisk\n",
    "      %shell sudo mount -t tmpfs -o size=9G ramdisk /tmp/ramdisk\n",
    "      pbar.update(2)\n",
    "\n",
    "      %shell wget -q -P /content \\\n",
    "        https://git.scicore.unibas.ch/schwede/openstructure/-/raw/7102c63615b64735c4941278d92b554ec94415f8/modules/mol/alg/src/stereo_chemical_props.txt\n",
    "      pbar.update(1)\n",
    "except subprocess.CalledProcessError:\n",
    "  print(captured)\n",
    "  raise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "cellView": "form",
    "id": "VzJ5iMjTtoZw"
   },
   "outputs": [],
   "source": [
    "#@title Download AlphaFold\n",
    "\n",
    "#@markdown Please execute this cell by pressing the *Play* button on \n",
    "#@markdown the left.\n",
    "\n",
    "GIT_REPO = 'https://github.com/deepmind/alphafold'\n",
    "\n",
    "SOURCE_URL = 'https://storage.googleapis.com/alphafold/alphafold_params_2021-07-14.tar'\n",
    "PARAMS_DIR = './alphafold/data/params'\n",
    "PARAMS_PATH = os.path.join(PARAMS_DIR, os.path.basename(SOURCE_URL))\n",
    "\n",
    "try:\n",
    "  with tqdm.notebook.tqdm(total=100, bar_format=TQDM_BAR_FORMAT) as pbar:\n",
    "    with io.capture_output() as captured:\n",
    "      %shell rm -rf alphafold\n",
    "      %shell git clone {GIT_REPO} alphafold\n",
    "      pbar.update(8)\n",
    "      # Install the required versions of all dependencies.\n",
    "      %shell pip3 install -r ./alphafold/requirements.txt\n",
    "      # Run setup.py to install only AlphaFold.\n",
    "      %shell pip3 install --no-dependencies ./alphafold\n",
    "      pbar.update(10)\n",
    "\n",
    "      # Apply OpenMM patch.\n",
    "      %shell pushd /opt/conda/lib/python3.7/site-packages/ && \\\n",
    "          patch -p0 < /content/alphafold/docker/openmm.patch && \\\n",
    "          popd\n",
    "          \n",
    "      %shell mkdir -p /content/alphafold/common\n",
    "      %shell cp -f /content/stereo_chemical_props.txt /content/alphafold/common\n",
    "\n",
    "      %shell mkdir --parents \"{PARAMS_DIR}\"\n",
    "      %shell wget -O \"{PARAMS_PATH}\" \"{SOURCE_URL}\"\n",
    "      pbar.update(27)\n",
    "\n",
    "      %shell tar --extract --verbose --file=\"{PARAMS_PATH}\" \\\n",
    "        --directory=\"{PARAMS_DIR}\" --preserve-permissions\n",
    "      %shell rm \"{PARAMS_PATH}\"\n",
    "      pbar.update(55)\n",
    "except subprocess.CalledProcessError:\n",
    "  print(captured)\n",
    "  raise\n",
    "\n",
    "import jax\n",
    "if jax.local_devices()[0].platform == 'tpu':\n",
    "  raise RuntimeError('Colab TPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')\n",
    "elif jax.local_devices()[0].platform == 'cpu':\n",
    "  raise RuntimeError('Colab CPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')"
   ]
  },
  {
{'fraction_non_alphanumeric': 0.16914534999008526, 'fraction_numerical': 0.024125851014607708, 'mean_word_length': 2.564193168433451, 'pattern_counts': {'":': 38, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 34, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2328093', 'n_tokens_mistral': 5573, 'n_tokens_neox': 5240, 'n_words': 1291}