{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "JV402f06Qs2I" }, "source": [ "" ] }, { "cell_type": "markdown", "metadata": { "id": "2JyzyqCTrO2i" }, "source": [ "Have you ever needed a reliable way to place the initial positions of Mg²⁺ ions in RNA or DNA molecular dynamics simulations? These divalent ions play a critical role in nucleic acid structure and dynamics.\n", "\n", "This tutorial demonstrating how to achieve this using our EPIPY package. The method is based on the 3DRISM-IDC theory, which was specifically developed to model solvation around highly negatively charged solutes such as nucleic acids.\n", "\n", "If you use the materials in this tutorial, please cite: \"A Python Tutorial for 3DRISM Solvation Calculations of Chemical and Biological Molecules\", Swanson, P., Cao, S., Huang, X, https://chemrxiv.org/engage/chemrxiv/article-details/68a6903c728bf9025e6c91ed" ] }, { "cell_type": "markdown", "metadata": { "id": "2UZUSEe9RzKv" }, "source": [ "## **Placing Magnesium in Highly Correlated Regions of RNA kink-Turn**\n", "\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "cellView": "form", "id": "e9Zwmfx1MLyE" }, "outputs": [], "source": [ "#@title ##Download and Install Episol\n", "#@markdown ($\\approx 2$min) Stable as of 07/01/25 eprism v1.2.6\n", "%%capture\n", "import subprocess\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "#%cd ../home/\n", "%cd $HOME/\n", "%mkdir episol\n", "%cd episol\n", "!wget https://github.com/EPISOLrelease/EPISOL/raw/refs/heads/main/src/fftw/fftw-3.3.8.tar.gz\n", "!echo \"+++++++++++++++++++\"\n", "!echo \"downloaded fftw files\"\n", "!echo \"+++++++++++++++++++\"\n", "!tar -xzf fftw-3.3.8.tar.gz\n", "%cd fftw-3.3.8/\n", "#!./configure --prefix=/home/fftw-3.3.8\n", "!./configure --prefix=$HOME/episol/fftw-3.3.8\n", "!make\n", "!make install\n", "%cd ../\n", "!wget https://github.com/EPISOLrelease/EPISOL/raw/refs/heads/main/src/kernel/release.tar.gz\n", "!echo \"+++++++++++++++++++\"\n", "!echo \"downloaded Episol files\"\n", "!echo \"+++++++++++++++++++\"\n", "!tar -xzf release.tar.gz\n", "%cd release/\n", "#!./configure --with-fftw=/home/fftw-3.3.8\n", "!./configure --with-fftw=$HOME/episol/fftw-3.3.8\n", "!make\n", "!make install\n", "#%cd /content\n", "########################### WRAPEPR\n", "!pip install episol==0.1.2\n", "#!python3.12 -m pip install --upgrade setuptools\n", "import subprocess\n", "import os\n", "import threading\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from episol import epipy\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "cellView": "form", "id": "Pz6E85eEOsUO" }, "outputs": [], "source": [ "%%capture\n", "\n", "#@title Install some python packages for topology generation\n", "#@markdown ($\\approx$4-8min)\n", "\n", "#@markdown This will prompt a restart in our colab session, this is necessary, just keep moving\n", "\n", "#@markdown (if you are using the notebook offline this wont be necessary, as presumably you'll have your own forcefield to generate topologies)\n", "########################################\n", "# FOR COLAB USERS ONLY #\n", "#---------------------------------------#\n", "# if you are running locally you dont need\n", "# condacolab. Just use your local conda dist\n", "########################################\n", "!pip install -q condacolab\n", "import condacolab\n", "condacolab.install()\n", "########################################\n", "#!conda update conda\n", "#!conda install --yes -c conda-forge python=3.11 numpy=1.26.4 openmm pdbfixer parmed mdanalysis py3dmol rdkit openff-toolkit\n", "#!conda install -y -c conda-forge numpy=1.26.4 openmm=8.3.1 python={PYTHON_VERSION} pdbfixer=1.11 parmed=4.3.0 mdanalysis=2.9.0 py3dmol=2.5.2 rdkit=2025.03.5 openff-toolkit=0.17.0 libgcc\n", "!conda install -y -c conda-forge python=3.12 numpy=1.26.4 openmm=8.3.1 pdbfixer=1.11 parmed=4.3.0 mdanalysis=2.9.0 py3dmol=2.5.2 rdkit=2025.03.5 openff-toolkit=0.17.0 torchvision pymol-open-source\n", "!python3.12 -m pip install --upgrade setuptools\n", "!python -m ensurepip --upgrade\n", "#openmm pdbfixer parmed mdanalysis py3dmol rdkitconda install libgcc" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "cellView": "form", "id": "rjpO1aNMD_89" }, "outputs": [], "source": [ "#@title import our downloaded packages\n", "%%capture\n", "!python -m ensurepip --upgrade # since we are using python 3.12 some pkg utils are now obsolete\n", "# after conda-initiate restart colab resets pip\n", "import matplotlib.pyplot as plt\n", "import openmm as mm\n", "from openmm import app\n", "# fix later\n", "from openmm.app import *\n", "from openmm.unit import *\n", "import py3Dmol# as pymol\n", "import MDAnalysis as md\n", "import parmed as chem\n", "from openff.toolkit.topology import Molecule, Topology\n", "import numpy as np\n", "import MDAnalysis.transformations as mdt\n", "import pdbfixer\n", "from episol import epipy\n", "%cd /content/" ] }, { "cell_type": "markdown", "metadata": { "id": "MgcR5034eDJ8" }, "source": [ "#**Walk Through Calculation:**" ] }, { "cell_type": "markdown", "metadata": { "id": "zHzfYZ4dbftJ" }, "source": [ "First, we will download our desired structure file from the PDB" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "cellView": "form", "colab": { "base_uri": "https://localhost:8080/" }, "id": "bS2Q05mOqDCw", "outputId": "5867ebc2-9040-4d4e-d002-c35322e0ba58" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--2025-10-28 21:21:58-- https://files.rcsb.org/download/7EFH.pdb\n", "Resolving files.rcsb.org (files.rcsb.org)... 3.166.135.85, 3.166.135.84, 3.166.135.67, ...\n", "Connecting to files.rcsb.org (files.rcsb.org)|3.166.135.85|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: unspecified [text/plain]\n", "Saving to: ‘7EFH.pdb.2’\n", "\n", "\r7EFH.pdb.2 [<=> ] 0 --.-KB/s \r7EFH.pdb.2 [ <=> ] 53.47K --.-KB/s in 0.01s \n", "\n", "2025-10-28 21:21:58 (4.11 MB/s) - ‘7EFH.pdb.2’ saved [54756]\n", "\n" ] } ], "source": [ "PDB_ID='7EFH' # @param {type:\"string\", placeholder:\"enter a value\"}\n", "PDB_ID = PDB_ID.strip()\n", "!wget https://files.rcsb.org/download/\"{PDB_ID}.pdb\"" ] }, { "cell_type": "markdown", "metadata": { "id": "I42ifhq8myTE" }, "source": [ "we can see that our unit cell is very large, using such a large box as input for 3DRISM is possible, but the extra 'blank space' equates to an excessive ammout of RAM\n", "* to combat this we will modify the unit cell to be much smaller, saving cost while maintaining acuuracy\n", "* since we are using a interaction-cutoff of 1nm, we will add a buffer on our PBC cell\n", "* Again, before we run 3DRISM, we need to generate a topology file for our molecule\n", "* we will use PDBFixer to add missing residues, atoms and hydrogens\n" ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "id": "ntrL86DiEPPd" }, "outputs": [], "source": [ "buffer = 7 # angstroms" ] }, { "cell_type": "markdown", "metadata": { "id": "qqU38HufEpVr" }, "source": [ "* now we clean our PDB file and generate a topology, we wont include any ions in this example\n", "* this protocol will work for essentailly any PDB (within reason) so feel free to download a different PDB and redo the tutorial\n" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "cellView": "form", "colab": { "base_uri": "https://localhost:8080/", "height": 497 }, "id": "Mgn1qEcfqT5j", "outputId": "348609b8-5677-4720-89a4-ec9d74492d0f" }, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.
3Dmol.js failed to load for some reason. Please check your browser console for error messages.