{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Getting Started\n", "\n", "Welcome to the first BuildAMol tutorial, where we shall learn the basics of operating with BuildAMol!\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 BuildAMol\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 are the ptimization environments of the `optimizers` module. They can be used to optimize conformations. Also, 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. " ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ " \n", " \n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import plotly\n", "plotly.offline.init_notebook_mode()\n", "\n", "import buildamol as bam" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Resources\n", "\n", "BuildAMol includes the _PDBE_ component library for small molecules (or at least a pretty large part of it). Since this is quite large, BuildAMol 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", "bam.load_amino_acids()\n", "\n", "# to load nucleotide and derivative compounds\n", "bam.load_nucleic_acids()\n", "\n", "# to load sugar and derivative compounds\n", "bam.load_sugars()\n", "\n", "# to load miscallaneous small molecules of less than 40 atoms\n", "bam.load_small_molecules()\n", "```" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Molecules\n", "\n", "Molecules are the essential data unit in BuildAMol. 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", "- ... and more\n", "\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": 17, "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}
__marker_size=%{marker.size}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}", "legendgroup": "N", "marker": { "color": "blue", "opacity": 1, "size": { "bdata": "BQ==", "dtype": "i1" }, "sizemode": "area", "sizeref": 0.0125, "symbol": "circle" }, "mode": "markers", "name": "N", "scene": "scene", "showlegend": true, "type": "scatter3d", "x": { "bdata": "ZmZmZmZm+D8=", "dtype": "f8" }, "y": { "bdata": "WmQ730+N3z8=", "dtype": "f8" }, "z": { "bdata": "2/l+arx0478=", "dtype": "f8" } }, { "customdata": [ [ "CA", 2, 1, "SER", "A" ], [ "C", 3, 1, "SER", "A" ], [ "CB", 5, 1, "SER", "A" ] ], "hovertemplate": "atom_element=C
x=%{x}
y=%{y}
z=%{z}
__marker_size=%{marker.size}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}", "legendgroup": "C", "marker": { "color": "darkslategray", "opacity": 1, "size": { "bdata": "BQUF", "dtype": "i1" }, "sizemode": "area", "sizeref": 0.0125, "symbol": "circle" }, "mode": "markers", "name": "C", "scene": "scene", "showlegend": true, "type": "scatter3d", "x": { "bdata": "mpmZmZmZuT+JQWDl0CKrvyUGgZVDi+S/", "dtype": "f8" }, "y": { "bdata": "arx0kxgE3j/8qfHSTWJwP7Kd76fGS9+/", "dtype": "f8" }, "z": { "bdata": "VOOlm8Qg0L/4U+Olm8TyP4ts5/up8fK/", "dtype": "f8" } }, { "customdata": [ [ "O", 4, 1, "SER", "A" ], [ "OG", 6, 1, "SER", "A" ], [ "OXT", 7, 1, "SER", "A" ] ], "hovertemplate": "atom_element=O
x=%{x}
y=%{y}
z=%{z}
__marker_size=%{marker.size}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}", "legendgroup": "O", "marker": { "color": "red", "opacity": 1, "size": { "bdata": "BQUF", "dtype": "i1" }, "sizemode": "area", "sizeref": 0.0125, "symbol": "circle" }, "mode": "markers", "name": "O", "scene": "scene", "showlegend": true, "type": "scatter3d", "x": { "bdata": "1XjpJjEI6D9YObTIdr7fv/LSTWIQWPG/", "dtype": "f8" }, "y": { "bdata": "UrgehetR6L9KDAIrhxapvylcj8L1KNw/", "dtype": "f8" }, "z": { "bdata": "/Knx0k1i+j9I4XoUrkcEwM/3U+Olm/4/", "dtype": "f8" } }, { "customdata": [ [ "H", 8, 1, "SER", "A" ], [ "H2", 9, 1, "SER", "A" ], [ "HA", 10, 1, "SER", "A" ], [ "HB2", 11, 1, "SER", "A" ], [ "HB3", 12, 1, "SER", "A" ], [ "HG", 13, 1, "SER", "A" ], [ "HXT", 14, 1, "SER", "A" ] ], "hovertemplate": "atom_element=H
x=%{x}
y=%{y}
z=%{z}
__marker_size=%{marker.size}
atom_id=%{customdata[0]}
atom_serial=%{customdata[1]}
residue_serial=%{customdata[2]}
residue_name=%{customdata[3]}
chain_id=%{customdata[4]}", "legendgroup": "H", "marker": { "color": "lightgray", "opacity": 1, "size": { "bdata": "BQUFBQUFBQ==", "dtype": "i1" }, "sizemode": "area", "sizeref": 0.0125, "symbol": "circle" }, "mode": "markers", "name": "H", "scene": "scene", "showlegend": true, "type": "scatter3d", "x": { "bdata": "rBxaZDvf/T/Jdr6fGi/5P9NNYhBYOdS/zczMzMzMzL/Jdr6fGi/7v7Kd76fGS++/IbByaJHt8r8=", "dtype": "f8" }, "y": { "bdata": "I9v5fmq83L85tMh2vp/mP/Cnxks3ifc/QmDl0CLb97/TTWIQWDngv+58PzVeuuW/kxgEVg4twj8=", "dtype": "f8" }, "z": { "bdata": "Vg4tsp3v37+wcmiR7Xz5vw4tsp3vp9a/sp3vp8ZL8b9xPQrXo3Dtv05iEFg5tAjAObTIdr6fBkA=", "dtype": "f8" } }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.525, 0.1 ], "y": [ 0.493, 0.469 ], "z": [ -0.608, -0.252 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.525, 1.867 ], "y": [ 0.493, -0.449 ], "z": [ -0.608, -0.499 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.525, 1.574 ], "y": [ 0.493, 0.707 ], "z": [ -0.608, -1.593 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 0.1, -0.053 ], "y": [ 0.469, 0.004 ], "z": [ -0.252, 1.173 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 0.1, -0.642 ], "y": [ 0.469, -0.489 ], "z": [ -0.252, -1.184 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 0.1, -0.316 ], "y": [ 0.469, 1.471 ], "z": [ -0.252, -0.354 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.053, 0.751 ], "y": [ 0.004, -0.76 ], "z": [ 1.173, 1.649 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.053, -1.084 ], "y": [ 0.004, 0.44 ], "z": [ 1.173, 1.913 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.642, -0.496 ], "y": [ -0.489, -0.049 ], "z": [ -1.184, -2.535 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.642, -0.225 ], "y": [ -0.489, -1.491 ], "z": [ -1.184, -1.081 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.642, -1.699 ], "y": [ -0.489, -0.507 ], "z": [ -1.184, -0.92 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.496, -0.978 ], "y": [ -0.049, -0.679 ], "z": [ -2.535, -3.088 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.084, -1.183 ], "y": [ 0.44, 0.142 ], "z": [ 1.913, 2.828 ] } ], "layout": { "scene": { "xaxis": { "showgrid": false, "showline": false, "showticklabels": false }, "yaxis": { "showgrid": false, "showline": false, "showticklabels": false }, "zaxis": { "showgrid": false, "showline": false, "showticklabels": false } }, "template": { "data": { "bar": [ { "error_x": { "color": "rgb(36,36,36)" }, "error_y": { "color": "rgb(36,36,36)" }, "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)" }, "baxis": { "endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "heatmap" } ], "histogram": [ { "marker": { "line": { "color": "white", "width": 0.6 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattergl" } ], "scattermap": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattermap" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "rgb(237,237,237)" }, "line": { "color": "white" } }, "header": { "fill": { "color": "rgb(217,217,217)" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "colorscale": { "diverging": [ [ 0, "rgb(103,0,31)" ], [ 0.1, "rgb(178,24,43)" ], [ 0.2, "rgb(214,96,77)" ], [ 0.3, "rgb(244,165,130)" ], [ 0.4, "rgb(253,219,199)" ], [ 0.5, "rgb(247,247,247)" ], [ 0.6, "rgb(209,229,240)" ], [ 0.7, "rgb(146,197,222)" ], [ 0.8, "rgb(67,147,195)" ], [ 0.9, "rgb(33,102,172)" ], [ 1, "rgb(5,48,97)" ] ], "sequential": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "sequentialminus": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ] }, "colorway": [ "#1F77B4", "#FF7F0E", "#2CA02C", "#D62728", "#9467BD", "#8C564B", "#E377C2", "#7F7F7F", "#BCBD22", "#17BECF" ], "font": { "color": "rgb(36,36,36)" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "white", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "white", "polar": { "angularaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "bgcolor": "white", "radialaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" } }, "scene": { "xaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "yaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "zaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" } }, "shapedefaults": { "fillcolor": "black", "line": { "width": 0 }, "opacity": 0.3 }, "ternary": { "aaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "baxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "bgcolor": "white", "caxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside", "title": { "standoff": 15 }, "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "yaxis": { "automargin": true, "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside", "title": { "standoff": 15 }, "zeroline": false, "zerolinecolor": "rgb(36,36,36)" } } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/opt/anaconda3/lib/python3.12/site-packages/jupyter_client/session.py:203: DeprecationWarning:\n", "\n", "datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).\n", "\n" ] } ], "source": [ "# make sure we have amino acids available\n", "bam.load_amino_acids()\n", "\n", "# get a serine\n", "ser = bam.molecule(\"serine\")\n", "\n", "# check what it looks like\n", "ser.show3d()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can always check out if a compound is available in a loaded set using the `has_compound` function. But even if a specific compound is not available\n", "BuildAMol can retrieve the molecular structure directly from PubChem to guarantee a smooth workflow!" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# check if we have diacetamide\n", "bam.has_compound(\"diacetamide\")" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAYAAADDhn8LAAAJUUlEQVR4nO3dfYxU1RnH8e8sCwsCWxBBLPWtFOWl9IViI8Ta1JhY26CxqUJqoyEmtbW12ljBNlqJBmtJWquxTTAxRgzU1saUvmhfrE0rZCWRNAWhNJoClSLvKkJ5XZ7+8ZxxZpbZswPMzLk79/dJJnfm3jM7z56ZZ+6555w7F0RERKRGBm0GowyGpY4l6wyGhbpqSx2LNJBBwWCOwV8NDhtYuO00WGIwKXWMWWEw2eApg11l9XQ41N1sg0LqGKWODNoNloU3er/BMwYLDX5osCqsP2jwxdSxpmZwbagLM+gKdbTQ4JcG/wvrlxq0p45V6sTg3vDG/t3gA1W2zzY4ZHDAYHKKGLPAYEqogwMG11TZfq7BulCX30sRo9SZwUiDfeFNPz9S7p7wxv+smfFlicHPQx3cGSlzQfgyeddgRBPDk0Yw+HJ405/po9zpoZ19wKCjWfFlhUFHaFodNOjso+yvQp1+qVnxpZKHnonpYdkVK1SAPcB6YDAwpdFBZdCH8S+GdQ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RMjV+EH8ivJ6TT6y8nRuc3Hey9B7gqDjgZ2a48yVZpYufJ5YDV+Utb8xLE0RQEfaZXKBBkD9jbYO94L9l6ZvCdI0dXAenxO19g+ytZVs3sLDD8IkwqFHfhYTyd+irBUWo6Pi83HZxD3dsJb3aXoTtuV4DX7g0eAtcB1YJqrVN3zwEy8npryQ3bqb86MwlHgFnwv+yhYRx9PyLNn8d6uhlOCZEphBT5lfDzwjcTBCEqQLLoDn590N/77U5KQEiRzCrvxeWgj0DndySlBsmkxPlB2WupA8k4JkkmFY/j8pO7UkeSdLn+Qzlr8RKKXq28urAa7Gf8Zo7XNC0skE6wDbDhY5EvK2kMZdflK3tiiMI1kbqTM3FBmUe9lpJF0DCISoQQRiVCCiEQoQUQi1M2bXrufgtvbNklJb0B6j4WbZJASJL0X8LPlqpmMn5osiShB0lsGhSeqb7K5KEGS0kG6SIQSRCRCCSISoQQRiVCCiEgWWWe4VELkrEE7LZTJ4PVQREREpHf/B72ND09wmU0kAAAAAElFTkSuQmCC", "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# get a diacetamide (using its name)\n", "# since diacetamide was not available in the loaded set of compounds\n", "# BuildAMol will automatically download it from PubChem\n", "tri = bam.molecule(\"diacetamide\")\n", "\n", "# check what it looks like\n", "# this time with a 2D depiction (use 'draw' to set some parameters, \n", "# use 'show' otherwise as a shortcut)\n", "tri.draw2d().draw(width=200, height=100) " ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Linkage \n", "\n", "Now assuming we want to take _diacetamide_ and connect the _serine_ to it. We can define a `Linkage` to specify which atoms to link between the two. To do so, we need to know what the atoms are labelled as (another reason to always visualize the structures). In the Linkage definition we specify, for instance, that the diacetamide-N1 should be connected to serine-C. In the process, we remove the a hydrogen from the acetamide's N1 and the serine's OXT and HXT.\n", "\n", "> #### Note\n", "> The linkages do *not* need to follow chemical reasoning - they only connect structures by adding and removing connections. Hence, we could connect the molecules by one of the methyl-groups making one of the hydrogens the leaving group (even though chemically such a reaction would probably never occur) - BuildAMol builds structures, but it does not imitate chemical reactions! " ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "# define the linkage between the two molecules\n", "# remember to check the atom labelling as these atom labels must match\n", "# the existing atom labels in both molecules\n", "link = bam.linkage(atom1=\"N1\", atom2=\"C\", delete_in_target=[\"H1\"], delete_in_source=[\"OXT\", \"HXT\"])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Now we can connect the two molecules for example using the `connect` function:" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

\n
\n", "text/html": [ "
\n", "

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# connect the two molecules\n", "new = bam.connect(tri, ser, link)\n", "\n", "# and check what it looks like\n", "# we can also use different backends, e.g. py3dmol\n", "new.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "BuildAMol also supports operator-based syntax:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
\n

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

\n
\n", "text/html": [ "
\n", "

3Dmol.js failed to load for some reason. Please check your browser console for error messages.

\n", "
\n", "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# equivalent to the above, % specifies the linkage, + connects the two molecules\n", "new = tri % link + ser \n", "new.py3dmol().show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pseudo-Reactions\n", "\n", "Even though chemical rationale is by no means part of BuildAMol's core idea, to facilitate the building process and offer some aid for users who strong think in chemical terms, BuildAMol offers a mechanism to imitate reactions to some degree by providing `Reactivity` patterns for functional groups and a `Reaction` class to automatically detect matching atoms to use for linking and removal. \n", "\n", "To repeat the above example, we had an imide react with a carboxyl group. The imide itself is not actually a defined reactivity (yet?) but since it consists basically of 1.5 amide groups we can borrow the reactivity of the amide group for our purposes. " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAASwAAADICAYAAABS39xVAAAcRUlEQVR4nO3deZwU9ZnH8U8Nw40ieGPiGfAGxSsS7/CKRMW4G2UVVOKa1TVREE8UUTyiKB6AugaT1YhCDLK6kaiJ0fWMGjzwRBMCooDIoYAc4Zxn/3iqoWfoo2ampqq75/t+vfo1M91V3Q9N19O/46lfgYiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiJS9IO0ApPkwaAHsCmwFrABmB7AmzZhERGox2M7gHoOvDCzrtsLgtwZd045RyoNaWNKkDPYAngd2AT4AHge+ALYGTgS+B3wDnBTAK2nFKSLNnEGVwZtha2qUQVWObX4ePv6FQac04hQRweDkMBlNzZWssrZ7NNxuaJLxiYhsZPBgmIjOK7LdMeF2byQVm4hILQbTwkTUs8h27QxqDFabxlWlgLzNdJEYbBP+XFhoowBWAcuB1sAWTR2UlC8lLGlKNfXYNtOyqs8+0swoYUlT+jr8uV2hjQzaAR2A1YEXlIrkpIQlTend8OfBRbY7BG9hTWvSaERE8jE4JRx0f73QYLrBw+F2VyQZX5nrBOyZdhAiFcOghcG7YTIanmeb08MZwi9VOCoiqTLYx2B+mLReNLggLCg9x+CJMFmtMPh+2rGKiGCwc3iS85o6Jz9vMHjWoHvaMZahA4BjUo4hcSrSk8SYzwR2BzoDy4CPA1icblQiIlkMOpuvgZXrsfYGbRMOScqUyhokCZcBF+R57CLg2gRjqRQ/An6SdhBJq047AGkWqshfwV7oMcnv92kHkAa1sCQJSlgSCyUsSYISVvwuA25MO4ikqUsoSWgBbMjzWBVgCcZSKW5PO4A0qIUlSSjWwsqXzERqUQtLkqAuYbx2BAaHv98FLEgxlkQpYUkSlLDiNZ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E5ynWWOPWqxcRaZywxuo3YdJaZvDLMIkNMnjEYE2YrIamHauISCZpDQzPQcw+8Xm9wV+sHmtulTuV8YuUEYPt8BnBGmBe4Jc0ExERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERESkf/w9IHLuzzHLloQAAAABJRU5ErkJggg==", "text/plain": [ "" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from buildamol.structural.reactivity import Amide, Carboxyl\n", "\n", "# define the reaction\n", "reaction = bam.Reaction.from_reactivities(nucleophile=Amide(), electrophile=Carboxyl())\n", "\n", "# connect the two molecules using the reaction\n", "new2 = reaction(ser, tri)\n", "\n", "new2.draw2d()\\\n", " .highlight_bonds(new2.get_residue_connections(), color=\"orange\")\\\n", " .draw(width=300, height=200)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By the way, these kinds of visualizations (especially the 2D one) can be easily customized in various ways (check out the tutorial for that to learn more).\n" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Optimization \n", "\n", "If we observe a clash in the resulting conformation, we can apply an optimization. This is where the `optimizers` module comes into play. BuildAMol uses a rotational optimization system to find conformations without the need for molecular dynamics. This can be efficient or very expensive (up to unsolvable, in fact!) depending on the pre-processing / pre-thinking that the user provided. But don't worry, just don't try to optimize hundreds of bonds at once (that won't work, trust me, I've tried!).\n", "\n", "The short way of optimizing a molecule is by using it's `optimize` method. This method does not require any additional arguments, although we can pass further instructions. If you are interested, go check out the tutorial on optimization to learn more!" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hoverinfo": "skip", "line": { "color": "black", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.4126, 1.2341 ], "y": [ -1.2387, -0.0239 ], "z": [ 0.0021, 0.0049 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.4128, -1.2342 ], "y": [ -1.2388, -0.024 ], "z": [ -0.0045, -0.0009 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.0001, 1.2341 ], "y": [ 0.6228, -0.0239 ], "z": [ 0.0038, 0.0049 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.0001, -1.2342 ], "y": [ 0.6228, -0.024 ], "z": [ 0.0038, -0.0009 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.2341, 2.381 ], "y": [ -0.0239, 0.9511 ], "z": [ 0.0049, -0.0062 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.2342, -2.3805 ], "y": [ -0.024, 0.9515 ], "z": [ -0.0009, 0.0007 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 2.381, 3.3262 ], "y": [ 0.9511, 0.4099 ], "z": [ -0.0062, 0.091 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 2.381, 2.3822 ], "y": [ 0.9511, 1.5068 ], "z": [ -0.0062, -0.948 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 2.381, 2.2873 ], "y": [ 0.9511, 1.6495 ], "z": [ -0.0062, 0.8303 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -2.3805, -2.3264 ], "y": [ 0.9515, 1.5897 ], "z": [ 0.0007, -0.8857 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -2.3805, -2.3386 ], "y": [ 0.9515, 1.5714 ], "z": [ 0.0007, 0.9008 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -2.3805, -3.3287 ], "y": [ 0.9515, 0.4071 ], "z": [ 0.0007, -0.0116 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.1335329224371622, -0.5975235076410428 ], "y": [ 3.8381497946875065, 2.5549141011557412 ], "z": [ -0.6834676527491519, -1.1566875404292567 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.1335329224371622, -0.35932450565992946 ], "y": [ 3.8381497946875065, 4.346875178162385 ], "z": [ -0.6834676527491519, -0.2859644306243134 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.1335329224371622, -1.4264062736990784 ], "y": [ 3.8381497946875065, 4.349588679034062 ], "z": [ -0.6834676527491519, -1.5026608336893776 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.5975235076410428, -0.00021594680465872556 ], "y": [ 2.5549141011557412, 1.8024427905977491 ], "z": [ -1.1566875404292567, 0.004031893609317394 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.5975235076410428, 0.481539243208444 ], "y": [ 2.5549141011557412, 2.810365018662758 ], "z": [ -1.1566875404292567, -2.2089804694532815 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.5975235076410428, -1.402158404766837 ], "y": [ 2.5549141011557412, 1.9659829770559287 ], "z": [ -1.1566875404292567, -1.5962177594061717 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.00021594680465872556, 0.4778020626401604 ], "y": [ 1.8024427905977491, 2.4057772623993188 ], "z": [ 0.004031893609317394, 0.9336416492500026 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 0.481539243208444, -0.08427395035472608 ], "y": [ 2.810365018662758, 3.5247638504804693 ], "z": [ -2.2089804694532815, -3.308801699966376 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 0.481539243208444, 1.2859097848454302 ], "y": [ 2.810365018662758, 3.3995127060382964 ], "z": [ -2.2089804694532815, -1.7680779471122579 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 0.481539243208444, 0.879307016527111 ], "y": [ 2.810365018662758, 1.8586192403749688 ], "z": [ -2.2089804694532815, -2.5600214528447944 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.08427395035472608, 0.6279096779075722 ], "y": [ 3.5247638504804693, 3.6642843159275915 ], "z": [ -3.308801699966376, -3.9478334044666834 ] }, { "hoverinfo": "skip", "line": { "color": "black", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.0001, -0.00021594680465872556 ], "y": [ 0.6228, 1.8024427905977491 ], "z": [ 0.0038, 0.004031893609317394 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 2.323677039393159, 1.2341 ], "y": [ 0.499691392520274, -0.0239 ], "z": [ -0.2102349783413162, 0.0049 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.9390049530458884, -1.2342 ], "y": [ -0.24195486273677883, -0.024 ], "z": [ 0.9806271855488133, -0.0009 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.0001, 1.2341 ], "y": [ 0.6228, -0.0239 ], "z": [ 0.0038, 0.0049 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.0001, -1.2342 ], "y": [ 0.6228, -0.024 ], "z": [ 0.0038, -0.0009 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.2341, 1.102114611190321 ], "y": [ -0.0239, -1.4890371359767687 ], "z": [ 0.0049, 0.3244009388445506 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.2342, -1.6415596999383775 ], "y": [ -0.024, -0.4483250617692741 ], "z": [ -0.0009, -1.3864009263153225 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.102114611190321, 0.36839040853542193 ], "y": [ -1.4890371359767687, -1.9477441163962363 ], "z": [ 0.3244009388445506, -0.34416844465493884 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.102114611190321, 2.0679746575452995 ], "y": [ -1.4890371359767687, -1.9835055657894505 ], "z": [ 0.3244009388445506, 0.1887303349034582 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.102114611190321, 0.7669030464449036 ], "y": [ -1.4890371359767687, -1.618649459644391 ], "z": [ 0.3244009388445506, 1.3574103058952123 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.6415596999383775, -1.8680022254656772 ], "y": [ -0.4483250617692741, 0.4328113853379314 ], "z": [ -1.3864009263153225, -1.9932397469358465 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.6415596999383775, -2.5241646720278266 ], "y": [ -0.4483250617692741, -1.092006083292049 ], "z": [ -1.3864009263153225, -1.332597248240499 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.6415596999383775, -0.8256521888891251 ], "y": [ -0.4483250617692741, -1.003254644487022 ], "z": [ -1.3864009263153225, -1.8575208490930797 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.0818628357525282, -0.14508823889106853 ], "y": [ 3.3187221220936705, 2.554475319273914 ], "z": [ 1.5632523710331614, 1.301613526801836 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.0818628357525282, 1.8023019158134657 ], "y": [ 3.3187221220936705, 2.9180691445859877 ], "z": [ 1.5632523710331614, 0.9830336850748591 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ 1.0818628357525282, 0.9196275674986782 ], "y": [ 3.3187221220936705, 4.253677363832628 ], "z": [ 1.5632523710331614, 1.2197987152374357 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.14508823889106853, -0.00021594680465872556 ], "y": [ 2.554475319273914, 1.8024427905977491 ], "z": [ 1.301613526801836, 0.004031893609317394 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.14508823889106853, -1.331989114621411 ], "y": [ 2.554475319273914, 3.5131788425766826 ], "z": [ 1.301613526801836, 1.2061888675286423 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.14508823889106853, -0.3123786917432505 ], "y": [ 2.554475319273914, 1.848123676238365 ], "z": [ 1.301613526801836, 2.1143528827859632 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 5.76 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.00021594680465872556, 0.11576260679546732 ], "y": [ 1.8024427905977491, 2.4061285978041407 ], "z": [ 0.004031893609317394, -1.0346212830008499 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.331989114621411, -1.7653133184573626 ], "y": [ 3.5131788425766826, 3.868184357983194 ], "z": [ 1.2061888675286423, 2.520083162516217 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.331989114621411, -1.0300466789236187 ], "y": [ 3.5131788425766826, 4.411799137038887 ], "z": [ 1.2061888675286423, 0.667844802914249 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.331989114621411, -2.1489931496250905 ], "y": [ 3.5131788425766826, 3.028041062652638 ], "z": [ 1.2061888675286423, 0.6728833816407913 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -1.7653133184573626, -2.5134326669501244 ], "y": [ 3.868184357983194, 4.471655388415175 ], "z": [ 2.520083162516217, 2.4143800128936554 ] }, { "hoverinfo": "skip", "line": { "color": "red", "width": 1.44 }, "mode": "lines", "showlegend": false, "type": "scatter3d", "x": [ -0.0001, -0.00021594680465872556 ], "y": [ 0.6228, 1.8024427905977491 ], "z": [ 0.0038, 0.004031893609317394 ] } ], "layout": { "scene": { "xaxis": { "showgrid": false, "showline": false, "showticklabels": false }, "yaxis": { "showgrid": false, "showline": false, "showticklabels": false }, "zaxis": { "showgrid": false, "showline": false, "showticklabels": false } }, "template": { "data": { "bar": [ { "error_x": { "color": "rgb(36,36,36)" }, "error_y": { "color": "rgb(36,36,36)" }, "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "white", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)" }, "baxis": { "endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "heatmap" } ], "histogram": [ { "marker": { "line": { "color": "white", "width": 0.6 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattergl" } ], "scattermap": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattermap" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" }, "colorscale": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "rgb(237,237,237)" }, "line": { "color": "white" } }, "header": { "fill": { "color": "rgb(217,217,217)" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 1, "tickcolor": "rgb(36,36,36)", "ticks": "outside" } }, "colorscale": { "diverging": [ [ 0, "rgb(103,0,31)" ], [ 0.1, "rgb(178,24,43)" ], [ 0.2, "rgb(214,96,77)" ], [ 0.3, "rgb(244,165,130)" ], [ 0.4, "rgb(253,219,199)" ], [ 0.5, "rgb(247,247,247)" ], [ 0.6, "rgb(209,229,240)" ], [ 0.7, "rgb(146,197,222)" ], [ 0.8, "rgb(67,147,195)" ], [ 0.9, "rgb(33,102,172)" ], [ 1, "rgb(5,48,97)" ] ], "sequential": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ], "sequentialminus": [ [ 0, "#440154" ], [ 0.1111111111111111, "#482878" ], [ 0.2222222222222222, "#3e4989" ], [ 0.3333333333333333, "#31688e" ], [ 0.4444444444444444, "#26828e" ], [ 0.5555555555555556, "#1f9e89" ], [ 0.6666666666666666, "#35b779" ], [ 0.7777777777777778, "#6ece58" ], [ 0.8888888888888888, "#b5de2b" ], [ 1, "#fde725" ] ] }, "colorway": [ "#1F77B4", "#FF7F0E", "#2CA02C", "#D62728", "#9467BD", "#8C564B", "#E377C2", "#7F7F7F", "#BCBD22", "#17BECF" ], "font": { "color": "rgb(36,36,36)" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "white", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "white", "polar": { "angularaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "bgcolor": "white", "radialaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" } }, "scene": { "xaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "yaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "zaxis": { "backgroundcolor": "white", "gridcolor": "rgb(232,232,232)", "gridwidth": 2, "linecolor": "rgb(36,36,36)", "showbackground": true, "showgrid": false, "showline": true, "ticks": "outside", "zeroline": false, "zerolinecolor": "rgb(36,36,36)" } }, "shapedefaults": { "fillcolor": "black", "line": { "width": 0 }, "opacity": 0.3 }, "ternary": { "aaxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "baxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" }, "bgcolor": "white", "caxis": { "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside", "title": { "standoff": 15 }, "zeroline": false, "zerolinecolor": "rgb(36,36,36)" }, "yaxis": { "automargin": true, "gridcolor": "rgb(232,232,232)", "linecolor": "rgb(36,36,36)", "showgrid": false, "showline": true, "ticks": "outside", "title": { "standoff": 15 }, "zeroline": false, "zerolinecolor": "rgb(36,36,36)" } } } } }, "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/opt/anaconda3/lib/python3.12/site-packages/jupyter_client/session.py:203: DeprecationWarning:\n", "\n", "datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).\n", "\n" ] } ], "source": [ "# prepare a 3D drawing with plotly (default backend) before optimization\n", "v = new.plotly(atoms=False)\n", "\n", "# optimize the new molecule\n", "new = new.optimize()\n", "\n", "v.add(new.plotly(line_color=\"red\", atoms=False))\n", "v.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Formats and Integrations\n", "\n", "Now that we have a structure we like we can for instance save it as a _PDB_ or _mmCIF_ file. If we have more intricate interests in the molecules we have built we can export them directly to `rdkit` or `openbabel` objects for further analysis. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To make working with different data formats as easy as possible, each BuildAMol Molecule can be created and saved to the following formats.\n", "Here are is a table with the corresponding methods available in the `Molecule` class:\n", "\n", "| Format | As input | As output |\n", "| --------- | ------------- | -------------- |\n", "| PDB | `from_pdb` | `to_pdb` |\n", "| mmCIF | `from_cif` | `to_cif` |\n", "| Molfile / SDF | `from_molfile` | `to_molfile` |\n", "| SMILES | `from_smiles` | `to_smiles` |\n", "| JSON | `from_json` | `to_json` |\n", "| XML | `from_xml` | `to_xml` |\n", "| XYZ | `from_xyz` | `to_xyz` |\n", "| PDBQT | `from_pdbqt` | `to_pdbqt` |\n", "| pickle | `load` | `save` |\n", "| rdkit | `from_rdkit` | `to_rdkit` |\n", "| openbabel | `from_pybel` | `to_pybel` |\n", "| openmm | `from_openmm` | `to_openmm` | \n", "| stk | `from_stk` | `to_stk` |\n", "| biopython | `` | `to_biopython` |" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "# so let's save our small molecule to a PDB file\n", "new.to_pdb(\"./files/our_first_molecule.pdb\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Beyond connecting Molecules\n", "\n", "We can also perform a plethora of other operations on molecules beyond stitching them together in creative ways. BuildAMol can modify existing molecules quickly in almost any way imaginable.\n", "- Need to replace one functional group with another? No problem! \n", "- Want to change the element of one atom? Sure! \n", "- Turn a _cis_ double bond to _trans_? Of course! \n", "- Align a molecule in space relative to something else? Yep!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With that we have reached already the end of this first little introduction into what BuildAMol can do, and how it feels to work with BuildAMol. Thanks a lot for reading this far! And good luck with whatever you may do with BuildAMol in your projects!" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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.12.3" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }