{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Circular Molecules\n", "\n", "> ### In this tutorial we will cover:\n", "> - how we can build circular structures in BuildAMol" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sometimes, the molecules we want to build are circular. This poses a challenge to BuildAMol which is tailored to linear molecules. In fact, BuildAMol's rotational optimization algorithms for improving conformations are useless for circular structures. Hence, in pure BuildAMol we cannot build circular molecules at this point!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For small rings it is usually possible to find reference components that already contain these rings, allowing users to circumvent the problem altogether by smart choices of starting compounds. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "However, didn't the tutorial title suggest that we _could_ build circular structures? Well, yes, we can - it's just not something that BuildAMol _inherently_ can do. But this is where BuildAMol's excellent integratability with other libraries comes in handy. \n", "\n", "The cheminformatics library `RDKit` uses a molecular force-field optimization that is perfectly able to handle ring-like structures. So, in order to build circular structures in BuildAMol, we (1) create the structure we want linearly, (2) \"circularize\" it by adding the necessary bonds, and (3) export it to RDKit to perform the conformational optimization. If after cricularization our building process is not yet complete, we can always (4) import the molecule back into BuildAMol to continue our work." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Going from linear to circular\n", "\n", "Let's make a super simple circular poly-Histidine." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import buildamol as bam\n", "bam.visual.set_backend(\"py3dmol\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# load the amino acids\n", "bam.load_amino_acids()\n", "\n", "# make a histidine\n", "his = bam.molecule(\"HIS\")\n", "\n", "# and make a polymer of 20 histidines\n", "peptide_link = bam.get_linkage(\"LINK\") # get the peptide linkage is just called LINK in the database\n", "his.repeat(20, peptide_link)\n", "\n", "his.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have our linear poly-histidine let's add a \"circular\" bond by connecting the first residue to the last residue (don't worry about the side chains at this point). We cannot use `bam.connect` or the `attach` method for this, however, because these methods would transpose the atom coordinates in our molecule, completely twisting the structure. But it's no trouble to manually add one bond and remove two atoms without adjusting the atom coordinates. So let's do it." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# luckily the linkage can also be applied directly to make bonds\n", "# without adjusting the atom placements. We simply have to specify the target and source residues (first and last)\n", "# of the \"his\" molecule, which is both the source and target molecule in this case\n", "peptide_link.apply(target=his, source=his, target_residue=-1, source_residue=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we look at the residue graph again, we will now see a new very looong bond spanning the entire length of the polymer." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "his.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Optimize with RDKit\n", "\n", "Alright, we now have a \"pseudo-circular\" molecule. However, it's actual structure is still a bad one because of the impossibly long bond between the first and last residues. And all the side chains still look somewhat crooked... To fix this we can use RDKit's energy minimization. Luckily, we can use the Molecule's `optimize` method with the argument `algorithm='rdkit'` to do so:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol

\n
\n", "text/html": [ "
\n", "

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n", " jupyter labextension install jupyterlab_3dmol

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# optimize the histidine-ring structure using RDKit to get a true ring structure\n", "his = his.optimize(algorithm=\"rdkit\")\n", "\n", "# and show the structure\n", "his.show()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# let's save the structure to a pdb file\n", "his.to_pdb(\"./files/his20.pdb\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And there it is, a nice circle of histidines!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So, that's it for this tutorial. Building circular structures is not so difficult after all, but it does involve making use of BuildAMol's integratability features. Thank you for checking out this tutorial and good luck with your research!" ] } ], "metadata": { "kernelspec": { "display_name": "glyco2", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.1.-1" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }