Skip to content

Instantly share code, notes, and snippets.

View mpharrigan's full-sized avatar

Matthew Harrigan mpharrigan

View GitHub Profile
@mpharrigan
mpharrigan / gist:aab6eac5032e94e5a043
Last active August 29, 2015 14:07
Example Slurm
#!/bin/bash
#SBATCH --partition=normal
#SBATCH --job-name=ip_engine
#SBATCH --output=ip_engine.out
#SBATCH --time=7-00:00:00
#SBATCH --time-min=02:00:00
#SBATCH --qos=normal
#SBATCH --nodes=1
#SBATCH --mem=64000
set mol [mol new {traj_fn} waitfor all]
mol addfile {top_fn} waitfor all
# Open data file
set sel [atomselect $mol all]
set nf [molinfo $mol get numframes]
set fp [open {dat_fn} r]
set line ""
# Each line of the data file corresponds to a frame
@mpharrigan
mpharrigan / gist:a31fabca534e8d4ef3d5
Created October 23, 2014 01:27
SLURM squeue aliases
alias ss='squeue --format="%.7i %9P %9j %9u %.13L %.13l %.16S %.2t %.5D %.5C %15R " --sort="t,-S"'
alias ssr='ss --states=R'
alias ssp='ss --states=PD'
@mpharrigan
mpharrigan / dmpc.pdb
Created December 3, 2014 05:53
Amber DMPC lipid
ATOM 14902 C12 MY 1 -25.136 10.163 9.358 1.00 0.00 MEMB
ATOM 14942 C13 MY 1 -24.372 9.630 8.213 1.00 0.00 MEMB
ATOM 14945 C14 MY 1 -25.074 9.701 6.922 1.00 0.00 MEMB
ATOM 14948 C15 MY 1 -25.460 8.518 6.468 1.00 0.00 MEMB
ATOM 14951 C16 MY 1 -26.583 8.386 5.816 1.00 0.00 MEMB
ATOM 14954 C17 MY 1 -27.221 6.099 4.694 1.00 0.00 MEMB
ATOM 14957 C18 MY 1 -28.077 5.983 3.677 1.00 0.00 MEMB
ATOM 14960 C19 MY 1 -28.644 4.770 3.859 1.00 0.00 MEMB
ATOM 14963 C110 MY 1 -27.454 3.698 4.032 1.00 0.00 MEMB
ATOM 14966 C111 MY 1 -26.798 3.485 2.647 1.00 0.00 MEMB
#!/bin/bash
#SBATCH --partition=long # or short, defq
#SBATCH --job-name=whatever
#SBATCH --output=whatever.%j.out
#SBATCH --time=5-00:00:00
#SBATCH --nodes=1
#SBATCH --mail-type=ALL
#SBATCH --mail-user=email@email.com
#SBATCH --ntasks=12 # or however many
@mpharrigan
mpharrigan / gist:61ce6cf4caab5dcd2398
Last active August 29, 2015 14:18
Pull Structures
from mdtraj.formats.dcd import DCDTrajectoryFile
from mdtraj.formats.prmtop import load_prmtop
km = KMedoids(...)
# "centers" is a pandas DataFrame with metadata about each trajectory
# from which we are pulling structures
def get_top(struc):
return centers.query("structure == @struc")['top_fn'].iloc[0]
from __future__ import print_function
import simtk.openmm as mm
import simtk.openmm.app as app
d = dict(base_dir="RUN2",
state='state.xml')
with open("{base_dir}/system.xml".format(**d)) as f:
system = mm.XmlSerializer.deserialize(f.read())
@mpharrigan
mpharrigan / 0-basic.py
Last active August 29, 2015 14:19
Potential msmbuilder workflow
# Basic usage / workflow
ds = dataset("**/*.dcd")
dihed = ds.derive('dihed', fmt='dir-npy')
dihed += DihedralFeaturizer().fit_transform(ds)
tica = dihed.derive('tica', fmt='hdf5')
tica += tICA().fit_transform(dihed)
clusters = tica.derive('clusters', fmt='hdf5')
@mpharrigan
mpharrigan / 0-basic.py
Created May 7, 2015 23:18
More Ideas for Datasets
ds = dataset("**/*.dcd", top='struct.pdb')
diheds = ds.fit_transform_with(DihedralFeaturizer(), 'diheds')
ticas = diheds.fit_transform_with(tICA(), 'ticas')
kmeans = KMeans(n_clusters=8)
clusters = ticas.fit_transform_with(kmeans, 'clusters')
msm = MSM().fit(clusters)
dump(msm, 'msm.pkl')
@mpharrigan
mpharrigan / 1-ffmpeg.sh
Last active June 3, 2019 05:11
Make a quality movie using ffmpeg
ffmpeg -i molecule.%5d.ppm -c:v libx264 -preset slow -crf 18 molecule.mkv
# -i input filenames
# -c:v codec (libx264 --> H.264)
# -preset duh
# -crf quality factor, lower = better, 18 = practically lossless
# output filename
# For colors, make sure you're using yuv444 which should be the default in newer ffmpeg