{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Using Molecular Geometries\n",
"> ### In this tutorial we will cover:\n",
"> - how we can use BuildAMol's molecular geometries to build fragment molecules from scratch"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The core business of BuildAMol is fragment-based assembly. This requires that we have suitable fragment molecules available. \n",
"In 99.9% of all cases it should be no trouble whatsoever to either use the built-in resources, use SMILES to impute templates, or query PubChem for molecules. However, there may be cases where this approach fails. For instance, think of phosphorus pentafluoride (PO5), a small inorganic molecule."
]
},
{
"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": "markdown",
"metadata": {},
"source": [
"Let us first check if we have the molecule available in the built-in resources:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "47e74f68a05d4618bd3a6bb1de1dae27",
"version_major": 2,
"version_minor": 0
},
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import buildamol as bam\n",
"bam.load_small_molecules()\n",
"\n",
"bam.has_compound(\"PF5\", search_by=\"formula\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Well, if the compound is not available, let us query PubChem for it..."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"bam.query_pubchem(\"PF5\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"No matches... Let's try again but with the name"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"bam.query_pubchem(\"phosphorus pentafluoride\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Nope... Well, the SMILES should definitely work, though:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/noahhk/anaconda3/envs/glyco2/lib/python3.11/site-packages/plotly/express/_core.py:1985: FutureWarning:\n",
"\n",
"When grouping with a length-1 list-like, you will need to pass a length-1 tuple to get_group in a future version of pandas. Pass `(name,)` instead of `name` to silence this warning.\n",
"\n"
]
},
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"customdata": [
[
"P1",
1,
1,
"UNL",
" "
]
],
"hovertemplate": "atom_element=P
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]}
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]}