Skip to content

Instantly share code, notes, and snippets.

View orbeckst's full-sized avatar

Oliver Beckstein orbeckst

View GitHub Profile
@orbeckst
orbeckst / water_1.dx
Last active September 4, 2015 20:53
water density around I-FABP (pdb: 2IFB) from GSBP MD simulation
# OpenDX density file written by
# $Id: sitemap.py 1706 2008-04-09 21:14:48Z oliver $
# File format: http://opendx.sdsc.edu/docs/html/pages/usrgu068.htm#HDREDF
# Data are embedded in the header and tied to the grid positions.
# Unit of length is Angstrom.
# Unit of density is TIP3P-based.
# Data is written in C array order: In grid[x,y,z] the axis z is fastest
# varying, then y, then finally x, i.e. z is the innermost loop.
# Meta data stored with the python Grid object:
# totaltime = 19998.998
@orbeckst
orbeckst / speed benchmark.ipynb
Last active December 13, 2015 19:05 — forked from kain88-de/speed benchmark.ipynb
offset fileformat speed benchmark
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / assert_test.py
Created February 15, 2016 18:31
demonstrate that `python -O` removes `assert`
# test assert vs assert_
# run with
# python assert_test.py
# and
# python -O assert_test.py
#
# to see that assert is optimized away by -O
from numpy.testing import assert_
@orbeckst
orbeckst / HOP_TESTRUN.sh
Last active May 27, 2016 19:01
manual test run for Becksteinlab/hop
#!/bin/bash
# get test data from https://www.dropbox.com/sh/jp1n4zc7q5nxvzf/AABrM8iEypZE-g2gOFfOgahRa?dl=0
# see https://github.com/Becksteinlab/hop/wiki/Testing#manual-tests
TESTDIR=analysis
PSF=ifabp_water.psf
DCD=rmsfit_ifabp_water_1.dcd
CUTOFF=1.3
@orbeckst
orbeckst / mda_rmsf.py
Last active May 30, 2016 19:37
How to calculate RMSF with MDAnalysis
import numpy as np
import MDAnalysis as mda
u = mda.Universe("topol.tpr", "trj.xtc")
ca = u.select_atoms("name CA")
means = np.zeros((len(ca), 3))
sumsq = np.zeros_like(means)
for k, ts in enumerate(u.trajectory):
sumsq += (k/(k+1.0)) * (ca.positions - means)**2
means[:] = (k*means + ca.positions)/(k+1.0)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / hole_orderparameter.ipynb
Last active July 28, 2016 21:27
Example for using HOLE with MDAnalysis to analyze a trajectory of the gramicidin A pore. We study the pore radius as a function of a RMSD order parameter.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / mda-dask.ipynb
Last active March 13, 2017 11:57
Parallel analysis with MDAnalysis and dask
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / bfactor-coloring-with-MDAnalysis.ipynb
Last active September 22, 2023 05:21
Example for how to calculate the RMSF with MDAnalysis and write a PDB file with the b-factor colored by RMSF.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env python2.7
import MDAnalysis as mda
import MDAnalysis.analysis.hbonds
def select_monomers(u, nmer=4):
protein = u.select_atoms("protein")
# note: bynum is 1-based so range starts at 1
monomers = [u.select_atoms("protein and bynum " + str(i1) + ":" + str(i2)) for i1 in range(1, protein.n_atoms, protein.n_atoms/nmer) for i2 in [i1+protein.n_atoms/nmer - 1]]