parmed.amber.readparm module

This module is simply a namespace for all Amber topology-like classes. There are different variants; for instance the standard Amber topology, the chamber-made topology, and the tinker_to_amber-made topology. These classes are all defined in their own private modules, but imported here to simplify the API.

Copyright (C) 2010 - 2014 Jason Swails

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

class parmed.amber.readparm.AmberFormat(fname=None)[source]

Bases: object

A class that can parse and print files stored in the Amber topology or MDL format. In particular, these files have the general form:

` %VERSION VERSION_STAMP = V00001.000  DATE = XX/XX/XX  XX:XX:XX %FLAG <FLAG_NAME> %COMMENT <comments> %FORMAT(<Fortran_Format>) ... data corresponding to that Fortran Format %FLAG <FLAG_NAME2> %COMMENT <comments> %FORMAT(<Fortran_Format>) ... data corresponding to that Fortran Format `

where the %COMMENT sections are entirely optional

Parameters
fnamestr=None

If provided, this file is parsed and the data structures will be loaded from the data in this file

Attributes
parm_datadict {str

A dictionary that maps FLAG names to all of the data contained in that section of the Amber file.

formatsdict {str

A dictionary that maps FLAG names to the FortranFormat instance in which the data is stored in that section

parm_commentsdict {str

A dictionary that maps FLAG names to the list of COMMENT lines that were stored in the original file

flag_listlist

An ordered list of all FLAG names. This must be kept synchronized with parm_data, formats, and parm_comments such that every item in flag_list is a key to those 3 dicts and no other keys exist

charge_flagstr=’CHARGE’

The name of the name of the FLAG that describes partial atomic charge data. If this flag is found, then its data are multiplied by the ELECTROSTATIC_CONSTANT to convert back to fractions of electrons

versionstr

The VERSION string from the Amber file

namestr

The file name of the originally parsed file (set to the fname parameter)

Methods

add_flag(flag_name, flag_format[, data, …])

Adds a new flag with the given flag name and Fortran format string and initializes the array with the values given, or as an array of 0s of length num_items

delete_flag(flag_name)

Removes a flag from the topology file

id_format(filename)

Identifies the file type as either Amber-format file (like prmtop) or an old-style topology file.

parse(filename, *args, **kwargs)

Meant for use with the automatic file loader, this will automatically return a subclass of AmberFormat corresponding to what the information in the prmtop file contains (i.e., either an AmberParm, ChamberParm, AmoebaParm, or AmberFormat)

rdparm(fname[, slow])

Parses the Amber format file

rdparm_old(prmtop_lines[, check])

This reads an old-style topology file and stores the results in the same data structures as a new-style topology file

rdparm_slow(fname)

Parses the Amber format file.

set_version()

Sets the version string

view_as(cls)

Returns a view of the current object as another object.

write_parm(name)

Writes the current data in parm_data into a new topology file with the given name

add_flag(flag_name, flag_format, data=None, num_items=- 1, comments=None, after=None)[source]

Adds a new flag with the given flag name and Fortran format string and initializes the array with the values given, or as an array of 0s of length num_items

Parameters
flag_namestr

Name of the flag to insert. It is converted to all upper case

flag_formatstr

Fortran format string representing how the data in this section should be written and read. Do not enclose in ()

datalist=None

Sequence with data for the new flag. If None, a list of zeros of length num_items (see below) is given as a holder

num_itemsint=-1

Number of items in the section. This variable is ignored if a set of data are given in data

commentslist of str=None

List of comments to add to this section

afterstr=None

If provided, the added flag will be added after the one with the name given to after. If this flag does not exist, IndexError will be raised

Raises
AmberError if flag already exists
IndexError if the after flag does not exist
delete_flag(flag_name)[source]

Removes a flag from the topology file

static id_format(filename)[source]

Identifies the file type as either Amber-format file (like prmtop) or an old-style topology file.

Parameters
filenamestr

Name of the file to check format for

Returns
is_fmtbool

True if it is an Amber-style format, False otherwise

static parse(filename, *args, **kwargs)[source]

Meant for use with the automatic file loader, this will automatically return a subclass of AmberFormat corresponding to what the information in the prmtop file contains (i.e., either an AmberParm, ChamberParm, AmoebaParm, or AmberFormat)

rdparm(fname, slow=False)[source]

Parses the Amber format file

rdparm_old(prmtop_lines, check=False)[source]

This reads an old-style topology file and stores the results in the same data structures as a new-style topology file

Parameters
prmtop_lineslist of str

List of all lines in the prmtop file

checkbool, optional

If True, only the first couple sections will be read to determine if this is, in fact, an old-style topology file

rdparm_slow(fname)[source]

Parses the Amber format file. This parser is written in pure Python and is therefore slower than the C++-optimized version

set_version()[source]

Sets the version string

view_as(cls)[source]

Returns a view of the current object as another object.

Parameters
clstype

Class definition of an AmberParm subclass for the current object to be converted into

Returns
instance of cls initialized from data in this object. This is NOT a deep
copy, so modifying the original object may modify this. The copy
function will create a deep copy of any AmberFormat-derived object
write_parm(name)[source]

Writes the current data in parm_data into a new topology file with the given name

Parameters
namestr or file-like

Name of the file to write the topology file to or file-like object to write

class parmed.amber.readparm.AmberParm(prm_name=None, xyz=None, box=None, rst7_name=None)[source]

Bases: parmed.amber.amberformat.AmberFormat, parmed.structure.Structure

Amber Topology (parm7 format) class. Gives low, and some high, level access to topology data. You can interact with the raw data in the topology file directly or interact with some of the high-level classes comprising the system topology and parameters.

Parameters
prm_namestr, optional

If provided, this file is parsed and the data structures will be loaded from the data in this file

xyzstr or array, optional

If provided, the coordinates and unit cell dimensions from the provided Amber inpcrd/restart file will be loaded into the molecule, or the coordinates will be loaded from the coordinate array

boxarray, optional

If provided, the unit cell information will be set from the provided unit cell dimensions (a, b, c, alpha, beta, and gamma, respectively)

Attributes
parm_datadict {str

A dictionary that maps FLAG names to all of the data contained in that section of the Amber file.

formatsdict {str

A dictionary that maps FLAG names to the FortranFormat instance in which the data is stored in that section

parm_commentsdict {str

A dictionary that maps FLAG names to the list of COMMENT lines that were stored in the original file

flag_listlist

An ordered list of all FLAG names. This must be kept synchronized with parm_data, formats, and parm_comments such that every item in flag_list is a key to those 3 dicts and no other keys exist

charge_flagstr=’CHARGE’

The name of the name of the FLAG that describes partial atomic charge data. If this flag is found, then its data are multiplied by the ELECTROSTATIC_CONSTANT to convert back to fractions of electrons

versionstr

The VERSION string from the Amber file

namestr

The file name of the originally parsed file (set to the fname parameter)

LJ_typesdict {str

A mapping whose keys are atom types paired with the nonbonded index of that type

LJ_radiuslist(float)

A list of floats corresponding to the Rmin/2 parameter for every Lennard-Jones type. The indexes are the nonbonded index (nb_idx attribute of the Atom class) minus 1 to account for indexing from 0 in Python. The values are in Angstroms. To get the radius for a particular atom type, you can use LJ_radius[LJ_types[“type”]-1]

LJ_depthlist(float)

A list of Lennard-Jones epsilon parameters laid out the same way as LJ_radius, described above.

atomsAtomList(Atom)

List of all atoms in the system

residuesResidueList(Residue)

List of all residues in the system

bondsTrackedList(Bond)

List of bonds between two atoms in the system

anglesTrackedList(Angle)

List of angles between three atoms in the system

dihedralsTrackedList(Angle)

List of all proper and improper torsions between 4 atoms in the system

boxlist of 6 floats

Periodic boundary unit cell dimensions and angles

bond_typesTrackedList(BondType)

The bond types containing the parameters for each bond stretching term

angle_typesTrackedList(AngleType)

The angle types containing the parameters for each angle bending term

dihedral_typesTrackedList(DihedralType)

The dihedral types containing the parameters for each torsional term

bonds_inc_hiterator(Bond)

All bonds including hydrogen

bonds_without_hiterator(Bond)

All bonds without hydrogen

angles_inc_hiterator(Angle)

All angles including hydrogen

angles_without_hiterator(Angle)

All angles including hydrogen

dihedrals_inc_hiterator(Dihedral)

All dihedrals including hydrogen

dihedrals_without_hiterator(Dihedral)

All dihedrals including hydrogen

chamberbool=False

Whether this instance uses the CHARMM force field

amoebabool=False

Whether this instance uses the Amoeba force field

has_cmapbool=False

Whether this instance has correction map terms or not

Methods

add_atom(atom, resname, resnum[, chain, …])

Adds a new atom to the Structure, adding a new residue to residues if it has a different name or number as the last residue added and adding it to the atoms list.

add_atom_to_residue(atom, residue)

Adds a new atom to the Structure at the end if the given residue

add_flag(flag_name, flag_format[, data, …])

Adds a new flag with the given flag name and Fortran format string and initializes the array with the values given, or as an array of 0s of length num_items

assign_bonds(*reslibs)

Assigns bonds to all atoms based on the provided residue template libraries.

copy(cls[, split_dihedrals])

Makes a copy of the current structure as an instance of a specified subclass

createSystem([nonbondedMethod, …])

Construct an OpenMM System representing the topology described by the prmtop file.

delete_flag(flag_name)

Removes a flag from the topology file

fill_LJ()

Calculates the Lennard-Jones parameters (Rmin/2 and epsilon) for each atom type by computing their values from the A and B coefficients of each atom interacting with itself.

from_rawdata(rawdata)

Take the raw data from a AmberFormat object and initialize an AmberParm from that data.

from_structure(struct[, copy])

Take a Structure instance and initialize an AmberParm instance from that data.

get_box([frame])

In some cases, multiple conformations may be stored in the Structure.

get_coordinates([frame])

In some cases, multiple conformations may be stored in the Structure.

has_1012()

This routine determines whether there are any defined 10-12 Lennard-Jones interactions that are non-zero

has_NBFIX()

This routine determines whether there are any off-diagonal Lennard-Jones modifications (i.e., if any two atoms have a L-J pair interaction that does not match the combined L-J parameters for that pair).

id_format(filename)

Identifies the file type as either Amber-format file (like prmtop) or an old-style topology file.

initialize_topology([xyz, box])

Initializes topology data structures, like the list of atoms, bonds, etc., after the topology file has been read.

is_changed()

Determines if any of the topological arrays have changed since the last upload

join_dihedrals()

Joins multi-term torsions into a single term and makes all of the parameters DihedralTypeList instances.

load_atom_info()

Loads atom properties into the atoms that have been loaded.

load_dataframe(df)

Loads atomic properties from an input DataFrame

load_pointers()

Loads the data in POINTERS section into a pointers dictionary with each key being the pointer name according to http://ambermd.org/formats.html

load_rst7(rst7)

Loads coordinates into the AmberParm class

load_structure()

Loads all of the topology instance variables.

omm_add_constraints(system, constraints, …)

Adds constraints to a given system

omm_angle_force([constraints, …])

Creates an OpenMM HarmonicAngleForce object (or AmoebaAngleForce if the angles are for an Amoeba-parametrized system)

omm_bond_force([constraints, rigidWater, …])

Creates an OpenMM Bond Force object (or AmoebaBondForce if the bonds are for an Amoeba-parametrized system)

omm_cmap_force()

Creates the OpenMM CMAP torsion force

omm_dihedral_force([split])

Creates the OpenMM PeriodicTorsionForce modeling dihedrals

omm_gbsa_force(implicitSolvent[, …])

Creates a Generalized Born force for running implicit solvent calculations

omm_improper_force()

Creates the OpenMM improper torsion force (quadratic bias)

omm_nonbonded_force([nonbondedMethod, …])

Creates the OpenMM NonbondedForce (and CustomNonbondedForce if necessary) to define the nonbonded interatomic potential for this system.

omm_out_of_plane_bend_force()

Creates the Amoeba out-of-plane bend force

omm_pi_torsion_force()

Creates the Amoeba pi-torsion force

omm_rb_torsion_force()

Creates the OpenMM RBTorsionForce for Ryckaert-Bellemans torsions

omm_set_virtual_sites(system)

Sets the virtual sites in a given OpenMM System object from the extra points defined in this system

omm_stretch_bend_force()

Create the OpenMM Amoeba stretch-bend force for this system

omm_torsion_torsion_force()

Create the OpenMM Amoeba coupled-torsion (CMAP) force

omm_trigonal_angle_force()

Creates the Amoeba trigonal-angle force

omm_urey_bradley_force()

Creates the OpenMM Urey-Bradley force

parse(filename, *args, **kwargs)

Meant for use with the automatic file loader, this will automatically return a subclass of AmberFormat corresponding to what the information in the prmtop file contains (i.e., either an AmberParm, ChamberParm, AmoebaParm, or AmberFormat)

prune_empty_terms()

Looks through all of the topological lists and gets rid of terms in which at least one of the atoms is None or has an idx attribute set to -1 (indicating that it has been removed from the atoms atom list)

ptr(pointer)

Returns the value of the given pointer, and converts to upper-case so it’s case-insensitive.

rdparm(fname[, slow])

Parses the Amber format file

rdparm_old(prmtop_lines[, check])

This reads an old-style topology file and stores the results in the same data structures as a new-style topology file

rdparm_slow(fname)

Parses the Amber format file.

recalculate_LJ()

Fills the LENNARD_JONES_ACOEF and LENNARD_JONES_BCOEF arrays in the parm_data raw data dictionary by applying the canonical Lorentz-Berthelot combining rules to the values in LJ_radius and LJ_depth.

rediscover_molecules([solute_ions, fix_broken])

This determines the molecularity and sets the ATOMS_PER_MOLECULE and SOLVENT_POINTERS sections of the prmtops.

remake_parm()

Fills parm_data from the data in the parameter and topology arrays (e.g., atoms, bonds, bond_types, …)

save(fname[, format, overwrite])

Saves the current Structure in the requested file format.

set_version()

Sets the version string

split()

Split the current Structure into separate Structure instances for each unique molecule.

strip(selection)

Deletes a subset of the atoms corresponding to an atom-based selection.

to_dataframe()

Generates a DataFrame from the current Structure’s atomic properties

unchange()

Toggles all lists so that they do not indicate any changes

update_dihedral_exclusions()

Nonbonded exclusions and exceptions have the following priority:

view_as(cls)

Returns a view of the current object as another object.

visualize(*args, **kwargs)

Use nglview for visualization.

write_cif(dest[, renumber, coordinates, …])

Write a PDB file from the current Structure instance

write_parm(name)

Writes the current data in parm_data into a new topology file with a given name.

write_pdb(dest[, renumber, coordinates, …])

Write a PDB file from a Structure instance

write_psf(dest[, vmd])

Writes a PSF file from the stored molecule

write_rst7(name[, netcdf])

Writes a restart file with the current coordinates and velocities and box info if it’s present

property amoeba

Whether this instance uses the Amoeba force field

property angles_inc_h

All angles including hydrogen

property angles_without_h

All angles including hydrogen

property bonds_inc_h

All bonds including hydrogen

property bonds_without_h

All bonds without hydrogen

property box
property chamber

Whether this instance uses the CHARMM force field

property dihedrals_inc_h

All dihedrals including hydrogen

property dihedrals_without_h

All dihedrals including hydrogen

fill_LJ()[source]

Calculates the Lennard-Jones parameters (Rmin/2 and epsilon) for each atom type by computing their values from the A and B coefficients of each atom interacting with itself.

This fills the LJ_radius, LJ_depth, and LJ_types data structures.

classmethod from_rawdata(rawdata)[source]

Take the raw data from a AmberFormat object and initialize an AmberParm from that data.

Parameters
rawdataAmberFormat

An AmberFormat instance that has already been instantiated

Returns
parmAmberParm

An instance of this type from the data in rawdata

classmethod from_structure(struct, copy=False)[source]

Take a Structure instance and initialize an AmberParm instance from that data.

Parameters
structStructure

The input structure from which to construct an AmberParm instance

copybool

If True, the input struct is deep-copied to make sure it does not share any objects with the original struct. Default is False

Returns
instAmberParm

The AmberParm instance derived from the input structure

Raises
TypeError

If the structure has parameters not supported by the standard Amber force field (i.e., standard bond, angle, and dihedral types)

Notes

Due to the nature of the prmtop file, struct almost always returns a deep copy. The one exception is when struct is already of type AmberParm, in which case the original object is returned unless copy is True.

has_1012()[source]

This routine determines whether there are any defined 10-12 Lennard-Jones interactions that are non-zero

Returns
has_10_12bool

If True, 10-12 interactions are defined for this particular system

has_NBFIX()[source]

This routine determines whether there are any off-diagonal Lennard-Jones modifications (i.e., if any two atoms have a L-J pair interaction that does not match the combined L-J parameters for that pair).

Returns
nbfixbool

If True, off-diagonal elements in the combined Lennard-Jones matrix exist. If False, they do not.

property has_cmap

Whether this instance has correction map terms or not

initialize_topology(xyz=None, box=None)[source]

Initializes topology data structures, like the list of atoms, bonds, etc., after the topology file has been read.

is_changed()[source]

Determines if any of the topological arrays have changed since the last upload

load_atom_info()[source]

Loads atom properties into the atoms that have been loaded. If any arrays are too short or too long, an IndexError will be raised

load_pointers()[source]

Loads the data in POINTERS section into a pointers dictionary with each key being the pointer name according to http://ambermd.org/formats.html

load_rst7(rst7)[source]

Loads coordinates into the AmberParm class

Parameters
rst7str or Rst7

The Amber coordinate file (either ASCII restart or NetCDF restart) object or filename to assign atomic coordinates from.

load_structure()[source]

Loads all of the topology instance variables. This is necessary if we actually want to modify the topological layout of our system (like deleting atoms)

omm_nonbonded_force(nonbondedMethod=None, nonbondedCutoff=Quantity(value=8, unit=angstrom), switchDistance=Quantity(value=0, unit=angstrom), ewaldErrorTolerance=0.0005, reactionFieldDielectric=78.5)[source]

Creates the OpenMM NonbondedForce (and CustomNonbondedForce if necessary) to define the nonbonded interatomic potential for this system. A CustomNonbondedForce is used for the r^-4 part of the 12-6-4 Lennard-Jones potential as well as any modified off-diagonal (i.e., NBFIX) terms

Parameters
nonbondedMethodcutoff method

This is the cutoff method. It can be either the NoCutoff, CutoffNonPeriodic, CutoffPeriodic, PME, or Ewald objects from the simtk.openmm.app namespace

nonbondedCutofffloat or distance Quantity

The nonbonded cutoff must be either a floating point number (interpreted as nanometers) or a Quantity with attached units. This is ignored if nonbondedMethod is NoCutoff.

switchDistancefloat or distance Quantity

The distance at which the switching function is turned on for van der Waals interactions. This is ignored when no cutoff is used, and no switch is used if switchDistance is 0, negative, or greater than the cutoff

ewaldErrorTolerancefloat=0.0005

When using PME or Ewald, the Ewald parameters will be calculated from this value

reactionFieldDielectricfloat=78.5

If the nonbondedMethod is CutoffPeriodic or CutoffNonPeriodic, the region beyond the cutoff is treated using a reaction field method with this dielectric constant. It should be set to 1 if another implicit solvent model is being used (e.g., GB)

Returns
NonbondedForce [, CustomNonbondedForce]

If a CustomNonbondedForce is necessary, the return value is a 2-element tuple of NonbondedForce, CustomNonbondedForce. If only a NonbondedForce is necessary, that is the return value

ptr(pointer)[source]

Returns the value of the given pointer, and converts to upper-case so it’s case-insensitive. A non-existent pointer meets with a KeyError

Parameters
pointerstr

The AMBER pointer for which to extract the value

Returns
int

The returned integer is the value of that pointer

recalculate_LJ()[source]

Fills the LENNARD_JONES_ACOEF and LENNARD_JONES_BCOEF arrays in the parm_data raw data dictionary by applying the canonical Lorentz-Berthelot combining rules to the values in LJ_radius and LJ_depth.

Notes

This will undo any off-diagonal L-J modifications you may have made, so call this function with care.

rediscover_molecules(solute_ions=True, fix_broken=True)[source]

This determines the molecularity and sets the ATOMS_PER_MOLECULE and SOLVENT_POINTERS sections of the prmtops. Returns the new atom sequence in terms of the ‘old’ atom indexes if re-ordering was necessary to fix the tleap bug. Returns None otherwise.

remake_parm()[source]

Fills parm_data from the data in the parameter and topology arrays (e.g., atoms, bonds, bond_types, …)

strip(selection)[source]

Deletes a subset of the atoms corresponding to an atom-based selection.

Parameters
selectionAmberMask, str, or iterable of bool

This is the selection of atoms that will be deleted from this structure. If it is a string, it will be interpreted as an AmberMask. If it is an AmberMask, it will be converted to a selection of atoms. If it is an iterable, it must be the same length as the atoms list.

write_parm(name)[source]

Writes the current data in parm_data into a new topology file with a given name.

Parameters
namestr or file-like

The name of the file to write the prmtop to or the file object to write to

write_rst7(name, netcdf=None)[source]

Writes a restart file with the current coordinates and velocities and box info if it’s present

Parameters
namestr

Name of the file to write the restart file to

netcdfbool=False

If True, write a NetCDF-format restart file (requires a NetCDF backend; scipy, netCDF4, or ScientificPython; to be installed)

Notes

If netcdf is not specified and the filename extension given by name is .ncrst, the a NetCDF restart file will be written. However, an explicit value for netcdf will override any filename extensions.

class parmed.amber.readparm.ChamberParm(prm_name=None, xyz=None, box=None, rst7_name=None)[source]

Bases: parmed.amber._amberparm.AmberParm

Chamber Topology (parm7 format) class.

Gives low, and some high, level access to topology data or interact with some of the high-level classes comprising the system topology and parameters. The ChamberParm class uses the same attributes that the AmberParm class uses, and only the ones unique to ChamberParm will be shown below.

Parameters
prm_namestr, optional

If provided, this file is parsed and the data structures will be loaded from the data in this file

xyzstr or array, optional

If provided, the coordinates and unit cell dimensions from the provided Amber inpcrd/restart file will be loaded into the molecule, or the coordinates will be loaded from the coordinate array

boxarray, optional

If provided, the unit cell information will be set from the provided unit cell dimensions (a, b, c, alpha, beta, and gamma, respectively)

See also

AmberParm
Attributes
LJ_14_radiuslist(float)

The same as LJ_radius, except specific for 1-4 nonbonded parameters, which may differ in the CHARMM force field

LJ_14_depthlist(float)

The same as LJ_depth, except specific for 1-4 nonbonded parameters, which may differ in the CHARMM force field

urey_bradleysTrackedList(UreyBradley)

List of Urey-Bradley terms between two atoms in a valence angle

impropersTrackedList(Improper)

List of CHARMM-style improper torsions

cmapsTrackedList(Cmap)

List of coupled-torsion correction map parameters

urey_bradley_typesTrackedList(UreyBradleyType)

List of parameters defining the Urey-Bradley terms

improper_typesTrackedList(Improper)

List of parameters defining the Improper terms

cmap_typesTrackedList(CmapType)

List of parameters defining the CMAP terms

chamberbool=True

Whether this instance uses the CHARMM force field

amoebabool=False

Whether this instance uses the Amoeba force field

has_cmapbool

Whether this instance has correction map terms or not

Methods

add_atom(atom, resname, resnum[, chain, …])

Adds a new atom to the Structure, adding a new residue to residues if it has a different name or number as the last residue added and adding it to the atoms list.

add_atom_to_residue(atom, residue)

Adds a new atom to the Structure at the end if the given residue

add_flag(flag_name, flag_format[, data, …])

Adds a new flag with the given flag name and Fortran format string and initializes the array with the values given, or as an array of 0s of length num_items

assign_bonds(*reslibs)

Assigns bonds to all atoms based on the provided residue template libraries.

copy(cls[, split_dihedrals])

Makes a copy of the current structure as an instance of a specified subclass

createSystem([nonbondedMethod, …])

Construct an OpenMM System representing the topology described by the prmtop file.

delete_flag(flag_name)

Removes a flag from the topology file

fill_LJ()

Fills the LJ_radius, LJ_depth arrays and LJ_types dictionary with data from LENNARD_JONES_ACOEF and LENNARD_JONES_BCOEF sections of the prmtop files, by undoing the canonical combining rules.

from_rawdata(rawdata)

Take the raw data from a AmberFormat object and initialize an AmberParm from that data.

from_structure(struct[, copy])

Take a Structure instance and initialize a ChamberParm instance from that data.

get_box([frame])

In some cases, multiple conformations may be stored in the Structure.

get_coordinates([frame])

In some cases, multiple conformations may be stored in the Structure.

has_1012()

This routine determines whether there are any defined 10-12 Lennard-Jones interactions that are non-zero

has_NBFIX()

This routine determines whether there are any off-diagonal Lennard-Jones modifications (i.e., if any two atoms have a L-J pair interaction that does not match the combined L-J parameters for that pair).

id_format(filename)

Identifies the file type as either Amber-format file (like prmtop) or an old-style topology file.

initialize_topology([xyz, box])

Initializes topology data structures, like the list of atoms, bonds, etc., after the topology file has been read.

is_changed()

Determines if any of the topological arrays have changed since the last upload

join_dihedrals()

Joins multi-term torsions into a single term and makes all of the parameters DihedralTypeList instances.

load_atom_info()

Loads atom properties into the atoms that have been loaded.

load_dataframe(df)

Loads atomic properties from an input DataFrame

load_pointers()

Loads the data in POINTERS section into a pointers dictionary with each key being the pointer name according to http://ambermd.org/formats.html

load_rst7(rst7)

Loads coordinates into the AmberParm class

load_structure()

Loads all of the topology instance variables.

omm_add_constraints(system, constraints, …)

Adds constraints to a given system

omm_angle_force([constraints, …])

Creates an OpenMM HarmonicAngleForce object (or AmoebaAngleForce if the angles are for an Amoeba-parametrized system)

omm_bond_force([constraints, rigidWater, …])

Creates an OpenMM Bond Force object (or AmoebaBondForce if the bonds are for an Amoeba-parametrized system)

omm_cmap_force()

Creates the OpenMM CMAP torsion force

omm_dihedral_force([split])

Creates the OpenMM PeriodicTorsionForce modeling dihedrals

omm_gbsa_force(implicitSolvent[, …])

Creates a Generalized Born force for running implicit solvent calculations

omm_improper_force()

Creates the OpenMM improper torsion force (quadratic bias)

omm_nonbonded_force([nonbondedMethod, …])

Creates the OpenMM NonbondedForce (and CustomNonbondedForce if necessary) to define the nonbonded interatomic potential for this system.

omm_out_of_plane_bend_force()

Creates the Amoeba out-of-plane bend force

omm_pi_torsion_force()

Creates the Amoeba pi-torsion force

omm_rb_torsion_force()

Creates the OpenMM RBTorsionForce for Ryckaert-Bellemans torsions

omm_set_virtual_sites(system)

Sets the virtual sites in a given OpenMM System object from the extra points defined in this system

omm_stretch_bend_force()

Create the OpenMM Amoeba stretch-bend force for this system

omm_torsion_torsion_force()

Create the OpenMM Amoeba coupled-torsion (CMAP) force

omm_trigonal_angle_force()

Creates the Amoeba trigonal-angle force

omm_urey_bradley_force()

Creates the OpenMM Urey-Bradley force

parse(filename, *args, **kwargs)

Meant for use with the automatic file loader, this will automatically return a subclass of AmberFormat corresponding to what the information in the prmtop file contains (i.e., either an AmberParm, ChamberParm, AmoebaParm, or AmberFormat)

prune_empty_terms()

Looks through all of the topological lists and gets rid of terms in which at least one of the atoms is None or has an idx attribute set to -1 (indicating that it has been removed from the atoms atom list)

ptr(pointer)

Returns the value of the given pointer, and converts to upper-case so it’s case-insensitive.

rdparm(fname[, slow])

Parses the Amber format file

rdparm_old(prmtop_lines[, check])

This reads an old-style topology file and stores the results in the same data structures as a new-style topology file

rdparm_slow(fname)

Parses the Amber format file.

recalculate_LJ()

Takes the values of the LJ_radius and LJ_depth arrays and recalculates the LENNARD_JONES_A/BCOEF topology sections from the canonical combining rules.

rediscover_molecules([solute_ions, fix_broken])

This determines the molecularity and sets the ATOMS_PER_MOLECULE and SOLVENT_POINTERS sections of the prmtops.

remake_parm()

Fills parm_data from the data in the parameter and topology arrays (e.g., atoms, bonds, bond_types, …)

save(fname[, format, overwrite])

Saves the current Structure in the requested file format.

set_version()

Sets the version string

split()

Split the current Structure into separate Structure instances for each unique molecule.

strip(selection)

Deletes a subset of the atoms corresponding to an atom-based selection.

to_dataframe()

Generates a DataFrame from the current Structure’s atomic properties

unchange()

Toggles all lists so that they do not indicate any changes

update_dihedral_exclusions()

Nonbonded exclusions and exceptions have the following priority:

view_as(cls)

Returns a view of the current object as another object.

visualize(*args, **kwargs)

Use nglview for visualization.

write_cif(dest[, renumber, coordinates, …])

Write a PDB file from the current Structure instance

write_parm(name)

Writes the current data in parm_data into a new topology file with a given name.

write_pdb(dest[, renumber, coordinates, …])

Write a PDB file from a Structure instance

write_psf(dest[, vmd])

Writes a PSF file from the stored molecule

write_rst7(name[, netcdf])

Writes a restart file with the current coordinates and velocities and box info if it’s present

property amoeba

Whether this instance uses the Amoeba force field

property chamber

Whether this instance uses the CHARMM force field

fill_LJ()[source]

Fills the LJ_radius, LJ_depth arrays and LJ_types dictionary with data from LENNARD_JONES_ACOEF and LENNARD_JONES_BCOEF sections of the prmtop files, by undoing the canonical combining rules.

classmethod from_structure(struct, copy=False)[source]

Take a Structure instance and initialize a ChamberParm instance from that data.

Parameters
structStructure

The input structure from which to construct a ChamberParm instance

copybool

If True, the input struct is deep-copied to make sure it does not share any objects with the original struct. Default is False

Returns
instChamberParm

The ChamberParm instance derived from the input structure

Notes

Due to the nature of the prmtop file, struct almost always returns a deep copy. The one exception is when struct is already of type ChamberParm, in which case the original object is returned unless copy is True.

initialize_topology(xyz=None, box=None)[source]

Initializes topology data structures, like the list of atoms, bonds, etc., after the topology file has been read. The following methods are called:

load_pointers()[source]

Loads the data in POINTERS section into a pointers dictionary with each key being the pointer name according to http://ambermd.org/formats.html

load_structure()[source]

Loads all of the topology instance variables. This is necessary if we actually want to modify the topological layout of our system (like deleting atoms)

recalculate_LJ()[source]

Takes the values of the LJ_radius and LJ_depth arrays and recalculates the LENNARD_JONES_A/BCOEF topology sections from the canonical combining rules.

remake_parm()[source]

Fills parm_data from the data in the parameter and topology arrays (e.g., atoms, bonds, bond_types, …)

parmed.amber.readparm.LoadParm(parmname, xyz=None, box=None)[source]

Loads a topology file using the correct class.

Parameters
parmnamestr

The name of the topology file to load

xyzstr or array, optional

If provided, the coordinates and unit cell dimensions from the provided Amber inpcrd/restart file will be loaded into the molecule, or the coordinates will be loaded from the coordinate array

boxarray, optional

If provided, the unit cell information will be set from the provided unit cell dimensions (a, b, c, alpha, beta, and gamma, respectively)

Returns
parmAmberParm (or subclass)

This function parses the topology file, determines if it is an Amber-style (i.e., traditional Amber force field), Chamber-style (i.e., CHARMM force field), or Amoeba-style (i.e., Amoeba force field), and then returns an instance of the appropriate type.

class parmed.amber.readparm.Rst7(filename=None, natom=None, title='', time=0.0)[source]

Bases: object

Amber input coordinate (or restart coordinate) file. Front-end for the readers and writers, supports both NetCDF and ASCII restarts.

Parameters
filenamestr, optional

If a filename is provided, this file is parsed and the Rst7 data populated from that file. The format (ASCII or NetCDF) is autodetected

natomint, optional

If no filename is provided, this value is required. If a filename is provided, this value is ignored (and instead set to the value of natom from the coordinate file). This is the number of atoms for which we have coordinates. If not provided for a new file, it must be set later.

titlestr, optional

For a file that is to be written, this is the title that will be given to that file. Default is an empty string

timefloat, optional

The time to write to the restart file. This is cosmetic. Default is 0

Attributes
box
box_vectors

Unit cell vectors with units

hasbox

Whether or not this Rst7 has unit cell information

hasvels

Whether or not this Rst7 has velocities

positions

Atomic coordinates with units

velocities

Atomic velocities in units of angstroms/picoseconds

Methods

copy_from(thing)

Copies the coordinates, velocities, and box information from another instance

open(filename)

Constructor that opens and parses an input coordinate file

write(fname[, netcdf])

Writes the coordinates and/or velocities to a restart file

property box
property box_vectors

Unit cell vectors with units

classmethod copy_from(thing)[source]

Copies the coordinates, velocities, and box information from another instance

property hasbox

Whether or not this Rst7 has unit cell information

property hasvels

Whether or not this Rst7 has velocities

classmethod open(filename)[source]

Constructor that opens and parses an input coordinate file

Parameters
filenamestr

Name of the file to parse

property positions

Atomic coordinates with units

property velocities

Atomic velocities in units of angstroms/picoseconds

write(fname, netcdf=False)[source]

Writes the coordinates and/or velocities to a restart file