pablo-arantes / making-it-rain

Cloud-based molecular simulations for everyone
MIT License
377 stars 97 forks source link

UsageError: Line magic function `%%capture` not found #40

Closed spmolnar closed 1 year ago

spmolnar commented 1 year ago

Debian Bullseye/Jupyterlab

Copied making-it-rain-main files and sub-directories to Miniconda/envs/Jupyterlab/CC. Opened CHARMM_GUI in Notebook. Here are the results:

Open In Colab Hello there!

This is a Jupyter notebook for running Molecular Dynamics (MD) simulations using OpenMM engine and AMBER force field for Protein and Ligand systems. This notebook is a supplementary material of the paper "Making it rain: Cloud-based molecular simulations for everyone" (link here) and we encourage you to read it before using this pipeline.

The main goal of this notebook is to demonstrate how to harness the power of cloud-computing to run microsecond-long MD simulations in a cheap and yet feasible fashion.

This notebook is NOT a standard protocol for MD simulations! It is just simple MD pipeline illustrating each step of a simulation protocol.

Bugs

If you encounter any bugs, please report the issue to https://github.com/pablo-arantes/making-it-rain/issues

Acknowledgments

We would like to thank the OpenMM team for developing an excellent and open source engine.

We would like to thank the ChemosimLab (@ChemosimLab) team for their incredible ProLIF (Protein-Ligand Interaction Fingerprints) tool.

A Making-it-rain by Pablo R. Arantes (@pablitoarantes), Marcelo D. Polêto (@mdpoleto), Conrado Pedebos (@ConradoPedebos) and Rodrigo Ligabue-Braun (@ligabue_braun).

Also, credit to David Koes for his awesome py3Dmol plugin.

For related notebooks see: Making-it-rain

Introduction

In general, MD simulations rely on 1) a set of atomic coordinates of all atoms on a simulation box and 2) a set of force field parameters that describes the interaction energies between atoms.

In terms of inputs, we wil need:

A .pdb file of the protein and a .pdb file of the ligand containing a set of atomic coordinates.

In this notebook, we will simulate PDB 3HTB. To build our simulation box, we will use LEaP program (https://ambermd.org/tutorials/pengfei/index.php). The LEaP program is a portal between many chemical structure file types (.pdb and .mol2, primarily), and the Amber model parameter file types such as .lib, .prepi, parm.dat, and .frcmod. Each of the parameter files contains pieces of information needed for constructing a simulation, whether for energy minimization or molecular dynamics. LEaP functions within a larger workflow described in Section 1.1 of the Amber Manual.

To build ligand topology we will use general AMBER force field (GAFF - http://ambermd.org/antechamber/gaff.html) and The Open Force Field Toolkit (OpenFF - https://openforcefield.org/). GAFF is compatible with the AMBER force field and it has parameters for almost all the organic molecules made of C, N, O, H, S, P, F, Cl, Br and I. As a complete force field, GAFF is suitable for study of a great number of molecules in an automatic fashion. The Open Force Field Toolkit, built by the Open Force Field Initiative, is a Python toolkit for the development and application of modern molecular mechanics force fields based on direct chemical perception and rigorous statistical parameterization methods.

You can download the input files examples from here;

Setting the environment for MD calculation

Firstly, we need to install all necessary libraries and packages for our simulation. The main packages we will be installing are:

Anaconda (https://docs.conda.io/en/latest/miniconda.html)
OpenMM (https://openmm.org/)
PyTraj (https://amber-md.github.io/pytraj/latest/index.html)
py3Dmol (https://pypi.org/project/py3Dmol/)
ProLIF (https://github.com/chemosim-lab/ProLIF)
Numpy (https://numpy.org/)
Matplotlib (https://matplotlib.org/)
AmberTools (https://ambermd.org/AmberTools.php)

@title Install dependencies

@markdown It will take a few minutes, please, drink a coffee and wait. ;-)

%%capture

import sys

!pip -q install py3Dmol 2>&1 1>/dev/null

!pip install --upgrade MDAnalysis 2>&1 1>/dev/null

!pip install git+https://github.com/pablo-arantes/biopandas 2>&1 1>/dev/null

!pip install rdkit-pypi

!pip install Cython

!git clone https://github.com/pablo-arantes/ProLIF.git

prolif1 = "cd /content/ProLIF"

prolif2 = "sed -i 's/mdanalysis.*/mdanalysis==2.0.0/' setup.cfg"

prolif3 = "pip install ."

original_stdout = sys.stdout # Save a reference to the original standard output

with open('prolif.sh', 'w') as f:

sys.stdout = f # Change the standard output to the file we created.

print(prolif1)

print(prolif2)

print(prolif3)

sys.stdout = original_stdout # Reset the standard output to its original value

!chmod 700 prolif.sh 2>&1 1>/dev/null

!bash prolif.sh >/dev/null 2>&1

install conda

!wget -qnc https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

!bash Miniconda3-latest-Linux-x86_64.sh -bfp /usr/local 2>&1 1>/dev/null

!rm -r Miniconda3-latest-Linux-x86_64.sh /content/ProLIF prolif.sh

!conda install -y -q -c conda-forge openmm=7.6 python=3.7 pdbfixer 2>&1 1>/dev/null

!conda install -c conda-forge ambertools --yes 2>&1 1>/dev/null

!conda install -c ambermd pytraj --yes 2>&1 1>/dev/null

!conda install -c conda-forge parmed --yes 2>&1 1>/dev/null

!conda install -c conda-forge openff-toolkit --yes 2>&1 1>/dev/null

!conda install -c bioconda pybel --yes

!conda install -c openbabel openbabel --yes

load dependencies

sys.path.append('/usr/local/lib/python3.7/site-packages/')

from openmm import app, unit

from openmm.app import HBonds, NoCutoff, PDBFile

from openff.toolkit.topology import Molecule, Topology

from openff.toolkit.typing.engines.smirnoff import ForceField

from openff.toolkit.utils import get_data_file_path

import parmed as pmd

from biopandas.pdb import PandasPdb

import openmm as mm

from openmm import *

from openmm.app import *

from openmm.unit import *

import os

import urllib.request

import numpy as np

import MDAnalysis as mda

import py3Dmol

import pytraj as pt

import platform

import scipy.cluster.hierarchy

from scipy.spatial.distance import squareform

import scipy.stats as stats

import matplotlib.pyplot as plt

import pandas as pd

from scipy.interpolate import griddata

import seaborn as sb

from statistics import mean, stdev

from pytraj import matrix

from matplotlib import colors

from IPython.display import set_matplotlib_formats

!wget https://raw.githubusercontent.com/openforcefield/openff-forcefields/master/openforcefields/offxml/openff_unconstrained-2.0.0.offxml 2>&1 1>/dev/null

UsageError: Line magic function %%capture not found.

Please advise.

Thanks in advance.

pablo-arantes commented 1 year ago

Thank you for letting us know.

Best,

Pablo