parmed.amber.AmberParm

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

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

__init__(prm_name=None, xyz=None, box=None, rst7_name=None)[source]

Instantiates an AmberParm object from data in prm_name and establishes validity based on presence of POINTERS and CHARGE sections. In general, you should use LoadParm from the readparm module instead. LoadParm will correctly dispatch the object to the ‘correct’ flavor of AmberParm

Methods

__init__([prm_name, xyz, box, rst7_name])

Instantiates an AmberParm object from data in prm_name and establishes validity based on presence of POINTERS and CHARGE sections.

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

Attributes

ANGLE_FORCE_GROUP

BOND_FORCE_GROUP

CMAP_FORCE_GROUP

DIHEDRAL_FORCE_GROUP

IMPROPER_FORCE_GROUP

NONBONDED_FORCE_GROUP

OUT_OF_PLANE_BEND_FORCE_GROUP

PI_TORSION_FORCE_GROUP

RB_TORSION_FORCE_GROUP

STRETCH_BEND_FORCE_GROUP

TORSION_TORSION_FORCE_GROUP

TRIGONAL_ANGLE_FORCE_GROUP

UREY_BRADLEY_FORCE_GROUP

amoeba

Whether this instance uses the Amoeba force field

angles_inc_h

All angles including hydrogen

angles_without_h

All angles including hydrogen

bonds_inc_h

All bonds including hydrogen

bonds_without_h

All bonds without hydrogen

box

box_vectors

3, 3-element tuple of unit cell vectors that are Quantity objects of dimension length

chamber

Whether this instance uses the CHARMM force field

combining_rule

coordinates

dihedrals_inc_h

All dihedrals including hydrogen

dihedrals_without_h

All dihedrals including hydrogen

has_cmap

Whether this instance has correction map terms or not

positions

A list of 3-element Quantity tuples of dimension length representing the atomic positions for every atom in the system.

topology

The OpenMM Topology object.

velocities

view

Returns an indexable object that can be indexed like a standard Structure, but returns a view rather than a copy