Skip to main content

openmm-mdanalysis-reporter

Latest release Last release tag GitHub commits since latest release (by date) for a branch
Status GH Actions Status codecov
Community Powered by MDAnalysis

MDAnalysis based reporter for OpenMM

openmm-mdanalysis-reporter is bound by a Code of Conduct.

Currently a WIP but it should work

This is an OpenMM Reporter class that uses MDAnalysis for output. This means it can use any format supported by MDAnalysis. It also supports MDAnalysis selection strings.

The reporter is called MDAReporter, once this package is installed it can be imported as:

from mdareporter import MDAReporter

Installation

Pip:

pip install git+https://github.com/sef43/openmm-mdanalysis-reporter

From source:

git clone https://github.com/sef43/openmm-mdanalysis-reporter.git
cd openmm-mdanalysis-reporter
pip install .

Usage

It is used like the existing OpenMM reporters, where the file format is read from the suffix of the output file by MDAnalysis, e.g. to output in XYZ format:

from mdareporter import MDAReporter

...

simulation.reporters.append(MDAReporter('traj.xyz',100))
...

Additionally it supports the MDAnalysis selection syntax

# using MDAnalysis selection string to output just Carbon atoms

simulation.reporters.append(MDAReporter('traj.xyz',100, selection='name C'))

Example

Full example of using MDAReporter to output just the protein (script and data file in cd example):

from openmm.app import *
from openmm import *
from openmm.unit import *
from sys import stdout
from mdareporter import MDAReporter


pdb = PDBFile('villin.pdb')
forcefield = ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')
system = forcefield.createSystem(pdb.topology, nonbondedMethod=PME,
        nonbondedCutoff=1*nanometer, constraints=HBonds)
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.004*picoseconds)
simulation = Simulation(pdb.topology, system, integrator)
simulation.context.setPositions(pdb.positions)
simulation.minimizeEnergy(maxIterations=100)

# output just protein in xyz format
simulation.reporters.append(MDAReporter('traj.xyz',100, enforcePeriodicBox=False, selection="protein"))

simulation.reporters.append(StateDataReporter(stdout, 100, step=True,
        potentialEnergy=True, temperature=True))

simulation.step(1000)
    

Testing

testsuite can be run using pytest

cd mdareporter/tests
pytest

or

pytest --pyargs mdareporter.tests   

Benchmarks

A benchmarking script which writes trajectory snapshots every 10 steps for 1000 steps can be found at example/benchmark.py

The output on a M2 Macbook is:

OpenMM PDBReporter time =  7.989748208987294 s
OpenMM DCDReporter time =  5.6639587499958 s
MDAReporter format DCD time =  3.5682871250028256 s
MDAReporter format NCDF time =  3.609358207992045 s
MDAReporter format PDB time =  11.491382707987214 s
MDAReporter format TRR time =  4.7894440419913735 s
MDAReporter format XTC time =  4.086603666975861 s
MDAReporter format XYZ time =  5.835725833981996 s

Excluding MDAReporter using PDB format the MDAReporter formats are all as fast, or faster than the OpenMM formats.

Acknowledgements

Project based on the MDAnalysis Cookiecutter version 0.1. Please cite MDAnalysis when using openmm-mdanalysis-reporter in published work.

Release files for openmm-mdanalysis-reporter 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openmm-mdanalysis-reporter 0.1
File Size Uploaded
openmm-mdanalysis-reporter-0.1.tar.gz 277.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openmm-mdanalysis-reporter 0.1
File Interpreter ABI Platform
openmm_mdanalysis_reporter-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 418.2 kB

Release files / openmm-mdanalysis-reporter-0.1.tar.gz

Download URL openmm-mdanalysis-reporter-0.1.tar.gz
Size 277.9 kB
Tags Source
SHA-256 checksum
How to use checksums
07197732dc8e629297a5d2103bf133ac464d388e2e17ff06b242d3513aa972d8
BLAKE2b-256 checksum
How to use checksums
b10a67cbbc2d7179ffc64729d43a7e21b6893e79c64ce95481756c789d0be2d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / openmm_mdanalysis_reporter-0.1-py3-none-any.whl

Download URL openmm_mdanalysis_reporter-0.1-py3-none-any.whl
Size 140.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04b731c4529be1948bbb8ebd04cc977aea7139f87a5a91568f4e20d8723e0529
BLAKE2b-256 checksum
How to use checksums
5e36081bc6ffb18024d6f89885e2e635ca47ac20bd7ba221af59335861e066ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page