Skip to content

Instantly share code, notes, and snippets.

View orbeckst's full-sized avatar

Oliver Beckstein orbeckst

View GitHub Profile
@orbeckst
orbeckst / secondary_structure_TopologyAttribute.py
Last active November 10, 2025 08:20
Example for how to add a custom TopologyAttribute (for secondary structure) in MDAnalysis
import numpy as np
import MDAnalysis as mda
# (1) define the custom SecondaryStructure attribute
from MDAnalysis.core.topologyattrs import ResidueAttr
# Just *defining* this class registers it with MDAnalysis
# and makes "ss" available for Universe.add_TopologyAttr()
@orbeckst
orbeckst / mda_universe_from_array.py
Created January 9, 2025 00:20
Create a MDAnalysis Universe for a "trajectory" in a numpy array.
import MDAnalysis as mda
import numpy as np
n_atoms = 6
n_steps = 4
# create empty Universe with one atom per residue
u = mda.Universe.empty(n_atoms, n_residues=n_atoms, atom_resindex=np.arange(n_atoms), trajectory=True)
# optional: name each atom CA
@orbeckst
orbeckst / distances-legacy-0.ipynb
Last active June 12, 2021 05:00
Analysis of moving across the board in the game Pandemic Legacy Season 0.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / density-analysis.ipynb
Created January 6, 2021 01:14
Density Analysis in MDAnalysis
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / polymer_rdf_COM.ipynb
Last active August 31, 2025 03:41
Radial distribution function (RDF) calculation of the centers of mass of molecules with MDAnalysis.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / otf-blog.ipynb
Last active March 7, 2020 11:55
On-the-fly transformations blog post
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@orbeckst
orbeckst / xtc_vs_memreader.py
Created June 12, 2019 17:58
Testing memory consumption of the MDAnalysis XTCReader vs MemoryReader. See https://github.com/MDAnalysis/mdanalysis/wiki/memory-profiling
# -*- coding: utf-8 -*-
# load trajectory and iterate
import numpy as np
import tqdm
import MDAnalysis as mda
import gc
@orbeckst
orbeckst / dihedral_benchmark.ipynb
Last active August 27, 2018 16:59
benchmarking dihedral featurization in MDAnalysis
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.