{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Adding Resources\n",
"\n",
"> ### In this tutorial we will cover:\n",
"> - how we can set custom default resources"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you checked out the tutorial on _built-in_ data resources you know that biobuild comes with a variety of molecular structures for the user to work with directly, such as compounds containing amino acids or sugars. These can be easily loaded using functions such as `load_sugars()`. However, what if we are working on a drug discovery project and would like to engineer small variations of a promising compound? We may have a structure of the compound itself but we don't want to keep re-loading them every time we open a new notebook to use biobuild. But we would like for it to be available by default. \n",
"\n",
"Luckily, biobuild allows us to set our own _defaults_ that can be loaded in every future session. We can add _custom linkages_ and _custom structures_ to the default CHARMM topology and PDBE Compounds, respecitively using functions `add_linkage` and `add_compound`. Here's how:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Adding custom linkages\n",
"\n",
"You may know that you can refer to any registered linkage directly via its string identifier. For example, we can refer to a beta 1->4 glycosydic linkage by its id `14bb`. We do not need to get the linkage object first because biobuild will be able to interpret the id and search the linkage object automatically. To make a custom linkage available in such a way, we simply need to define it, give it an id (which is otherwise optional when creating a `Linkage` object). Then we call `add_linkage` with our new linkage and that's it!"
]
},
{
"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": [
"[Linkage(SCK0),\n",
" Linkage(SCK1),\n",
" Linkage(LLLO),\n",
" Linkage(CERA),\n",
" Linkage(CERB),\n",
" Linkage(DAGA),\n",
" Linkage(DAGB),\n",
" Linkage(INS2A),\n",
" Linkage(INS2B),\n",
" Linkage(INS6A),\n",
" Linkage(INS6B),\n",
" Linkage(SGPA),\n",
" Linkage(TGPA),\n",
" Linkage(SGPB),\n",
" Linkage(TGPB),\n",
" Linkage(NGLA),\n",
" Linkage(11aa),\n",
" Linkage(11ab),\n",
" Linkage(11bb),\n",
" Linkage(12aa),\n",
" Linkage(12ab),\n",
" Linkage(12ba),\n",
" Linkage(12bb),\n",
" Linkage(13aa),\n",
" Linkage(13ab),\n",
" Linkage(13ba),\n",
" Linkage(13bb),\n",
" Linkage(14aa),\n",
" Linkage(14ab),\n",
" Linkage(14ba),\n",
" Linkage(14bb),\n",
" Linkage(16aa),\n",
" Linkage(16ab),\n",
" Linkage(16ba),\n",
" Linkage(SUCR),\n",
" Linkage(LCTL),\n",
" Linkage(AB15),\n",
" Linkage(SA23AB),\n",
" Linkage(LINK),\n",
" Linkage(my_14_glyco_link)]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import biobuild as bb\n",
"\n",
"# define a custom link\n",
"my_link = bb.linkage(\"C1\", \"O4\", [\"O1\", \"HO1\"], [\"HO4\"], id=\"my_14_glyco_link\")\n",
"\n",
"# now add the link to the default CHARMM topology\n",
"bb.add_linkage(my_link)\n",
"\n",
"# now we find it at the bottom of the list of 'out-of-the-box' available linkages\n",
"bb.available_linkages()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now make use of our custom linkage just as we would use any of the predefined ones. So, to connect a glucose and a mannose using our new linkage, we can do:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"customdata": [
[
"C1",
1,
1,
"GLC",
"A"
],
[
"C2",
2,
1,
"GLC",
"A"
],
[
"C3",
3,
1,
"GLC",
"A"
],
[
"C4",
4,
1,
"GLC",
"A"
],
[
"C5",
5,
1,
"GLC",
"A"
],
[
"C6",
6,
1,
"GLC",
"A"
],
[
"C1",
23,
2,
"MAN",
"A"
],
[
"C2",
24,
2,
"MAN",
"A"
],
[
"C3",
25,
2,
"MAN",
"A"
],
[
"C4",
26,
2,
"MAN",
"A"
],
[
"C5",
27,
2,
"MAN",
"A"
],
[
"C6",
28,
2,
"MAN",
"A"
]
],
"hovertemplate": "atom_element=C
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]}