The API for ParmEd Command-line Utilities

In some cases, parmed interpreter is insufficient to do what you need it to do, or perhaps you want to use some of parmed‘s functionality in your own Python script or program.

In that case, the ParmEd API is here! Every Action subclass is available for import from For a full listing of available actions, you are forward to the auto-generated list in the parmed page.

Importing the actions

All actions can be imported from with the same camelCase shown in the parmed page. Examples are shown below:

>>> from import change, addLJType, changeRadii, tiMerge
>>> from import setBond, deleteBond, addDihedral, addPDB

Using the actions

Each of the actions described on the previous page can be invoked either on a parm list (a few, like interpolate, actually require a parm list with multiple topologies), or a raw AmberParm object. Note that some actions do not support all AmberParm subclasses (like those for the CHARMM or Amoeba force fields).

The first step is to instantiate the action with the AmberParm instance as the first argument. The arguments that each action requires in the ParmEd interpreter can then be given as separate arguments to the constructor or all as a single string in the second argument. Keyword arguments can optionally be given as keyword arguments to the action constructor.

Examples of valid syntax for addLJType are shown below:

from import addLJType
from parmed.amber import AmberParm

parm = AmberParm('trx.prmtop')

# All arguments as one string, a la parmed
action = addLJType(parm, "@1 radius 1.5 epsilon 0.5")

# Equivalent; all arguments separate
action = addLJType(parm, "@1", "radius", 1.5, "epsilon", 0.5)

# Also equivalent; keyword arguments given as keywords
action = addLJType(parm, "@1", radius=1.5, epsilon=0.5)

Note that simply instantiating the object does not do anything. You need to explicitly execute it as well, as shown below (continuting from the example above):


The informational message printed to the ParmEd output are available by casting the action to a string:


# Equivalent:
print('%s' % action)