Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
615a265
Created using Colab
sokrypton Sep 16, 2026
0a7d59d
Created using Colab
sokrypton Sep 17, 2026
08cfca9
Created using Colab
sokrypton Sep 17, 2026
1b312c8
fixing style
sokrypton Sep 17, 2026
ec208bb
fixing credits
sokrypton Sep 17, 2026
2a0dcd0
stop downloading AlphaFold 3's weights, and drop the debugging comments
sokrypton Sep 17, 2026
1b4fe8d
trim the rest of the commentary in the three code cells
sokrypton Sep 17, 2026
116fe28
alphafold3's weights are a public release, so fetch them again
sokrypton Sep 17, 2026
b6bbcfe
ColabFold2_preview: alphafold3-colabfold 3.1.11
sokrypton Sep 18, 2026
0f5cac5
Enable optional RGI across supported diffusion notebooks
th2ch-g Sep 19, 2026
2b8801c
Use canonical ColabFold repository URLs in notebooks
th2ch-g Sep 19, 2026
3ca6b76
Use the toolkit native multi-restraint editor in notebooks
th2ch-g Sep 19, 2026
bc41061
Show where and how to configure RGI before running the notebook
th2ch-g Sep 19, 2026
8779af1
Restore upstream notebook presentation and use standard RGI forms
th2ch-g Sep 19, 2026
6b0a3d6
Document notebook RGI model support and remove dedicated CI
th2ch-g Sep 22, 2026
f988713
Enable OpenBind-0 RGI and collapse optional notebook controls
th2ch-g Sep 30, 2026
8f5ec5c
Preserve vanilla predictions and stream ESM-C weight loading
th2ch-g Sep 30, 2026
1fcb61d
Trim duplicate notebook and sampler regression cases
th2ch-g Sep 30, 2026
928a5ac
Show RGI controls as regular notebook cells
th2ch-g Sep 30, 2026
6949f14
Merge upstream/main (sokrypton/ColabFold) into main
th2ch-g Oct 5, 2026
a57f00a
Merge main into rgi-integration
th2ch-g Oct 5, 2026
2a2f9b9
Fix consumer Blackwell GPU dispatch and validation
th2ch-g Oct 5, 2026
7682b47
Refresh native Boltz caches across RGI switches
th2ch-g Oct 5, 2026
63c3bb0
Move RGI support column after licence in notebook tables
th2ch-g Oct 5, 2026
bcf4b6a
Add RGI citation and restore upstream defaults
th2ch-g Oct 7, 2026
6f92079
Restore upstream ColabFold README
th2ch-g Oct 7, 2026
902ce73
Include RGI paper in prediction citations and result archives
th2ch-g Oct 7, 2026
e7f8f39
Revert runtime compatibility extras and update the RGI heading
th2ch-g Oct 7, 2026
af68833
use subprocess run
YoshitakaMo Oct 9, 2026
83466dd
delete "_vanilla" from the resultant files when rgi is not used
YoshitakaMo Oct 9, 2026
3e6b076
modify RGI instructions
YoshitakaMo Oct 9, 2026
b1a128e
modify RGI instructions
YoshitakaMo Oct 9, 2026
059d62b
Merge branch 'rgi-integration' of github.com:cddlab/ColabFold_restr i…
YoshitakaMo Oct 9, 2026
bfa489b
fix conformer_chains
YoshitakaMo Oct 9, 2026
1cac26c
fix output directory
YoshitakaMo Oct 9, 2026
8561eef
Match duplicate BibTeX entries by citation key across entry types
YoshitakaMo Oct 9, 2026
4807acd
Preserve the configured output directory instead of overwriting it
YoshitakaMo Oct 9, 2026
233d6ac
fix output directory
YoshitakaMo Oct 9, 2026
b389639
update the description about the RGI
YoshitakaMo Oct 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
504 changes: 373 additions & 131 deletions AlphaFold3_of3.ipynb

Large diffs are not rendered by default.

160 changes: 134 additions & 26 deletions Boltz1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
"#@markdown - Use `:` to specify multiple DNA sequences\n",
"jobname = 'test' #@param {type:\"string\"}\n",
"\n",
"msa_mode = \"mmseqs2_server\" #@param [\"mmseqs2_server\", \"single_sequence\"]\n",
"import json\n",
"for _k, _v in json.loads(os.environ.get('BOLTZ_NB_OVERRIDES', '{}')).items():\n",
" if _k in globals(): globals()[_k] = _v\n",
"\n",
"# Clean up the query sequence and jobname\n",
"query_sequence = \"\".join(query_sequence.split())\n",
"ligand_input = \"\".join(ligand_input.split())\n",
Expand Down Expand Up @@ -219,7 +224,11 @@
"# Optionally, print the output for verification\n",
"#print(f\"Generated FASTA file '{queries_fasta}':\\n\")\n",
"#for header, sequence in fasta_entries:\n",
"# print(f\"{header}\\n{sequence}\\n\")\n"
"# print(f\"{header}\\n{sequence}\\n\")\n",
"\n",
"print('Chain IDs for restraints:')\n",
"for header, sequence in fasta_entries:\n",
" print(header.split('|')[0].lstrip('>'), header.split('|')[1], len(sequence) if header.split('|')[1] == 'protein' else '')\n"
],
"metadata": {
"cellView": "form",
Expand All @@ -228,6 +237,60 @@
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "rgi-restraints",
"cellView": "form"
},
"outputs": [],
"source": [
"#@title RGI: Making restraint-guided protein folding inference accessible to all! (optional)\n",
"#@markdown Fill in this form before **Runtime → Run all**. Leave `use_rgi` off for vanilla. Leave unused restraint\n",
"#@markdown fields empty.\n",
"use_rgi = False #@param {type:\"boolean\"}\n",
"#@markdown **distance** — enter two atom selections and their target distance in Å. Example: `chain A and resid\n",
"#@markdown 1 to 10` and `chain A and resid 40 to 50`, with `target_distance = 25`.\n",
"distance_atom_selection1 = \"\" #@param {type:\"string\"}\n",
"distance_atom_selection2 = \"\" #@param {type:\"string\"}\n",
"target_distance = 25 #@param {type:\"raw\"}\n",
"#@markdown **conformer** — enter chain IDs such as `B,C`, or `ligands` for all ligand chains. Leave empty to\n",
"#@markdown disable.\n",
"conformer_chains = \"\" #@param {type:\"string\"}\n",
"#@markdown **angle** — enter three atom selections and the target in degrees. Selection 2 is the vertex. Leave\n",
"#@markdown all three empty to disable.\n",
"angle_atom_selection1 = \"\" #@param {type:\"string\"}\n",
"angle_atom_selection2 = \"\" #@param {type:\"string\"}\n",
"angle_atom_selection3 = \"\" #@param {type:\"string\"}\n",
"target_angle = 90 #@param {type:\"raw\"}\n",
"#@markdown **custom** — set named selections and an energy expression, e.g. `harmonic(distance(A, B), 25.0)`.\n",
"#@markdown Leave the energy empty to disable.\n",
"custom_selections = {\"A\": \"chain A and resid 1 to 10\", \"B\": \"chain A and resid 40 to 50\"} #@param {type:\"raw\"}\n",
"custom_energy = \"\" #@param {type:\"string\"}\n",
"#@markdown **RMSD** — upload a reference using Colab's **Files → Upload** and enter its filename in either\n",
"#@markdown `ref_pdb` or `ref_cif`. Leave both filenames empty to disable. Empty target/ref selections mean the\n",
"#@markdown whole structure; e.g. `chain A and name CA` selects C-alpha atoms.\n",
"ref_pdb = \"\" #@param {type:\"string\"}\n",
"ref_cif = \"\" #@param {type:\"string\"}\n",
"atom_selection_target = \"\" #@param {type:\"string\"}\n",
"atom_selection_ref = \"\" #@param {type:\"string\"}\n",
"target_rmsd = 0 #@param {type:\"raw\"}\n",
"#@markdown **Multiple restraints:** enter lists in the same fields, e.g. `distance_atom_selection2 = [\"chain A\n",
"#@markdown and resid 20\", \"chain A and resid 40\"]` and `target_distance = [15, 25]`. A single selection/value is\n",
"#@markdown shared across the entries. All non-single lists must have the same length.\n",
"#@markdown **Selections:** all fields accept the full RGI-toolkit selection language. Residues start at 1 within\n",
"#@markdown each chain. The input cell prints the chain IDs. Distance and angle use atom-group centroids.\n",
"#@markdown **Advanced (optional)** — an ordinary RGI-toolkit dict for additional restraints, flat-bottomed\n",
"#@markdown penalties, weights, activation windows or conformer settings. Lists append to the fields above. Use\n",
"#@markdown `{\"config_path\": \"restraints.yaml\"}` to read a file. [Examples and native config\n",
"#@markdown reference](https://github.com/cddlab/rgi_toolkit/blob/main/docs/colabfold.md).\n",
"restraints_config = {} #@param {type:\"raw\"}\n",
"#@markdown After changing this form, rerun this cell and the prediction cell, or use **Run all**. Settings are\n",
"#@markdown saved in the notebook itself.\n",
"#@markdown When switching `use_rgi`, rerun **Install dependencies** too to select the matching Boltz environment.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -238,34 +301,39 @@
"outputs": [],
"source": [
"#@title Install dependencies\n",
"%%time\n",
"import os\n",
"if not os.path.isfile(\"COLABFOLD_READY\"):\n",
" print(\"installing colabfold...\")\n",
" os.system(\"pip install -q --no-warn-conflicts 'colabfold[alphafold-minus-jax] @ git+https://github.com/sokrypton/ColabFold'\")\n",
" if os.environ.get('TPU_NAME', False) != False:\n",
" os.system(\"pip uninstall -y jax jaxlib\")\n",
" os.system(\"pip install --no-warn-conflicts --upgrade dm-haiku==0.0.10 'jax[cuda12_pip]'==0.3.25 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html\")\n",
" os.system(\"ln -s /usr/local/lib/python3.*/dist-packages/colabfold colabfold\")\n",
" os.system(\"ln -s /usr/local/lib/python3.*/dist-packages/alphafold alphafold\")\n",
" # hack to fix TF crash\n",
" os.system(\"rm -f /usr/local/lib/python3.*/dist-packages/tensorflow/core/kernels/libtfkernel_sobol_op.so /usr/local/lib/python3.*/dist-packages/tensorflow/lite/python/*/*.so\")\n",
" os.system(\"touch COLABFOLD_READY\")\n",
"\n",
"if not os.path.isfile(\"BOLZ_READY\"):\n",
" os.system(\"apt-get install -y aria2\")\n",
" os.system(\"pip install -q --no-warn-conflicts boltz\")\n",
" os.system(\"mkdir weights\")\n",
" os.system(\"aria2c -d weights -x8 -s8 https://colabfold.steineggerlab.workers.dev/boltz1.ckpt\")\n",
" os.system(\"aria2c -d weights -x8 -s8 https://colabfold.steineggerlab.workers.dev/ccd.pkl\")\n",
" os.system(\"touch BOLZ_READY\")"
"import shutil, subprocess, sys\n",
"from pathlib import Path\n",
"use_rgi = globals().get('use_rgi', False)\n",
"if shutil.which('uv') is None:\n",
" subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', 'uv'], check=True)\n",
"_colabfold_source = os.environ.get('RGI_COLABFOLD_SOURCE', 'git+https://github.com/sokrypton/ColabFold')\n",
"_toolkit_source = os.environ.get('RGI_TOOLKIT_SOURCE', 'git+https://github.com/cddlab/rgi_toolkit.git@054cd4c81a7f198df12fdd72f88d5caa7f8d9615')\n",
"subprocess.run(['uv', 'pip', 'install', '--python', sys.executable, _colabfold_source], check=True)\n",
"# Boltz requires Python 3.12; isolate it from Colab's Python and NumPy versions.\n",
"boltz_env = Path('.cache') / ('boltz-rgi' if use_rgi else 'boltz-vanilla')\n",
"if not (boltz_env / 'bin/python').exists():\n",
" subprocess.run(['uv', 'venv', '--python', '3.12', str(boltz_env)], check=True)\n",
"boltz_python = str(boltz_env / 'bin/python')\n",
"_boltz_source = ('git+https://github.com/cddlab/boltz_restr.git@rgi-integration' if use_rgi else 'boltz==2.2.1')\n",
"subprocess.run(['uv', 'pip', 'install', '--python', boltz_python, _boltz_source], check=True)\n",
"if use_rgi:\n",
" subprocess.run(['uv', 'pip', 'install', '--python', sys.executable, _toolkit_source], check=True)\n",
" subprocess.run(['uv', 'pip', 'install', '--python', boltz_python, _toolkit_source], check=True)\n"
]
},
{
"cell_type": "code",
"source": [
"#@title Generate MSA with ColabFold\n",
"!colabfold_batch \"{queries_path}\" \"{jobname}\" --msa-only"
"if msa_mode == 'mmseqs2_server' and csv_entries:\n",
" from colabfold.colabfold import run_mmseqs2\n",
" for seq_id, seq in csv_entries:\n",
" msa_path = Path(jobname) / f'{seq_id}.a3m'\n",
" if not msa_path.exists():\n",
" a3m = run_mmseqs2([seq], str(Path(jobname) / (seq_id + '_msa')), use_env=True)[0]\n",
" msa_path.write_text(a3m)\n",
"else:\n",
" print('Single sequence: skipping the MSA server.')\n"
],
"metadata": {
"cellView": "form",
Expand All @@ -278,7 +346,46 @@
"cell_type": "code",
"source": [
"#@title Predict structure using boltz\n",
"!boltz predict --out_dir \"{jobname}\" \"{jobname}/{jobname}.fasta\" --cache weights"
"import yaml\n",
"num_recycles = 3 #@param {type:\"integer\"}\n",
"num_diffusion_samples = 1 #@param {type:\"integer\"}\n",
"seed = 42 #@param {type:\"integer\"}\n",
"# Read the standard Colab fields before starting inference.\n",
"if globals().get('use_rgi', False):\n",
" from rgi_toolkit.notebook_colab import config_from_fields\n",
" rgi_config, rgi_conformer_chains = config_from_fields(globals())\n",
"else:\n",
" use_rgi = False\n",
" rgi_config, rgi_conformer_chains = None, ''\n",
"\n",
"from colabfold.rgi.boltz import notebook_input\n",
"\n",
"# Use YAML so the predictor can read the shared RGI config and entity opt-ins.\n",
"boltz_input = notebook_input(fasta_entries, config=rgi_config if use_rgi else None,\n",
" conformer_chains=rgi_conformer_chains, single_sequence=(msa_mode == 'single_sequence'))\n",
"input_yaml = Path(jobname) / f'{jobname}.yaml'\n",
"input_yaml.write_text(yaml.safe_dump(boltz_input, sort_keys=False))\n",
"# Refresh RGI features without changing vanilla-only cache reuse.\n",
"boltz_output = Path(jobname) / f'boltz_results_{input_yaml.stem}'\n",
"rgi_cache_marker = boltz_output / '.rgi-enabled'\n",
"if use_rgi or rgi_cache_marker.exists():\n",
" import shutil\n",
" if boltz_output.exists():\n",
" shutil.rmtree(boltz_output)\n",
" if use_rgi:\n",
" boltz_output.mkdir(parents=True, exist_ok=True)\n",
" rgi_cache_marker.touch()\n",
"subprocess.run([boltz_python, '-m', 'boltz.main', 'predict', str(input_yaml),\n",
" '--model', 'boltz1', '--out_dir', jobname, '--cache', str(Path('.cache') / 'boltz-weights'),\n",
" '--recycling_steps', str(num_recycles), '--diffusion_samples', str(num_diffusion_samples),\n",
" '--seed', str(seed), '--override'], check=True)\n",
"import glob\n",
"if not glob.glob(f'{jobname}/boltz_results_{jobname}/predictions/{jobname}/*.cif'):\n",
" raise RuntimeError('Prediction produced no structure files. Check the log above.')\n",
"if use_rgi:\n",
" from colabfold.citations import write_rgi_citation\n",
" write_rgi_citation(boltz_output)\n",
"print('RGI ON: check nonzero built-spec counts and final energies above.' if use_rgi else 'Vanilla prediction complete.')\n"
],
"metadata": {
"cellView": "form",
Expand Down Expand Up @@ -307,7 +414,8 @@
"with zipfile.ZipFile(zip_filename, 'w') as zipf:\n",
" coverage_png_files = glob.glob(os.path.join(jobname, '*_coverage.png'))\n",
" a3m_files = glob.glob(os.path.join(jobname, '*.a3m'))\n",
" for file in coverage_png_files + a3m_files:\n",
" bibtex_files = glob.glob(os.path.join(jobname, f'boltz_results_{jobname}', 'cite.bibtex'))\n",
" for file in coverage_png_files + a3m_files + [str(input_yaml)] + bibtex_files:\n",
" arcname = os.path.basename(file) # Use only the file name\n",
" zipf.write(file, arcname=arcname)\n",
"\n",
Expand All @@ -334,4 +442,4 @@
"outputs": []
}
]
}
}
Loading
Loading