{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Work with protein interfaces\n", "\n", "Start from a selected interface ID and rebuild its two-chain coordinate view. Use [Query the release tables](2_query_filter_index.ipynb) to select interfaces and {ref}`Protein interfaces ` for the column definitions." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import biotite.structure as struc\n", "import pandas as pd\n", "\n", "from plinder.core import PlinderInterface" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Rebuild one interface\n", "\n", "`PlinderInterface` expands the two selected assembly-chain instances from the source mmCIF revision recorded by the release." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "interface = PlinderInterface(system_id=\"7cm8__1__1.A--2.A\")\n", "interface" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pd.DataFrame(\n", " {\n", " \"chain\": interface.chains,\n", " \"full_sequence_length\": [\n", " len(interface.sequences[chain]) for chain in interface.chains\n", " ],\n", " \"resolved_atom_count\": [\n", " len(interface.chain_structures[chain]) for chain in interface.chains\n", " ],\n", " }\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`sequences` contains the full deposited polymer sequences; coordinate arrays contain only resolved atoms." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Interface residues and coordinate views\n", "\n", "The residue masks are defined over the complete two-chain `atom_array`. Their keys match the assembly-chain IDs in `interface_annotations`." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "summary = []\n", "for chain, mask in interface.interface_residue_masks.items():\n", " atoms = interface.atom_array[mask]\n", " summary.append(\n", " {\n", " \"chain\": chain,\n", " \"interface_residues\": struc.get_residue_count(atoms),\n", " \"interface_atoms\": len(atoms),\n", " }\n", " )\n", "pd.DataFrame(summary)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(f\"Two-chain atoms: {len(interface.atom_array):,}\")\n", "print(f\"Interface atoms: {len(interface.interface_structure):,}\")\n", "print(f\"Reconstructed mmCIF: {interface.interface_cif}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`interface_cif` is a `pathlib.Path`; `atom_array`, the values of `chain_structures`, and `interface_structure` are Biotite `AtomArray` objects. The written mmCIF is self-contained and contains only the selected interface chains." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.12" } }, "nbformat": 4, "nbformat_minor": 4 }