{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Building Workflow"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"> ### In this tutorial we will cover:\n",
"> - the basic \"workflow\" of building a larger molecule in biobuild"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Building molecules is a straightforward task in biobuild. It involves always the same steps:\n",
"\n",
"```mermaid\n",
"\n",
"flowchart TB\n",
" node_1[\"identify suitable sub-structure A\"]\n",
" node_2[\"identify suitable sub-structure B\"]\n",
" node_3[\"identify what you want to build\"]\n",
" node_4[\"identify atom to connect to B\"]\n",
" node_5[\"identify atom to connect to A\"]\n",
" node_6[\"identify atom(s) to\\nremove when connecting to B\"]\n",
" node_7[\"identify atom(s) to\\nremove when connecting to A\"]\n",
" node_8((\"connect\"))\n",
" node_9(\"repeat\")\n",
" node_3 --> node_1\n",
" node_3 --> node_2\n",
" node_1 --> node_4\n",
" node_2 --> node_5\n",
" node_1 --> node_6\n",
" node_2 --> node_7\n",
" node_6 ---> node_8\n",
" node_4 ---> node_8\n",
" node_5 --> node_8\n",
" node_7 --> node_8\n",
" node_8 --> node_9\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As for steps 1 and 2, finding a structure to build and identifying subcomponents - that's on you, biobuild cannot help you there! As for steps 3 and 4, thats where biobuild can start to help you. How do you identify which atoms to connect and which to remove? Well, by looking at the structures, of course! \n",
"\n",
"If biobuild has a linkage already defined for your specific task, great! But most of the time we want to build custom molecules for which the CHARMM force field does not conveniently have a patch defined. So we need to define the linkage ourselves. We can do this by looking at the structure, checking out what the atoms we want to connect are called, and then define our linkage. We can either connect molecules using the `Molecule.attach` method where we can directly provide the information regarding atoms-to-connect and -remove, or we first set up a `Linkage` which can then use instead. \n",
"\n",
"The advantage of setting up a `Linkage` first is that we can then re-use the same linkage time and time again, without needing to keep filling in the information manually. We can even add custom linkages to the default settings to make them permanently available whenever we use biobuild (checkout the tutorials regarding built-in resources and setting defaults). "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Working by example is usually best, so let us build the following molecule:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can start by identifying the different components that we might want to work with. For example we can choose these:\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With our components decided, we can start to build. The first step is getting the molecular structures we need. PubChem is sure to have the structures available, so we are not going to load any built-in structures."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly\n",
"plotly.offline.init_notebook_mode()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Molecule(1,2,4a,8a-tetrahydronaphthalene)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import biobuild as bb\n",
"\n",
"# get the molecules we need\n",
"phenyl_methanol = bb.molecule(\"phenylmethanol\")\n",
"aldehyde = bb.molecule(\"butyraldehyde\")\n",
"amine = bb.molecule(\"methoxyethanamine\")\n",
"naphthalene = bb.molecule(\"1,2,4a,8a-tetrahydronaphthalene\")\n",
"\n",
"# because PubChem structures use a simple enumeration rather than hierarchical atom labelling\n",
"# we can (optionally) call `autolabel` to assign more descriptive atom labels which is useful for \n",
"# defining linkages\n",
"phenyl_methanol.autolabel()\n",
"aldehyde.autolabel()\n",
"amine.autolabel()\n",
"naphthalene.autolabel() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now that our molecules are all ready, we can start building. We start by attaching the `phenyl_methanol` to the `aldehyde`. To do this, we first visualize both structures to identify the `atom ids` of the atoms we want to connect and remove in both cases."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"customdata": [
[
"O7",
1,
1,
"UNK",
"A"
]
],
"hovertemplate": "atom_element=O
x=%{x}
y=%{y}
z=%{z}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}
x=%{x}
y=%{y}
z=%{z}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}
x=%{x}
y=%{y}
z=%{z}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}