Skip to content
Jason Swails edited this page Dec 20, 2018 · 15 revisions

Table of Contents


ParmEd: The Parameter file Editor

Welcome to the ParmEd wiki!

Please feel free to add to this page with any corrections, wisdoms, tricks, or anything else you think may make this a better resource for users.

What is ParmEd

ParmEd is a program written in pure Python that has a wide range of capabilities useful for molecular mechanical studies on chemical systems. It started as a program designed to make manipulating Amber topology files easier, but has grown immensely and can now do a range of diverse tasks, including running GPU-accelerated molecular dynamics simulations very efficiently using OpenMM (https://simtk.org/home/openmm).

ParmEd is also released as part of AmberTools. However, given ParmEd's rapid pace of development and expanding scope beyond just the Amber suite of programs, I have begun a Github repository to make developments available more frequently than standard AmberTools releases and to hopefully encourage more widespread adoption and contributions.

There are two primary components to ParmEd. The first is the underlying class hierarchy, written in pure Python, which provides reliable parsers for a wide range of Amber and CHARMM file formats including AMBER topology, coordinate, NetCDF restart, and NetCDF trajectory files as well as the protein structure file (PSF), residue topology file (RTF), parameter file (PAR), stream file (STR), coordinate file, and restart file used by CHARMM.

The second component is the set of ParmEd Action classes that allow you to interact with and modify Amber topology files reliably in order to make targeted changes to the underlying Hamiltonian. An interpreter was written that will read user input (in the form of typing from a terminal or in the form of a prepared script) and perform the various Actions on the topology files.

I recently added OpenMM capabilities to the underlying classes (the first component described). API documentation as well as detailed, annotated examples for using the classes here to perform simulations using OpenMM is provided in the pages listed below.

The ParmEd interpreter

There are two executable programs distributed with ParmEd: parmed.py and xparmed.py. These programs were designed to give access to the APIs described in the next sections with an easy textual (scriptable) interface (parmed.py) and a point-and-click GUI (xparmed.py).

Click here for ParmEd intepreter instructions

The parmed package and API

The classes provided in the parmed package provide a simple(r) interface to Amber and CHARMM files and the data they contain using a set of Python classes that can be used in your own Python scripts.

The documentation is generated automatically using sphinx and is available on the main ParmEd webpage: http://parmed.github.io/ParmEd/parmed

A summary of the major classes and the files that they parse (and use to set up their internal data structures) is listed below:

AMBER-related classes

  • AmberParm -- Amber topology file class
  • ChamberParm -- Amber-style topology file class defining a CHARMM potential
  • AmoebaParm -- Amber-style topology file class defining an AMOEBA potential
  • Rst7 -- Amber input coordinate (and restart file) class
  • AmberAsciiRestart -- Amber restart/inpcrd file class
  • AmberMdcrd -- Amber ASCII trajectory file class (pure Python)
  • NetCDFRestart -- Amber NetCDF-style restart file class*
  • NetCDFTraj -- Amber NetCDF-style trajectory file class*

CHARMM-related classes

  • CharmmPsfFile -- CHARMM Protein Structure File (PSF) class
  • CharmmParameterSet -- CHARMM Residue Topology File (RTF), Parameter File (PAR), and stream file (STR) parsers.**
  • CharmmCrdFile -- CHARMM coordinate file class***
  • CharmmRstFile -- CHARMM restart file class***

* Performant NetCDF trajectory/restart file writing requires the netCDF4 Python package

** Only the atom types and parameter types are parsed from these files

*** These classes only support reading the data from these files. All other classes support both reading and writing.

The parmed.tools package and API

The parmed.tools Python package allows you to incorporate the actions available in the ParmEd interpreter (see above) directly in your Python scripts. This gives added flexibility for reusing core ParmEd functionality inside your own scripts. The translation between an Action's use in the interpreter and its use via the API in your own Python program is simple and flexible. You must first import the desired action and instantiate a prmtop class (AmberParm, ChamberParm, TinkerParm, or one of its OpenMM-enabled equivalents). The command-line you would use for that action in the interpreter can then be applied either as a single-string argument or each argument can be given a separate string (and keyword arguments can be specified as arbitrary keyword-pairs). You must then run the execute() command for that action (casting the action to a str will yield the printout seen in the ParmEd interpreter). An example for addLJType is shown below

from parmed import load_file
from parmed.tools import addLJType

parm = load_file('your.prmtop')
act = addLJType(parm, '@1 radius 1.0 epsilon 0.5')
print(str(act))
act.execute()

Alternatively, the following syntax also works

from parmed.amber.readparm import AmberParm
from parmed.tools import addLJType

parm = AmberParm('your.prmtop')
act = addLJType(parm, '@1', radius=1.0, epsilon=0.5)
print(str(act))
act.execute()

Using the OpenMM API in parmed

ParmEd includes classes for running simulations using OpenMM. So far, OpenMM System objects capable of performing energy, force, and molecular dynamics calculations can be created for AmberParm, ChamberParm, and CharmmPsfFile objects.

Running a simulation with Amber, CHARMM, or GROMACS files

Any Structure subclass that was instantiated with parameters can be used to perform calculations with OpenMM directly. For Amber and GROMACS files, that means reading a topology file (prmtop) and coordinate file. For CHARMM, a PSF file contains only the connectivity -- parameters need to be loaded separately using the load_parameters method on the CHARMM PSF instance.

These files provide an almost identical interface as the Amber file classes in OpenMM's application layer, but these classes are compatible with the ParmEd API and they work for old-style Amber topology files.

Click here to see some examples for running OpenMM Simulations with Amber files

Some tricks and recipes for OpenMM Simulations

OpenMM is designed to be a highly flexible library. That comes with a cost -- it's not always clear if you can do something you want to or how to do it. I've created a page where people can share their tricks and bits of wisdom through code samples and brief explanations on this Wiki. Many of them assume familiarity with the AMBER or CHARMM Python examples available here.

Click here to visit the page of OpenMM Tricks and Recipes