{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Getting Started\n",
"\n",
"Welcome to the first `biobuild` tutorial, where we shall learn the basics of operating with `biobuild`!\n",
"\n",
"> ### In this tutorial we will cover:\n",
"> - which (main) classes and modules exist and when to use them\n",
"> - how to read input to make `Molecule`s\n",
"> - how to connect two molecules together"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Main Classes in `biobuild`\n",
"\n",
"The most important class is the `Molecule` class which houses ~90% of all functionality that the average user is likely to use. \n",
"Next, comes the `Linkage` class that defines how multiple molecules can be connected, so the user can build larger structures. Third,\n",
"are the `ResidueGraph` and `Rotatron` environments of the `optimizers` module - to optimize conformations. Finally, the `MoleculeViewer3D` may come in quite handy. It is essentially just a plotly 3D-plot but it can be selectively colored easily so as to highlight specific parts of your molecule - it is a great tool to check if your building process is working (or to debug why it may not be). Finally, the `resources` module houses a wealth of reference structures for users to use when building their favourite structures.\n",
"\n",
"That's already about it! Of course, there is a lot more - but everything else is mostly underneath the surface and will most likely not bother the average user directly. "
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"```mermaid\n",
"\n",
"flowchart TB\n",
" node_0[\"core\"]\n",
" node_1(\"Molecule\")\n",
" node_2(\"ResidueGraph\")\n",
" node_3(\"MoleculeViewer3D\")\n",
" node_4[\"Optimizers\"]\n",
" node_6(\"Rotatron\")\n",
" node_7{\"{}_optimize\"}\n",
" node_5[\"Linkage\"]\n",
" node_8[\"resources\"]\n",
" node_1 -.-> node_2\n",
" node_1 -.-> node_3\n",
" node_0 --- node_1\n",
" node_4 --- node_6\n",
" node_4 --- node_7\n",
" node_6 -.-> node_7\n",
" node_2 -.-> node_7\n",
" node_0 --- node_5\n",
"\n",
"```"
]
},
{
"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()\n",
"\n",
"import biobuild as bb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Resources\n",
"\n",
"biobuild includes the _PDBE_ component library for small molecules (or at least a pretty large part of it). Since this is quite large, biobuild will not by default load any data, but offers a buch of functions for the user to load what they are interested in using selectively. We can also set defaults that are always loaded if we want to re-use our own custom builds in different sessions. \n",
"\n",
"Available pre-loadable sets are:\n",
"\n",
"```python\n",
"# to load the amino acid and derivative compounds\n",
"bb.load_amino_acids()\n",
"\n",
"# to load nucleotide and derivative compounds\n",
"bb.load_nucleic_acids()\n",
"\n",
"# to load sugar and derivative compounds\n",
"bb.load_sugars()\n",
"\n",
"# to load miscallaneous small molecules of less than 40 atoms\n",
"bb.load_small_molecules()\n",
"```"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Molecules\n",
"\n",
"Molecules are the essential data unit in `biobuild`. Each Molecule houses atoms that form a molecular structure. We can generate Molecules from:\n",
"- a PDB or CIF file (e.g. \"my_structure.pdb\")\n",
"- a PDB ID (e.g. \"GLC\" - the PDB id for alpha-D-glucose)\n",
"- a trivial name (e.g. \"triacetamide\")\n",
"- a chemical formula (e.g. \"C2H6O\" - caution, may produce ambiguities!)\n",
"- SMILES and InChI/InChIKey\n",
"\n",
"The `Molecule` class has classmethods for all of these named `from_pdb`, `from_compound` (for PDB ID, name etc.), `from_pubchem` and so forth. But there also exists the toplevel `molecule` function that will try to automatically figure out the user input and generate a molecule for you."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"customdata": [
[
"N",
1,
1,
"SER",
"A"
]
],
"hovertemplate": "atom_element=N
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]}
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]}