" with tqdm.notebook.tqdm(total=100, bar_format=TQDM_BAR_FORMAT) as pbar:\n",
" with tqdm.notebook.tqdm(total=100, bar_format=TQDM_BAR_FORMAT) as pbar:\n",
" with io.capture_output() as captured:\n",
" with io.capture_output() as captured:\n",
" # Uninstall default Colab version of TF.\n",
" %shell pip uninstall -y tensorflow\n",
"\n",
" %shell sudo apt install --quiet --yes hmmer\n",
" %shell sudo apt install --quiet --yes hmmer\n",
" pbar.update(6)\n",
" pbar.update(6)\n",
"\n",
"\n",
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# AlphaFold Colab
# AlphaFold Colab
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).
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).
**Differences to AlphaFold v2.0**
**Differences to AlphaFold v2.0**
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/).
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/).
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.
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.
**Citing this work**
**Citing this work**
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).
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).
**Licenses**
**Licenses**
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.
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.
**More information**
**More information**
You can find more information about how AlphaFold works in our two Nature papers:
You can find more information about how AlphaFold works in our two Nature papers:
%shell tar --extract --verbose --file="{PARAMS_PATH}" \
%shell tar --extract --verbose --file="{PARAMS_PATH}" \
--directory="{PARAMS_DIR}" --preserve-permissions
--directory="{PARAMS_DIR}" --preserve-permissions
%shell rm "{PARAMS_PATH}"
%shell rm "{PARAMS_PATH}"
pbar.update(55)
pbar.update(55)
except subprocess.CalledProcessError:
except subprocess.CalledProcessError:
print(captured)
print(captured)
raise
raise
import jax
import jax
if jax.local_devices()[0].platform == 'tpu':
if jax.local_devices()[0].platform == 'tpu':
raise RuntimeError('Colab TPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')
raise RuntimeError('Colab TPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')
elif jax.local_devices()[0].platform == 'cpu':
elif jax.local_devices()[0].platform == 'cpu':
raise RuntimeError('Colab CPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')
raise RuntimeError('Colab CPU runtime not supported. Change it to GPU via Runtime -> Change Runtime Type -> Hardware accelerator -> GPU.')
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## Making a prediction
## Making a prediction
Please paste the sequence of your protein in the text box below, then run the remaining cells via _Runtime_ > _Run after_. You can also run the cells individually by pressing the _Play_ button on the left.
Please paste the sequence of your protein in the text box below, then run the remaining cells via _Runtime_ > _Run after_. You can also run the cells individually by pressing the _Play_ button on the left.
Note that the search against databases and the actual prediction can take some time, from minutes to hours, depending on the length of the protein and what type of GPU you are allocated by Colab (see FAQ below).
Note that the search against databases and the actual prediction can take some time, from minutes to hours, depending on the length of the protein and what type of GPU you are allocated by Colab (see FAQ below).
aatypes = set('ACDEFGHIKLMNPQRSTVWY') # 20 standard aatypes
aatypes = set('ACDEFGHIKLMNPQRSTVWY') # 20 standard aatypes
if not set(sequence).issubset(aatypes):
if not set(sequence).issubset(aatypes):
raise Exception(f'Input sequence contains non-amino acid letters: {set(sequence) - aatypes}. AlphaFold only supports 20 standard amino acids as inputs.')
raise Exception(f'Input sequence contains non-amino acid letters: {set(sequence) - aatypes}. AlphaFold only supports 20 standard amino acids as inputs.')
if len(sequence) < MIN_SEQUENCE_LENGTH:
if len(sequence) < MIN_SEQUENCE_LENGTH:
raise Exception(f'Input sequence is too short: {len(sequence)} amino acids, while the minimum is {MIN_SEQUENCE_LENGTH}')
raise Exception(f'Input sequence is too short: {len(sequence)} amino acids, while the minimum is {MIN_SEQUENCE_LENGTH}')
if len(sequence) > MAX_SEQUENCE_LENGTH:
if len(sequence) > MAX_SEQUENCE_LENGTH:
raise Exception(f'Input sequence is too long: {len(sequence)} amino acids, while the maximum is {MAX_SEQUENCE_LENGTH}. Please use the full AlphaFold system for long sequences.')
raise Exception(f'Input sequence is too long: {len(sequence)} amino acids, while the maximum is {MAX_SEQUENCE_LENGTH}. Please use the full AlphaFold system for long sequences.')
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
```
#@title Search against genetic databases
#@title Search against genetic databases
#@markdown Once this cell has been executed, you will see
#@markdown Once this cell has been executed, you will see
#@markdown statistics about the multiple sequence alignment
#@markdown statistics about the multiple sequence alignment
#@markdown (MSA) that will be used by AlphaFold. In particular,
#@markdown (MSA) that will be used by AlphaFold. In particular,
#@markdown you’ll see how well each residue is covered by similar
#@markdown you’ll see how well each residue is covered by similar
indices = np.indices((len(rounded_errors), len(rounded_errors))) + 1
indices = np.indices((len(rounded_errors), len(rounded_errors))) + 1
indices_1 = indices[0].flatten().tolist()
indices_1 = indices[0].flatten().tolist()
indices_2 = indices[1].flatten().tolist()
indices_2 = indices[1].flatten().tolist()
pae_data = json.dumps([{
pae_data = json.dumps([{
'residue1': indices_1,
'residue1': indices_1,
'residue2': indices_2,
'residue2': indices_2,
'distance': rounded_errors.flatten().tolist(),
'distance': rounded_errors.flatten().tolist(),
'max_predicted_aligned_error': max_pae.item()
'max_predicted_aligned_error': max_pae.item()
}],
}],
indent=None,
indent=None,
separators=(',', ':'))
separators=(',', ':'))
with open(pae_output_path, 'w') as f:
with open(pae_output_path, 'w') as f:
f.write(pae_data)
f.write(pae_data)
# --- Download the predictions ---
# --- Download the predictions ---
!zip -q -r {output_dir}.zip {output_dir}
!zip -q -r {output_dir}.zip {output_dir}
files.download(f'{output_dir}.zip')
files.download(f'{output_dir}.zip')
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
### Interpreting the prediction
### Interpreting the prediction
Please see the [AlphaFold methods paper](https://www.nature.com/articles/s41586-021-03819-2) and the [AlphaFold predictions of the human proteome paper](https://www.nature.com/articles/s41586-021-03828-1), as well as [our FAQ](https://alphafold.ebi.ac.uk/faq) on how to interpret AlphaFold predictions.
Please see the [AlphaFold methods paper](https://www.nature.com/articles/s41586-021-03819-2) and the [AlphaFold predictions of the human proteome paper](https://www.nature.com/articles/s41586-021-03828-1), as well as [our FAQ](https://alphafold.ebi.ac.uk/faq) on how to interpret AlphaFold predictions.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
## FAQ & Troubleshooting
## FAQ & Troubleshooting
* How do I get a predicted protein structure for my protein?
* How do I get a predicted protein structure for my protein?
* Click on the _Connect_ button on the top right to get started.
* Click on the _Connect_ button on the top right to get started.
* Paste the amino acid sequence of your protein (without any headers) into the “Enter the amino acid sequence to fold”.
* Paste the amino acid sequence of your protein (without any headers) into the “Enter the amino acid sequence to fold”.
* Run all cells in the Colab, either by running them individually (with the play button on the left side) or via _Runtime_ > _Run all._
* Run all cells in the Colab, either by running them individually (with the play button on the left side) or via _Runtime_ > _Run all._
* The predicted protein structure will be downloaded once all cells have been executed. Note: This can take minutes to hours - see below.
* The predicted protein structure will be downloaded once all cells have been executed. Note: This can take minutes to hours - see below.
* How long will this take?
* How long will this take?
* Downloading the AlphaFold source code can take up to a few minutes.
* Downloading the AlphaFold source code can take up to a few minutes.
* Downloading and installing the third-party software can take up to a few minutes.
* Downloading and installing the third-party software can take up to a few minutes.
* The search against genetic databases can take minutes to hours.
* The search against genetic databases can take minutes to hours.
* Running AlphaFold and generating the prediction can take minutes to hours, depending on the length of your protein and on which GPU-type Colab has assigned you.
* Running AlphaFold and generating the prediction can take minutes to hours, depending on the length of your protein and on which GPU-type Colab has assigned you.
* My Colab no longer seems to be doing anything, what should I do?
* My Colab no longer seems to be doing anything, what should I do?
* Some steps may take minutes to hours to complete.
* Some steps may take minutes to hours to complete.
* If nothing happens or if you receive an error message, try restarting your Colab runtime via _Runtime_ > _Restart runtime_.
* If nothing happens or if you receive an error message, try restarting your Colab runtime via _Runtime_ > _Restart runtime_.
* If this doesn’t help, try resetting your Colab runtime via _Runtime_ > _Factory reset runtime_.
* If this doesn’t help, try resetting your Colab runtime via _Runtime_ > _Factory reset runtime_.
* How does this compare to the open-source version of AlphaFold?
* How does this compare to the open-source version of AlphaFold?
* This Colab version of AlphaFold searches a selected portion of the BFD dataset and currently doesn’t use templates, so its accuracy is reduced in comparison to the full version of AlphaFold that is described in the [AlphaFold paper](https://doi.org/10.1038/s41586-021-03819-2) and [Github repo](https://github.com/deepmind/alphafold/)(the full version is available via the inference script).
* This Colab version of AlphaFold searches a selected portion of the BFD dataset and currently doesn’t use templates, so its accuracy is reduced in comparison to the full version of AlphaFold that is described in the [AlphaFold paper](https://doi.org/10.1038/s41586-021-03819-2) and [Github repo](https://github.com/deepmind/alphafold/)(the full version is available via the inference script).
* What is a Colab?
* What is a Colab?
* See the [Colab FAQ](https://research.google.com/colaboratory/faq.html).
* See the [Colab FAQ](https://research.google.com/colaboratory/faq.html).
* I received a warning “Notebook requires high RAM”, what do I do?
* I received a warning “Notebook requires high RAM”, what do I do?
* The resources allocated to your Colab vary. See the [Colab FAQ](https://research.google.com/colaboratory/faq.html) for more details.
* The resources allocated to your Colab vary. See the [Colab FAQ](https://research.google.com/colaboratory/faq.html) for more details.
* You can execute the Colab nonetheless.
* You can execute the Colab nonetheless.
* I received an error “Colab CPU runtime not supported” or “No GPU/TPU found”, what do I do?
* I received an error “Colab CPU runtime not supported” or “No GPU/TPU found”, what do I do?
* Colab CPU runtime is not supported. Try changing your runtime via _Runtime_ > _Change runtime type_ > _Hardware accelerator_ > _GPU_.
* Colab CPU runtime is not supported. Try changing your runtime via _Runtime_ > _Change runtime type_ > _Hardware accelerator_ > _GPU_.
* The type of GPU allocated to your Colab varies. See the [Colab FAQ](https://research.google.com/colaboratory/faq.html) for more details.
* The type of GPU allocated to your Colab varies. See the [Colab FAQ](https://research.google.com/colaboratory/faq.html) for more details.
* If you receive “Cannot connect to GPU backend”, you can try again later to see if Colab allocates you a GPU.
* If you receive “Cannot connect to GPU backend”, you can try again later to see if Colab allocates you a GPU.
*[Colab Pro](https://colab.research.google.com/signup) offers priority access to GPUs.
*[Colab Pro](https://colab.research.google.com/signup) offers priority access to GPUs.
* Does this tool install anything on my computer?
* Does this tool install anything on my computer?
* No, everything happens in the cloud on Google Colab.
* No, everything happens in the cloud on Google Colab.
* At the end of the Colab execution a zip-archive with the obtained prediction will be automatically downloaded to your computer.
* At the end of the Colab execution a zip-archive with the obtained prediction will be automatically downloaded to your computer.
* How should I share feedback and bug reports?
* How should I share feedback and bug reports?
* Please share any feedback and bug reports as an [issue](https://github.com/deepmind/alphafold/issues) on Github.
* Please share any feedback and bug reports as an [issue](https://github.com/deepmind/alphafold/issues) on Github.
## Related work
## Related work
Take a look at these Colab notebooks provided by the community (please note that these notebooks may vary from our validated AlphaFold system and we cannot guarantee their accuracy):
Take a look at these Colab notebooks provided by the community (please note that these notebooks may vary from our validated AlphaFold system and we cannot guarantee their accuracy):
* The [ColabFold AlphaFold2 notebook](https://colab.research.google.com/github/sokrypton/ColabFold/blob/main/AlphaFold2.ipynb) by Sergey Ovchinnikov, Milot Mirdita and Martin Steinegger, which uses an API hosted at the Södinglab based on the MMseqs2 server ([Mirdita et al. 2019, Bioinformatics](https://academic.oup.com/bioinformatics/article/35/16/2856/5280135)) for the multiple sequence alignment creation.
* The [ColabFold AlphaFold2 notebook](https://colab.research.google.com/github/sokrypton/ColabFold/blob/main/AlphaFold2.ipynb) by Sergey Ovchinnikov, Milot Mirdita and Martin Steinegger, which uses an API hosted at the Södinglab based on the MMseqs2 server ([Mirdita et al. 2019, Bioinformatics](https://academic.oup.com/bioinformatics/article/35/16/2856/5280135)) for the multiple sequence alignment creation.
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# License and Disclaimer
# License and Disclaimer
This is not an officially-supported Google product.
This is not an officially-supported Google product.
This Colab notebook and other information provided is for theoretical modelling only, caution should be exercised in its use. It is provided ‘as-is’ without any warranty of any kind, whether expressed or implied. Information is not intended to be a substitute for professional medical advice, diagnosis, or treatment, and does not constitute medical or other professional advice.
This Colab notebook and other information provided is for theoretical modelling only, caution should be exercised in its use. It is provided ‘as-is’ without any warranty of any kind, whether expressed or implied. Information is not intended to be a substitute for professional medical advice, diagnosis, or treatment, and does not constitute medical or other professional advice.
Copyright 2021 DeepMind Technologies Limited.
Copyright 2021 DeepMind Technologies Limited.
## AlphaFold Code License
## AlphaFold Code License
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
## Model Parameters License
## Model Parameters License
The AlphaFold parameters are made available for non-commercial use only, under the terms of the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. You can find details at: https://creativecommons.org/licenses/by-nc/4.0/legalcode
The AlphaFold parameters are made available for non-commercial use only, under the terms of the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. You can find details at: https://creativecommons.org/licenses/by-nc/4.0/legalcode
## Third-party software
## Third-party software
Use of the third-party software, libraries or code referred to in the [Acknowledgements section](https://github.com/deepmind/alphafold/#acknowledgements) in the AlphaFold README may be governed by separate terms and conditions or license provisions. Your use of the third-party software, libraries or code is subject to any such terms and you should check that you can comply with any applicable restrictions or terms and conditions before use.
Use of the third-party software, libraries or code referred to in the [Acknowledgements section](https://github.com/deepmind/alphafold/#acknowledgements) in the AlphaFold README may be governed by separate terms and conditions or license provisions. Your use of the third-party software, libraries or code is subject to any such terms and you should check that you can comply with any applicable restrictions or terms and conditions before use.
## Mirrored Databases
## Mirrored Databases
The following databases have been mirrored by DeepMind, and are available with reference to the following:
The following databases have been mirrored by DeepMind, and are available with reference to the following:
* UniRef90: v2021\_03 (unmodified), by The UniProt Consortium, available under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/).
* UniRef90: v2021\_03 (unmodified), by The UniProt Consortium, available under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/).
* MGnify: v2019\_05 (unmodified), by Mitchell AL et al., available free of all copyright restrictions and made fully and freely available for both non-commercial and commercial use under [CC0 1.0 Universal (CC0 1.0) Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).
* MGnify: v2019\_05 (unmodified), by Mitchell AL et al., available free of all copyright restrictions and made fully and freely available for both non-commercial and commercial use under [CC0 1.0 Universal (CC0 1.0) Public Domain Dedication](https://creativecommons.org/publicdomain/zero/1.0/).
* BFD: (modified), by Steinegger M. and Söding J., modified by DeepMind, available under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by/4.0/). See the Methods section of the [AlphaFold proteome paper](https://www.nature.com/articles/s41586-021-03828-1) for details.
* BFD: (modified), by Steinegger M. and Söding J., modified by DeepMind, available under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by/4.0/). See the Methods section of the [AlphaFold proteome paper](https://www.nature.com/articles/s41586-021-03828-1) for details.