{ "cells": [ { "cell_type": "markdown", "id": "a134b6d0", "metadata": {}, "source": [ "# TMol How-To Guide — Selections\n", "\n", "[](https://colab.research.google.com/github/RosettaCommons/tmol/blob/main/docs/tutorial/05_selections.ipynb)" ] }, { "cell_type": "markdown", "id": "a46c8e3c", "metadata": {}, "source": [ "## 5. Selections" ] }, { "cell_type": "markdown", "id": "f9c854e2", "metadata": {}, "source": [ "Every selection in TMol is a plain boolean `torch.Tensor` -- block-shaped (`[n_poses, max_n_blocks]`) or atom-shaped (`[n_poses, max_n_atoms]`) -- built by hand from whatever a `PoseStack` already exposes. There's no dedicated \"Selection\" class or query language, just tensors and boolean algebra; this notebook collects the common patterns in one place." ] }, { "cell_type": "markdown", "id": "0dbb0add", "metadata": {}, "source": [ "### Setup" ] }, { "cell_type": "markdown", "id": "c452efb8", "metadata": {}, "source": [ "Wheel install, imports, seeding, and device selection live in [notebook_setup.py](https://github.com/RosettaCommons/tmol/blob/main/docs/tutorial/notebook_setup.py)." ] }, { "cell_type": "code", "execution_count": 1, "id": "fe69dc3b", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T17:52:15.549729Z", "iopub.status.busy": "2026-10-20T17:52:15.549459Z", "iopub.status.idle": "2026-10-20T17:52:20.551707Z", "shell.execute_reply": "2026-10-20T17:52:20.551010Z" }, "tags": [ "collapse-code" ] }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Environment variable CCD_MIRROR_PATH not set. Will not be able to use function requiring this variable. To set it you may:\n", " (1) add the line 'export VAR_NAME=path/to/variable' to your .bashrc or .zshrc file\n", " (2) set it in your current shell with 'export VAR_NAME=path/to/variable'\n", " (3) write it to a .env file in the root of the atomworks.io repository\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Environment variable PDB_MIRROR_PATH not set. Will not be able to use function requiring this variable. To set it you may:\n", " (1) add the line 'export VAR_NAME=path/to/variable' to your .bashrc or .zshrc file\n", " (2) set it in your current shell with 'export VAR_NAME=path/to/variable'\n", " (3) write it to a .env file in the root of the atomworks.io repository\n" ] } ], "source": [ "try:\n", " import google.colab # noqa: F401\n", "except ImportError:\n", " IN_COLAB = False\n", "else:\n", " IN_COLAB = True\n", "\n", "if IN_COLAB:\n", " from urllib.request import urlretrieve\n", "\n", " urlretrieve(\n", " \"https://raw.githubusercontent.com/RosettaCommons/tmol/\"\n", " \"main/docs/tutorial/notebook_setup.py\",\n", " \"notebook_setup.py\",\n", " )\n", "\n", "from notebook_setup import * # noqa: F401,F403\n", "\n", "device, param_db = setup()\n" ] }, { "cell_type": "markdown", "id": "4d92a968", "metadata": {}, "source": [ "`pose_stack.pdb_info` is where most chain/residue-identity selections start: parallel `[pose, block]` arrays `chain_labels`, `residue_labels`, and `residue_insertion_codes`, plus per-atom `atom_occupancy` and `atom_b_factor`. We use [1BL8](https://www.rcsb.org/structure/1BL8) (the protein-protein interface example from section 2) as the running example, for its multiple chains and three bound potassium ions as a second polymer type." ] }, { "cell_type": "code", "execution_count": 2, "id": "e2b80e53", "metadata": { "execution": { "iopub.execute_input": "2026-10-20T17:52:20.553998Z", "iopub.status.busy": "2026-10-20T17:52:20.553538Z", "iopub.status.idle": "2026-10-20T17:52:28.761595Z", "shell.execute_reply": "2026-10-20T17:52:28.760860Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "n_poses=1, max_n_blocks=391\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/runner/work/tmol/tmol/.venv/lib/python3.12/site-packages/biotite/structure/io/pdb/file.py:629: DeprecationWarning: The chararray class is deprecated and will be removed in a future release. Use an ndarray with a string or bytes dtype instead.\n", " record = np.char.array(np.where(array.hetero, \"HETATM\", \"ATOM\"))\n" ] }, { "data": { "application/3dmoljs_load.v0": "
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.