{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional Groups\n", "\n", "> ### In this tutorial we will cover:\n", "> - how we can use functional groups in BuildAMol to connect molecules" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "> ### NOTE: \n", "> The *functional groups* that are discussed here **have been succeeded** by the **new** `Reactivity` classes that offer a greater flexibility and easy-of-use. If you are interested in learning more about BuildAMol+Chemistry and you are not already invested in using the functional groups it is recommended to check out the tutorial on the Reactivities instead! You can always come back to this tutorial if the Reactivities are not for you :-)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "BuildAMol offers great flexibility when connecting molecules. It is designed create any kind of single-bond between any two atoms and is *not* restrained to work in the realm of the \"chemically plausible\". " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "However, BuildAMol does know about some functional groups (which may be expanded upon in the future). Their purpose is to automatically generate a `Linkage` when connecting two molecules, without the user having to identify precicely which atoms they want to connect. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The catch is that BuildAMol only supports a handful of functional groups like this and due to its atom-substitution philosophy can only model substitution reactions but not addition reactions. That is to say, the limit is that the functional group needs to be able to loose some of it's atoms in the reaction as leaving group (e.g. the OH that is lost as water from a carboxyl group when targeted by a nucleophilic attach). " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example\n", "\n", "Nothing beats a practical example to understand how we can use functional groups in BuildAMol to connect molecules. Let's say we want to connect benzaldehyde to m-Toluidine like so:\n", "\n", "\n", "\n", "So we want to connect the aldehyde of benzaldehyde to the amine of m-Toluidine. Specifying the linkage manually would not be a big deal, especially if we `autolabel` them first. However, since both molecules only have one single aldehyde and amine respectively, we can quicken up the process by specifying that we want to connect the two molecules using the functional groups, and thus automatically infer the atoms involved in the linkage. Here's how:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import buildamol as bam\n", "bam.visual.set_backend(\"py3dmol\")\n", "\n", "bam.load_small_molecules()\n", "\n", "# first make the component molecules\n", "benzaldehyde = bam.molecule(\"benzaldehyde\")\n", "toluidine = bam.molecule(\"m-toluidine\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have our component molecules, we can connect them. Instead of looking at them and identifying the atoms manually we will now use the functional groups to automatically generate the linkage. There is two ways we can do this:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Making a linkage with functional groups\n", "\n", "We can use the classmethod `Linkage.from_functional_groups` to generate a linkage which we can then use to connect the molecules. To do so, we need to specify which molecules we want to work with, and which functional groups to use. Functional groups can be found in the `buildamol.structural.groups` module. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Linkage(carbonyl_amine)\n", "AbstractBond(atom1=\"C1'\", atom2='N1', K=None, length=None)\n", "([], [])\n" ] } ], "source": [ "# we need to specify an electrophile and a nucleophile\n", "# for this to work. emol / egroup are the molecule and functional group\n", "# that serve as electrophile, and nmol / ngroup are the corresponding nucleophile.\n", "link = bam.Linkage.from_functional_groups(\n", " emol=benzaldehyde, egroup=bam.structural.groups.aldehyde,\n", " nmol=toluidine, ngroup=bam.structural.groups.amine\n", ")\n", "\n", "print(link, link.bond, link.deletes, sep=\"\\n\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So, our linkage identified atoms `C1` and `N1` to be the atoms that will form a new bond. No atoms to delete were found since both atoms have hydrogen neighbors that can be removed as leaving groups." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
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
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
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
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
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
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
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
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
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
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
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
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
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
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