{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 08. Molecules CG Mapping \n", "\n", "In this tutorial, we show how to generate a CG mapping matrix for a molecule given a bead distribution." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "import hoomd, hoomd.htf as htf, hoomd.md\n", "import numpy as np\n", "import MDAnalysis as mda" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[0.8224383 0.05918723 0.05918723 0.05918723 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0.44409524 0.03726984\n", " 0.44409524 0.03726984 0.03726984 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0.15577257 0.15577257 0.01307291\n", " 0.15577257 0.01307291 0.15577257 0.01307291 0.15577257 0.01307291\n", " 0.15577257 0.01307291 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0.42880501 0.57119499 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0.93286579 0.06713421\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0.44409524 0.03726984 0.44409524 0.03726984 0.03726984 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.15577257\n", " 0.15577257 0.01307291 0.15577257 0.01307291 0.15577257 0.01307291\n", " 0.15577257 0.01307291 0.15577257 0.01307291 0. 0.\n", " 0. ]\n", " [0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0. 0.\n", " 0. 0. 0. 0. 0.27291648 0.36354176\n", " 0.36354176]]\n" ] } ], "source": [ "# Loading inputs\n", "TPR = 'Molecules_CG_Mapping/nvt_prod.tpr'\n", "tpr = mda.Universe(TPR)\n", "TRAJECTORY = 'Molecules_CG_Mapping/traj.trr'\n", "u = mda.Universe(TPR, TRAJECTORY)\n", "\n", "# Generating Mapping Matrix for FF\n", "protein_FF = u.select_atoms(\"resname PHE and resid 0:1\")\n", "Beads_distribution = [['N','H1','H2','H3'],\n", " ['CA','HA','CB','HB1','HB2'],\n", " ['CG','CD1','HD1','CD2','HD2','CE1','HE1','CE2','HE2','CZ','HZ'],\n", " ['C','O'],\n", " ['N','H'],\n", " ['CA','HA','CB','HB1','HB2'],\n", " ['CG','CD1','HD1','CD2','HD2','CE1','HE1','CE2','HE2','CZ','HZ'],\n", " ['C','O1','O2']]\n", "mapping_FF = htf.matrix_mapping(protein_FF,Beads_distribution)\n", "print (mapping_FF)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[0.88809574 0.05595213 0.05595213]]\n" ] } ], "source": [ "# Generating Mapping Matrix for Water\n", "water = u.select_atoms(\"resname SOL and resid 500\")\n", "Beads_distribution = [['OW','HW1','HW2']]\n", "mapping_water = htf.matrix_mapping(water,Beads_distribution) \n", "print (mapping_water)" ] } ], "metadata": { "kernelspec": { "display_name": "Python (hoomd-tf)", "language": "python", "name": "hoomd-tf" }, "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.7.6" } }, "nbformat": 4, "nbformat_minor": 2 }