{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Biomolecules and BuildAMol\n", "\n", "> ### In this tutorial we will cover:\n", "> - how we can use the packages in the `bio` extension to make\n", "> - peptides\n", "> - lipids\n", "> - glycans\n", "> - oligonucleotides" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Bio Extension\n", "\n", "BuildAMol comes with a `bio` extension that contains functions to quickly model small biomolecules. Currently available are functions to model peptides, glycans, different types of lipids, as well as small stretches of DNA or RNA. \n", "\n", "We can use these by importing the respective packages from the extension. Here we will talk more about them. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making a Peptide\n", "\n", "We can use the `peptide` function from the `bio.proteins` package to obtain a model from a single-letter code amino acid sequence. The implementation is very low-level. While it will work with large sequences of amino acids, do not think that you can use it to model protein structures! It can make models for small peptides but cannot model secondary or tertiary structures!" ] }, { "cell_type": "code", "execution_count": 12, "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": [ "import buildamol as bam\n", "\n", "# import the proteins extension\n", "from buildamol.extensions.bio import proteins\n", "\n", "# make a peptide\n", "peptide_seq = \"MAARGRRAWLSVLLGLVLGF\"\n", "peptide = proteins.peptide(peptide_seq)\n", "\n", "# now optimize using rdkit's forcefield\n", "peptide.optimize(algorithm=\"rdkit\")\n", "\n", "# show the peptide\n", "peptide.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And there we have a peptide molecule that we can work with. Of course, it does not have any notable structure, BuildAMol does not do any kind of folding after all!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making a Glycan\n", "\n", "In glycobiology the [IUPAC nomenclature](https://iupac.qmul.ac.uk/2carb/) has been widely used to represent glycans in textual form. This is because glycans tend to produce very long and complex SMILES strings, which is also why they are often difficult to compute from SMILES. Different flavors of the IUPAC nomenclature exist. BuildAMol supports the _condensed_ version and can read text inputs in that format. \n", "\n", "To create a glycan model from an IUPAC string we can import the `glycans` extension like so:" ] }, { "cell_type": "code", "execution_count": 13, "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": [ "# import the glycans extension\n", "from buildamol.extensions.bio import glycans\n", "\n", "# make a glycan\n", "iupac = \"Gal(b1-3)[Fuc(a1-4)]Man(b1-4)GalNAc(b1-4)GlcNAc\"\n", "glycan = glycans.glycan(iupac)\n", "\n", "# now optimize using rdkit's forcefield\n", "glycan.optimize(algorithm=\"rdkit\")\n", "\n", "# show the glycan\n", "glycan.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And there we have a small glycan model that we can use further..." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making Lipids\n", "\n", "Lipids are a little more diverse than peptides or glycans. For once, the length and saturation of fatty acids can be very flexible. Furthermore, different types of lipids include different backbones or head groups. In the `lipids` extension BuildAMol offers functions to create:\n", "- fatty acids\n", "- mono-, di-, and triacylglycerols (all in the `triacylglycerol` function)\n", "- phospholipids\n", "- sphingolipids\n", "\n", "Let's explore a bit how we can work with these functions:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# import the lipids extension\n", "from buildamol.extensions.bio import lipids" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Making Fatty Acids\n", "\n", "Using the `fatty_acid` function we can control the length as well as saturation of the fatty acids we produce. The saturation can be controlled by either specifying exactly where we want double bonds and whether they are supposed to be in cis configuration, or by simply providing inputs for the number of double bonds as well as a probability of a bond to be in cis configuration. Like so we can quickly both generate specific fatty acids or a population of random ones. Here's how:" ] }, { "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": [ "# make a fatty acid with 18 carbons and 2 double bonds, with a 50% chance for cis configuration\n", "fa1 = lipids.fatty_acid(18, 2, cis=0.5)\n", "fa1.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And there we have one fatty acid! Let's make some more:" ] }, { "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": [ "# make a fatty acid with 16 carbons and one double bond at the 9th position in trans configuration\n", "# to specify individual double bonds, we use a tuple of positions rather than an integer\n", "fa2 = lipids.fatty_acid(16, (9,), cis=False)\n", "fa2.py3dmol().show()" ] }, { "cell_type": "code", "execution_count": 8, "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": [ "# make a fatty acid with 20 carbons and 2 double bonds at the 5th and 8th positions in cis and trans configuration\n", "fa3 = lipids.fatty_acid(20, (5, 8), cis=(True, False))\n", "fa3.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Feel free to play around a little more if you like. Now let's make some larger lipids using these fatty acids!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Making Acylglycerols\n", "\n", "Using the function `triacylglycerol` we can make mono-, di-, and triacylglycerols by passing one, two, or three, fatty acid molecules as arguments. Positions where no fatty acid should be we can specify by passing `None`. " ] }, { "cell_type": "code", "execution_count": 9, "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": [ "# make a triacylglycerol \n", "tag = lipids.triacylglycerol(fa1, fa2, fa3)\n", "tag.py3dmol().show()" ] }, { "cell_type": "code", "execution_count": 10, "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": [ "# make a diacylglycerol with the middle position empty\n", "dag = lipids.triacylglycerol(fa1, None, fa3)\n", "dag.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Making Phospho- and Sphingolipids\n", "\n", "Phospho- and Sphingolipids haves two fatty acid chains and one headgroup. The headgroups are more diverse in structure which is why the `phospholipid` and `sphingolipid` function require in addition to the molecules themselves also a _Linkage_ that defines how the headgroup should be connected. The Linkage only needs to specify the _source_ atom and deleters, however, the target settings will be automatically applied." ] }, { "cell_type": "code", "execution_count": 14, "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": [ "# make a phosphatidylserine\n", "ser = proteins.amino_acids.serine\n", "\n", "# define the linkage with which to attach the serine to the glycerol\n", "# (we do not need to specify the atom1 because the position of where the headgroup is attached\n", "# is already known in the glycerol, the only uncertainty is which headgroup atoms to use)\n", "link = bam.linkage(atom1=None, atom2=\"CB\", delete_in_source=[\"OG\", \"HG\"])\n", "\n", "# make the phosphatidylserine\n", "ps = lipids.phospholipid(fa1, fa2, headgroup=ser, headgroup_link=link)\n", "ps.py3dmol().show()" ] }, { "cell_type": "code", "execution_count": 15, "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": [ "# make a sphingoglycolipid\n", "# let's actually just attach the glycan we made before as a headgroup\n", "\n", "# make sure we attach the glycan via it's first (i.e. root) residue\n", "glycan.set_attach_residue(1)\n", "\n", "# define the linkage with which to attach the glycan to the sphingosine\n", "link = bam.linkage(None, \"C1\", delete_in_source=[\"O1\", \"HO1\"])\n", "\n", "# make the sphingoglycolipid\n", "sgl = lipids.sphingolipid(fa1, headgroup=glycan, headgroup_link=link)\n", "sgl.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making Nucleic Acids\n", "\n", "Oligonucleotides are again a simpler case that is very similar to the peptide extension. We can create small oligonucleotides from a sequence using the `dna` or `rna` functions like so:" ] }, { "cell_type": "code", "execution_count": 16, "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": [ "from buildamol.extensions.bio import nucleic_acids\n", "\n", "# make an RNA strand\n", "seq = \"ACCUCAAGAGACUAC\"\n", "rna = nucleic_acids.rna(seq)\n", "\n", "# now optimize using rdkit's forcefield\n", "rna.optimize(algorithm=\"rdkit\")\n", "rna.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So that just about wraps up the `bio` extension! We saw how we can build simple peptides, glycans, various lipids, and nucleic acids using easy toplevel functions. Of course, the lipids especially might require some additional post-processing to align the fatty acid chains properly (if one wanted to construct things like membranes for instance). \n", "\n", "Thanks for checking out this tutorial and good luck in your next project using BuildAMol!" ] } ], "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.11.0" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }