diff --git a/fine-grain-grits-example-polyalanine.ipynb b/fine-grain-grits-example-polyalanine.ipynb new file mode 100644 index 0000000..716837f --- /dev/null +++ b/fine-grain-grits-example-polyalanine.ipynb @@ -0,0 +1,479 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "07feb42e-6950-4201-b0ba-5dbbedaa7e1e", + "metadata": {}, + "source": [ + "Example of using GRiTS to fine-grain (i.e. backmap) a CG compound to an atomistic one.\n", + "\n", + "Right now, to run this notebook you'll need to install from a fork of GRiTS.\n", + "\n", + "```\n", + "git clone git@github.com:chrisjonesBSU/grits.git\n", + "cd grits\n", + "git checkout fine-grain\n", + "conda env create -f environment.yml\n", + "pip install .\n", + "conda activate grits\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f31d8388-1414-4efb-80c1-78a25a6cf274", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/mdtraj/formats/__init__.py:13: DeprecationWarning: 'xdrlib' is deprecated and slated for removal in Python 3.13\n", + " from mdtraj.formats.trr import TRRTrajectoryFile\n", + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/foyer/forcefield.py:34: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html\n", + " from pkg_resources import iter_entry_points, resource_filename\n", + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/pkg_resources/__init__.py:3138: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.\n", + "Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages\n", + " declare_namespace(pkg)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Support for writing out LAMMPS data files will be removed\n", + "in mbuild 1.0.\n", + "See GMSO (https://github.com/mosdef-hub/gmso/tree/main/gmso/formats/lammpsdata) for\n", + "continued support for LAMMPS.\n", + "\n" + ] + } + ], + "source": [ + "import warnings\n", + "warnings.filterwarnings(\"ignore\")\n", + "\n", + "import grits\n", + "from grits.finegrain import backmap_snapshot_to_compound\n", + "import gsd.hoomd\n", + "import mbuild as mb\n", + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e500881f-0391-4e7d-80d9-f245d43b8317", + "metadata": {}, + "outputs": [], + "source": [ + "cg_gsd = \"cg-single-chain.gsd\"\n", + "with gsd.hoomd.open(cg_gsd, \"r\") as traj:\n", + " snap = traj[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "86293d26-731e-496d-8ae1-008a354cd156", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 150\n" + ] + } + ], + "source": [ + "cg_comp = mb.load(cg_gsd)\n", + "print(\"Total Particles:\", cg_comp.n_particles)\n", + "#cg_comp.visualize(bead_size=4).show()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "4873e18c-fc0f-4c18-ba60-3e4b84b7eb6a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "extra head\n", + "Total Time: 1.8446919918060303\n" + ] + } + ], + "source": [ + "bead_mapping = {\"A\": \"C[C@@H](C(=O)O)N\"} # Mapping one A bead to 1 Polyalanine monomer\n", + "# We have to tell GRiTS which atoms on the Polystyrene monomer are used to form monomer-monomer bonds\n", + "head_indices = {\"A\":[4,10]}\n", + "tail_indices = {\"A\":[12]}\n", + "\n", + "start = time.time()\n", + "\n", + "fg_comp = backmap_snapshot_to_compound(\n", + " snapshot=snap,\n", + " bead_mapping=bead_mapping,\n", + " bond_head_index=head_indices,\n", + " bond_tail_index=tail_indices,\n", + " ref_distance=0.3438, # The example GSD file used reduced simulation units, this puts distances back into nm.\n", + " energy_minimize=False, # Minimize sub-groups of atomistic monomers as the fine-grain structure is being created. Still needs testing/debugging\n", + ")\n", + "\n", + "end = time.time()\n", + "print(\"Total Time:\", end - start)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "9db365db-fca7-4e41-b1ba-7d1c2e3156ea", + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcIAAACWCAIAAADCEh9HAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3dZ1xU19YH4D8MDH0QEBVEQFCaBlRABSwgIoiYixq7ohGxXKIxaMyba8dGEk1sxBhRsBuNvSYqil1sgSjNCEiRJkiRDnPeD4eM4wBKG2Zw1vPzw5l9yiyMWex9dpNjGAaEEEKaSl7SARBCSNtGaZQQQpqF0ighhDQLpVFCCGkWSqOEENIslEYJIaRZFCQdAJGE9HSEh+PlSygqwsICLi5QUan34qoqXLyIhASoqKBXLzg4tGKghLQBlEZlTFUVFi1CcDD4fHTogOJiFBWhUyfs2IFPP63j+thYjBqFhATo6qKwEGVlcHfH0aPQ0Gj10AmRUtSolzFffIHNm/H550hPR0YGCgpw8ya0tDB6NK5eFb24shIjR0JDA//8g6wsFBbim2/wxx/YskUSoRMipeRoFpMMiY6GjQ1Gj8axY++Up6WhRw8YGSE6WvSW27fRuTOMjGo+vnkDDQ14e+PEidYImJC2gGqjsuTwYQBYsEC03MAA48fj77/x9CkA5OQgP7/mlKPj2xwKIC4OALp0EXuoLeT27dsPHz6sXR4RERFd+3cGAIDP59+6dSssLOzUqVOvX78Wc4Dko8AQ2eHhwQDMq1d1nNq8mQGY/fsZhmEUFZlBg945m5vLxMczv//OmJkxRkZMSkprRNsSunTp0r9//9rlqqqqnp6etcsTEhKsra0F/3eoq6sfPHhQ/GGSto1qo7IkPx8qKtDRqeMUW8HMywOAiRPh5vbO2Y0bYW6Ozz5Ddjb27WtDtdFGqaysHDlyZEJCwt69e/Pz8+/cuWNsbOzj4/PkyRNJh0akGqVRWaKkhLIylJfXcaqgAEDNsKc9e7B06TtnFy5ETAzOnYOtLVxdcf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IQu4/fR/bptl7vFoITUKqktRFgIjNq7pBwO92TncPEWdCKC8IqXAdcdu5AiaUV88eTlqxVBqDAGmC1TDkDJyyUhQdgCZATNa25wgFT8WRFB6TCslm1SY3YWJSLDcAKF8hRq+gWEbmhjqppDlLSSqYcEb3vVGgA2gaaiIcKj+bpjlIkdNDbp1ux7oFGPqcBSA4eclI14RxJcjOxUTU+5MuWnGFjDEkRG47S9KciTyxCTbauekW1DcjzMj/sye/mHNdl7psTl/uChFr7HoTa+rRDtT5T94TcBxeq9vGESrspOAvSe02ull1LKQLSrnUUIXnXoM2Q98XtSwn9/gO5PP0Ar+WsJuYjWrUAAADpelRYdFNNSUxFUyByZGtpdCAyMDI0LjAzLjUAAHicLY47jsMwDESvskUKG6AF/kSRFrZy4yo+QJCb5PBLZl0QQ70RB/M639ex/F7rsbzO97o8v1Jzg/v581k2aWahDBs29tAImBs3chtarFMulowaq/cAbNalzEIjhAS4YSdJkhGiGD0/KZvyKKSWHgO1wCAqgmiuQzpkAnbj/3gJdC5kiA6zLCWHKiM3GVnGM5wi0plSi46qiez4LZXng8IqJ6+oFwlVlCxgTj5ghce5E85r13nsnCqpNM895nPvqVQP4qSYi+WMHH98/gDaa0j6jeB35AAAAABJRU5ErkJggg==", + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "polyalanine = mb.load(\"C[C@@H](C(=O)O)N\",smiles=True)\n", + "polyalanine.to_rdkit()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "3f1f7c8f-31d5-4d21-b286-afe5f172fe28", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 1500\n" + ] + }, + { + "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": [ + "print(\"Total Particles:\", fg_comp.n_particles)\n", + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7de3243e-f571-4ecf-b79d-4bf97ee5ff5d", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "d4a31b9d-ce2e-42a0-819a-f66920e4f7ba", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "extra tail\n", + "Total Time: 1.6989569664001465\n" + ] + } + ], + "source": [ + "bead_mapping = {\"A\": \"C[C@@H](C(=O)O)N\"} # Mapping one A bead to 1 Polyalanine monomer\n", + "# We have to tell GRiTS which atoms on the Polystyrene monomer are used to form monomer-monomer bonds\n", + "head_indices = {\"A\":[4,10]}\n", + "tail_indices = {\"A\":[12]}\n", + "\n", + "start = time.time()\n", + "\n", + "fg_comp = backmap_snapshot_to_compound(\n", + " snapshot=snap,\n", + " library_key='polyalanine',\n", + " ref_distance=0.3438, # The example GSD file used reduced simulation units, this puts distances back into nm.\n", + " energy_minimize=False, # Minimize sub-groups of atomistic monomers as the fine-grain structure is being created. Still needs testing/debugging\n", + ")\n", + "\n", + "end = time.time()\n", + "print(\"Total Time:\", end - start)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "843e5a7e-a289-453a-967c-c4bcfc78c7fa", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "f34e15d5-8a1f-4666-85ca-709f5ea4140c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 1500\n" + ] + }, + { + "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": [ + "print(\"Total Particles:\", fg_comp.n_particles)\n", + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "markdown", + "id": "4e5d07d2-8063-42fa-9cb5-e9b4db6cfec9", + "metadata": {}, + "source": [ + "# Next Step: Energy minimize...\n", + "# mBuild c" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "953ddd09-512d-462c-a212-f6fa244e4fe7", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp.energy_minimize(steps=2500)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "8fcbb794-7662-4ecb-a649-38003a5b9b63", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp.save(\"fg.mol2\", overwrite=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "dcaeb267-153c-462e-9457-7133c11e8cea", + "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": [ + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40796efd-7396-4d9d-ac06-b28f6abf3062", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/fine-grain-grits-example-polystyrene.ipynb b/fine-grain-grits-example-polystyrene.ipynb new file mode 100644 index 0000000..33835d0 --- /dev/null +++ b/fine-grain-grits-example-polystyrene.ipynb @@ -0,0 +1,441 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "07feb42e-6950-4201-b0ba-5dbbedaa7e1e", + "metadata": {}, + "source": [ + "Example of using GRiTS to fine-grain (i.e. backmap) a CG compound to an atomistic one.\n", + "\n", + "Right now, to run this notebook you'll need to install from a fork of GRiTS.\n", + "\n", + "```\n", + "git clone git@github.com:chrisjonesBSU/grits.git\n", + "cd grits\n", + "git checkout fine-grain\n", + "conda env create -f environment.yml\n", + "pip install .\n", + "conda activate grits\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f31d8388-1414-4efb-80c1-78a25a6cf274", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/mdtraj/formats/__init__.py:13: DeprecationWarning: 'xdrlib' is deprecated and slated for removal in Python 3.13\n", + " from mdtraj.formats.trr import TRRTrajectoryFile\n", + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/foyer/forcefield.py:34: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html\n", + " from pkg_resources import iter_entry_points, resource_filename\n", + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/pkg_resources/__init__.py:3138: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.\n", + "Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages\n", + " declare_namespace(pkg)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Support for writing out LAMMPS data files will be removed\n", + "in mbuild 1.0.\n", + "See GMSO (https://github.com/mosdef-hub/gmso/tree/main/gmso/formats/lammpsdata) for\n", + "continued support for LAMMPS.\n", + "\n" + ] + } + ], + "source": [ + "import warnings\n", + "warnings.filterwarnings(\"ignore\")\n", + "\n", + "import grits\n", + "from grits.finegrain import backmap_snapshot_to_compound\n", + "import gsd.hoomd\n", + "import mbuild as mb\n", + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e500881f-0391-4e7d-80d9-f245d43b8317", + "metadata": {}, + "outputs": [], + "source": [ + "cg_gsd = \"cg-single-chain.gsd\"\n", + "with gsd.hoomd.open(cg_gsd, \"r\") as traj:\n", + " snap = traj[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "86293d26-731e-496d-8ae1-008a354cd156", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 150\n" + ] + }, + { + "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": [ + "cg_comp = mb.load(cg_gsd)\n", + "print(\"Total Particles:\", cg_comp.n_particles)\n", + "cg_comp.visualize(bead_size=4).show()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "a8d2f65b-8c3d-4975-8c09-8a570b9591e4", + "metadata": {}, + "outputs": [], + "source": [ + "styrene = mb.load(\"C=CC1=CC=CC=C1\",smiles=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "40630796-43a4-48d1-990b-0c1f8d695f20", + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcIAAACWCAIAAADCEh9HAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3dd0BT1/4A8HMJYYchsmUrKooyHAVF2UgVXl24KtanVl/V6nNW1LaOWtD+tGoVjXs8F44qImUKIgiIC8HKRlBWIBAhQCDJ/f1x+u5LARUZuUG+n79yTm5yv7H2673nnvM9BEmSCAAAQGfJ0R0AAAD0bpBGAQCgSyCNAgBAl0AaBQCALoE0CgAAXQJpFAAAukSe7gAAkC3JycmNjY3u7u5UT0xMjKqqqq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Fi2pXtb4k8UGSSYy00BnMVyglGol4E9HIDUXdV6VEDjL6CKpMAXo0CVdtRAmQq6OCpCB69KitlIFtB5GYDfYoI0xeVTP8XGKbCBkoSeve2sr56/X8TaYP4R5v1/MQLuVvyBNj+tBgLnFSWvI89LRfx6EbiSsy5JFLGyKQmG20GvM9mhoap0WntmF64Kk5Ei761AKMNcpUagmnNlUUY41tKhxGGKhzfeZq5Pr5FxD29hfOgs+T7tf86AAAAQZ6VFh0U01JTEVTIHJka2l0IDIwMjQuMDMuNQAAeJx1kDuOwzAMRK+yRYoEUAT+RdrYyo3vEOQmOfwOnXoLYZ5GwwGh1/k+7q/z/fj9ysHbF/6RjaE/n/vTppZmjCdN8ipZNfanzDJJGTRViNMvyy2sBs8VkQmHZ2Yy9+Sy0IorJWlmA8Cl1F00TRct6ZxGSOplktHSWuijJOOrj8rNB0YtCqM8jUmRsCCXvidFKAKFPhiCFyfuNUux8dh1FiMMZy0j985QZKzR9S7LO8OimteOWBLr0Axeod4hU8FvwBJhJelUrvIYj3E7t9yPjfZzKyhDmQCCo31hgDW04w0KiAYDrAa/ff4A2axaYfvW/HwAAAAASUVORK5CYII=", + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "styrene.to_rdkit()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "9db365db-fca7-4e41-b1ba-7d1c2e3156ea", + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcIAAACWCAIAAADCEh9HAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3dd1xT5/oA8DchgSB7SUBlKQjRioiWjQMErAy3WAdqrVjrBbVV77VYsb3Wed1V1FIHtoqoBRVBxFUQHICgLAEZsiGGsELIOr8/Tm9+uYhUJclJ5Pl++kfOe87JedLyefqed5IwDEMAAAA+FJnoAAAAQLlBGgUAgH6BNAoAAP0CaRQAAPoF0igAAPQLpFEAAOgX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ycs667lN3t0WdUj+Sm903UdKnMbZS4jY2yuI0AFOyhgAx1Ug6iH0OvzBcRPSEBtYw+LAAAAAElFTkSuQmCC", + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pps = mb.load(\"c1ccc(S)cc1\",smiles=True)\n", + "pps.to_rdkit()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "4873e18c-fc0f-4c18-ba60-3e4b84b7eb6a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Time: 2.174791097640991\n" + ] + } + ], + "source": [ + "bead_mapping = {\"A\": \"C=CC1=CC=CC=C1\"} # Mapping one A bead to 1 Polystyrene monomer\n", + "# We have to tell GRiTS which atoms on the Polystyrene monomer are used to form monomer-monomer bonds\n", + "head_indices = {\"A\": [10]}\n", + "tail_indices = {\"A\": [9]}\n", + "\n", + "start = time.time()\n", + "\n", + "fg_comp = backmap_snapshot_to_compound(\n", + " snapshot=snap,\n", + " bead_mapping=bead_mapping,\n", + " bond_head_index=head_indices,\n", + " bond_tail_index=tail_indices,\n", + " ref_distance=0.3438, # The example GSD file used reduced simulation units, this puts distances back into nm.\n", + " energy_minimize=False, # Minimize sub-groups of atomistic monomers as the fine-grain structure is being created. Still needs testing/debugging\n", + ")\n", + "\n", + "end = time.time()\n", + "print(\"Total Time:\", end - start)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3f1f7c8f-31d5-4d21-b286-afe5f172fe28", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 2100\n" + ] + }, + { + "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": [ + "print(\"Total Particles:\", fg_comp.n_particles)\n", + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "markdown", + "id": "4e5d07d2-8063-42fa-9cb5-e9b4db6cfec9", + "metadata": {}, + "source": [ + "# Next Step: Energy minimize...\n", + "# mBuild c" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "953ddd09-512d-462c-a212-f6fa244e4fe7", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp.energy_minimize(steps=2500)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "8fcbb794-7662-4ecb-a649-38003a5b9b63", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp.save(\"fg.mol2\", overwrite=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "dcaeb267-153c-462e-9457-7133c11e8cea", + "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": [ + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40796efd-7396-4d9d-ac06-b28f6abf3062", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/fine-grain-grits-example.ipynb b/fine-grain-grits-example.ipynb new file mode 100644 index 0000000..ade993b --- /dev/null +++ b/fine-grain-grits-example.ipynb @@ -0,0 +1,346 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "07feb42e-6950-4201-b0ba-5dbbedaa7e1e", + "metadata": {}, + "source": [ + "Example of using GRiTS to fine-grain (i.e. backmap) a CG compound to an atomistic one.\n", + "\n", + "Right now, to run this notebook you'll need to install from a fork of GRiTS.\n", + "\n", + "```\n", + "git clone git@github.com:chrisjonesBSU/grits.git\n", + "cd grits\n", + "git checkout fine-grain\n", + "conda env create -f environment.yml\n", + "pip install .\n", + "conda activate grits\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f31d8388-1414-4efb-80c1-78a25a6cf274", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/mdtraj/formats/__init__.py:13: DeprecationWarning: 'xdrlib' is deprecated and slated for removal in Python 3.13\n", + " from mdtraj.formats.trr import TRRTrajectoryFile\n", + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/foyer/forcefield.py:34: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html\n", + " from pkg_resources import iter_entry_points, resource_filename\n", + "/Users/stephaniemccallum/miniforge3/envs/grits/lib/python3.12/site-packages/pkg_resources/__init__.py:3138: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.\n", + "Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages\n", + " declare_namespace(pkg)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Support for writing out LAMMPS data files will be removed\n", + "in mbuild 1.0.\n", + "See GMSO (https://github.com/mosdef-hub/gmso/tree/main/gmso/formats/lammpsdata) for\n", + "continued support for LAMMPS.\n", + "\n" + ] + } + ], + "source": [ + "import warnings\n", + "warnings.filterwarnings(\"ignore\")\n", + "\n", + "import grits\n", + "from grits.finegrain import backmap_snapshot_to_compound\n", + "import gsd.hoomd\n", + "import mbuild as mb\n", + "import time" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "e500881f-0391-4e7d-80d9-f245d43b8317", + "metadata": {}, + "outputs": [], + "source": [ + "cg_gsd = \"cg-single-chain.gsd\"\n", + "with gsd.hoomd.open(cg_gsd, \"r\") as traj:\n", + " snap = traj[-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "86293d26-731e-496d-8ae1-008a354cd156", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 150\n" + ] + } + ], + "source": [ + "cg_comp = mb.load(cg_gsd)\n", + "print(\"Total Particles:\", cg_comp.n_particles)\n", + "#cg_comp.visualize(bead_size=4).show()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "4873e18c-fc0f-4c18-ba60-3e4b84b7eb6a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Time: 2.0872750282287598\n" + ] + } + ], + "source": [ + "bead_mapping = {\"A\": \"c1ccc(S)cc1\"} # Mapping one A bead to 1 PPS monomer\n", + "# We have to tell GRiTS which atoms on the PPS monomer are used to form monomer-monomer bonds\n", + "head_indices = {\"A\": [7]}\n", + "tail_indices = {\"A\": [10]}\n", + "\n", + "start = time.time()\n", + "\n", + "fg_comp = backmap_snapshot_to_compound(\n", + " snapshot=snap,\n", + " bead_mapping=bead_mapping,\n", + " bond_head_index=head_indices,\n", + " bond_tail_index=tail_indices,\n", + " ref_distance=0.3438, # The example GSD file used reduced simulation units, this puts distances back into nm.\n", + " energy_minimize=False, # Minimize sub-groups of atomistic monomers as the fine-grain structure is being created. Still needs testing/debugging\n", + ")\n", + "\n", + "end = time.time()\n", + "print(\"Total Time:\", end - start)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "386917af-f0c2-4d7c-8bee-cd1c5caf2352", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp = backmap_snapshot_to_compound(\n", + " snapshot=snap,\n", + " library_key='pps',\n", + " ref_distance=0.3438, # The example GSD file used reduced simulation units, this puts distances back into nm.\n", + " energy_minimize=False, # Minimize sub-groups of atomistic monomers as the fine-grain structure is being created. Still needs testing/debugging\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "3f1f7c8f-31d5-4d21-b286-afe5f172fe28", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Particles: 1650\n" + ] + }, + { + "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": [ + "print(\"Total Particles:\", fg_comp.n_particles)\n", + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "markdown", + "id": "4e5d07d2-8063-42fa-9cb5-e9b4db6cfec9", + "metadata": {}, + "source": [ + "# Next Step: Energy minimize...\n", + "# mBuild c" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "953ddd09-512d-462c-a212-f6fa244e4fe7", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp.energy_minimize(steps=2500)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "8fcbb794-7662-4ecb-a649-38003a5b9b63", + "metadata": {}, + "outputs": [], + "source": [ + "fg_comp.save(\"fg.mol2\", overwrite=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "dcaeb267-153c-462e-9457-7133c11e8cea", + "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": [ + "fg_comp.visualize().show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "40796efd-7396-4d9d-ac06-b28f6abf3062", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/grits/__init__.py b/grits/__init__.py index bdcac03..7bde759 100644 --- a/grits/__init__.py +++ b/grits/__init__.py @@ -4,7 +4,8 @@ from . import utils from .coarsegrain import Bead, CG_Compound, CG_System -from .finegrain import backmap + +# from .finegrain import backmap try: __version__ = version("grits") diff --git a/grits/finegrain.py b/grits/finegrain.py index 62fb57a..aceb476 100644 --- a/grits/finegrain.py +++ b/grits/finegrain.py @@ -1,16 +1,175 @@ """GRiTS: Fine-graining tools.""" -__all__ = ["backmap"] - import itertools as it from collections import defaultdict +import gsd.hoomd +import mbuild as mb +import numpy as np +from cmeutils.geometry import angle_between_vectors from mbuild import Compound, Particle, load -from grits.utils import align, get_hydrogen, get_index +from grits.utils import align, get_hydrogen, get_index, reactant_dict + + +def backmap_snapshot_to_compound( + snapshot, + bead_mapping=None, + bond_head_index=None, + bond_tail_index=None, + library_key=None, + ref_distance=None, + energy_minimize=False, +): + """Backmap a fine-grained snapshot onto a coarse one. + + Creates a fine-grained compound from a coarse one using the given parameters. + + Parameters + ---------- + snapshot : one frame of gsd trajectory + + bead_mapping (string) : SMILES string of fine-grain monomer + + bond_head_index (list of int) : index of polymer reaction, choose head to orient chain + + bond_tail_index (list of int) : index of polymer reaction, choose tail to orient chain + + library_key (string) : string key to dictionary, reactant_dict, with known bead_mapping, bond_head_index, and bond_tail_index + + ref_distance (float) : distance between monomers + + energy_minimize (bool) : Option to run a mbuild energy minimization. + + + Returns + ------- + :py:class:`mbuild.Compound` + The atomistic structure mapped onto the coarse-grained one. + """ + # TODO + # assert all 3 dicts have the same keys + if ( + bead_mapping is None + and bond_head_index is None + and bond_tail_index is None + ) == (library_key is None): + raise ValueError("Please provide dictionaries or library key.") + if library_key is not None: + bead_mapping = reactant_dict[library_key]["smiles"] + bond_tail_index = reactant_dict[library_key]["tail_indices"] + bond_head_index = reactant_dict[library_key]["head_indices"] + if not ref_distance: + ref_distance = 1 + cg_snap = snapshot + fg_compound = mb.Compound() + box = cg_snap.configuration.box * ref_distance + pos_adjust = np.array([box[0] / 2, box[1] / 2, box[2] / 2]) + mb_box = mb.box.Box.from_lengths_angles( + lengths=[box[0], box[1], box[2]], angles=[90.0, 90.0, 90.0] + ) + fg_compound.box = mb_box + # Create atomistic compounds, remove hydrogens in the way of bonds + compounds = dict() + anchor_dict = dict() + for mapping in bead_mapping: + comp = mb.load(bead_mapping[mapping], smiles=True) + if bond_head_index and bond_tail_index: + remove_atoms = [] # These will be removed + anchor_particles = [] # Store this for making bonds later + """adding section to remove other particles in reacting group + assuming input for head/tail indices is a list, with the anchor particle listed first""" + if len(bond_tail_index[mapping]) > 1: + extra_tail_particles = [] + extra_tail_particles = bond_tail_index[mapping][1:] + for k in extra_tail_particles: + for l, particle in enumerate(comp.particles()): + if l == k: + remove_atoms.append(particle) + if len(bond_head_index[mapping]) > 1: + extra_head_particles = [] + extra_head_particles = bond_head_index[mapping][1:] + for k in extra_head_particles: + for l, particle in enumerate(comp.particles()): + if l == k: + remove_atoms.append(particle) + for i in [bond_tail_index[mapping][0], bond_head_index[mapping][0]]: + for j, particle in enumerate(comp.particles()): + if j == i: + remove_atoms.append(particle) + anchor = [p for p in particle.direct_bonds()][0] + anchor_particles.append(anchor) + for particle in remove_atoms: + comp.remove(particle) + # List of length 2 [tail particle index, head particle index] + anchor_particle_indices = [] + for anchor in anchor_particles: + for i, p in enumerate(comp.particles()): + if p == anchor: + anchor_particle_indices.append(i) + anchor_dict[mapping] = tuple(anchor_particle_indices) + + compounds[mapping] = comp + + finished_beads = set() + bead_to_comp_dict = dict() + mb_compounds = [] + for group in cg_snap.bonds.group: + cg_bond_vec = ( + cg_snap.particles.position[group[1]] + - cg_snap.particles.position[group[0]] + ) + cg_bond_vec = cg_bond_vec / np.linalg.norm(cg_bond_vec) + for bead_index in group: + if bead_index not in finished_beads: + bead_type = cg_snap.particles.types[ + cg_snap.particles.typeid[bead_index] + ] + bead_pos = cg_snap.particles.position[bead_index] * ref_distance + comp = mb.clone(compounds[bead_type]) + tail_pos = comp[anchor_particle_indices[1]].xyz[0] + head_pos = comp[anchor_particle_indices[0]].xyz[0] + head_tail_vec = tail_pos - head_pos + head_tail_vec = head_tail_vec / np.linalg.norm(head_tail_vec) + normal_vec = np.cross(head_tail_vec, cg_bond_vec) + angle = angle_between_vectors( + head_tail_vec, cg_bond_vec, degrees=False + ) + comp.rotate(around=normal_vec, theta=angle) + comp.translate_to(bead_pos + pos_adjust) + mb_compounds.append(comp) + bead_to_comp_dict[bead_index] = comp + finished_beads.add(bead_index) + fg_compound.add(comp) + + tail_comp = bead_to_comp_dict[group[0]] + tail_comp_particle = tail_comp[anchor_particle_indices[1]] + head_comp = bead_to_comp_dict[group[1]] + head_comp_particle = head_comp[anchor_particle_indices[0]] + fg_compound.add_bond( + particle_pair=[tail_comp_particle, head_comp_particle] + ) + if energy_minimize: + temp_head = mb.clone(head_comp) + temp_tail = mb.clone(tail_comp) + temp_comp = mb.Compound(subcompounds=[temp_tail, temp_head]) + tail_comp_particle = temp_tail[anchor_particle_indices[1]] + head_comp_particle = temp_head[anchor_particle_indices[0]] + temp_comp.add_bond( + particle_pair=[tail_comp_particle, head_comp_particle] + ) + print("Running energy minimization") + temp_comp.energy_minimize(steps=500) + temp_tail = temp_comp.children[0] + temp_head = temp_comp.children[1] + tail_comp.xyz = temp_tail.xyz + head_comp.xyz = temp_head.xyz + """maybe replace this section with just: + fg_compound.energy_minimize(steps=500)""" + return fg_compound -def backmap(cg_compound): +def backmap_compound(cg_compound): """Backmap a fine-grained representation onto a coarse one. Creates a fine-grained compound from a coarse one using the attributes diff --git a/grits/utils.py b/grits/utils.py index e5898ce..88209f2 100644 --- a/grits/utils.py +++ b/grits/utils.py @@ -474,3 +474,21 @@ def num2str(num): "sx": ele.element_from_symbol("S"), "sy": ele.element_from_symbol("S"), } + +reactant_dict = { + "pps": { + "smiles": {"A": "c1ccc(S)cc1"}, + "head_indices": {"A": [7]}, + "tail_indices": {"A": [10]}, + }, + "polystyrene": { + "smiles": {"A": "C=CC1=CC=CC=C1"}, + "head_indices": {"A": [9]}, + "tail_indices": {"A": [10]}, + }, + "polyalanine": { + "smiles": {"A": "C[C@@H](C(=O)O)N"}, + "head_indices": {"A": [12]}, + "tail_indices": {"A": [4, 10]}, + }, +}