parmed.amber package¶
Subpackages¶
Submodules¶
Module contents¶
Package that provides an API to Amber-specific files
-
class
parmed.amber.
AmberAsciiRestart
(fname, mode='r', natom=0, hasbox=None, title=None, time=0.0)[source]¶ Bases:
parmed.amber.asciicrd._AmberAsciiCoordinateFile
Parser for the Amber ASCII inpcrd/restart file format
- Parameters
- fnamestr
File name to open
- modestr={‘r’, ‘w’}
Whether to open this file for ‘r’eading or ‘w’riting
- natomint, optional
Number of atoms in the system (necessary when mode=’w’)
- hasboxbool, optional
Does the system have PBCs? Necessary when mode=’w’
- titlestr, optional
Title to write to a new trajectory (when mode=’w’)
- timefloat, optional
The time to write to the restart file in ps. Default is 0.
- Attributes
box
Combined cell lengths and cell angles
- cell_angles
- cell_lengths
- coordinates
- positions
- velocities
Methods
close
()Close the open file handler
id_format
(filename)Identifies the file type as an Amber restart/inpcrd file
parse
-
CRDS_PER_LINE
= 6¶
-
DEFAULT_TITLE
= 'restart created by ParmEd'¶
-
property
box
¶ Combined cell lengths and cell angles
-
property
cell_angles
¶
-
property
cell_lengths
¶
-
property
coordinates
¶
-
static
id_format
(filename)[source]¶ Identifies the file type as an Amber restart/inpcrd file
- Parameters
- filenamestr
Name of the file to check format for
- Returns
- is_fmtbool
True if it is an Amber restart/inpcrd file. False otherwise
-
property
velocities
¶
-
class
parmed.amber.
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.
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
-
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_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
-
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
-
class
parmed.amber.
AmberMask
(parm, mask)[source]¶ Bases:
object
What is hopefully a fully-fledged Amber mask parser implemented in Python.
- Parameters
- parmStructure
The topology structure for which to select atoms
- maskstr
The mask string that selects a subset of atoms
Methods
Selected
([invert])Generator that returns the indexes of selected atoms
Selection
([prnlev, invert])Parses the mask and analyzes the result to return an atom selection array
-
Selected
(invert=False)[source]¶ Generator that returns the indexes of selected atoms
- Parameters
- invertbool, optional
If True, all atoms not selected by the mask will be returned
- Returns
- generator of int
Each iteration will yield the index of the next atom that has been selected by the mask. Atom indices are 0-based
-
Selection
(prnlev=0, invert=False)[source]¶ Parses the mask and analyzes the result to return an atom selection array
- Parameters
- prnlevint, optional
Print debug information on the processing of the Amber mask string. This is mainly useful if you are modifying the mask parser. Default value is 0 (no printout), values between 1 and 8 control the level of output (larger values produce more output). Default 0
- invertbool, optional
If True, the returned array will invert the selection of the mask (i.e., selected atoms will not be selected and vice-versa)
- Returns
- masklist of int
A list with length equal to the number of atoms in the assigned
Structure
instance. Selected atoms will have a value of 1 placed in the corresponding slot in the return list while atoms not selected will be assigned 0.
-
class
parmed.amber.
AmberMdcrd
(fname, natom, hasbox, mode='r', title=None)[source]¶ Bases:
parmed.amber.asciicrd._AmberAsciiCoordinateFile
A class to parse Amber ASCII trajectory files. This is much slower than parsing NetCDF files (or the equivalent parsing done in a compiled language like C or C++). For large trajectories, this may be significant.
- Attributes
- box
- coordinates
- frame
- positions
Methods
add_box
(stuff)Prints ‘stuff’ (which must be a 3-element list, array.array, tuple, or np.ndarray) as the box lengths for this frame
add_coordinates
(stuff)Prints ‘stuff’ (which must be either an iterable of 3*natom or have an attribute ‘flatten’ that converts it into an iterable of 3*natom) to the open file handler.
close
()Close the open file handler
id_format
(filename)Identifies the file type as an Amber mdcrd file
-
CRDS_PER_LINE
= 10¶
-
DEFAULT_TITLE
= 'trajectory created by ParmEd'¶
-
add_box
(stuff)[source]¶ Prints ‘stuff’ (which must be a 3-element list, array.array, tuple, or np.ndarray) as the box lengths for this frame
- Parameters
- stuffarray or iterable
This must be an iterable of length 3 with the box lengths
- Raises
- If the coordinate file is an old one being parsed or if you are
- currently expected to provide coordinates, a RuntimeError is raised.
- raised. If the provided box lengths are not length 3, a ValueError is
- raised.
-
add_coordinates
(stuff)[source]¶ Prints ‘stuff’ (which must be either an iterable of 3*natom or have an attribute ‘flatten’ that converts it into an iterable of 3*natom) to the open file handler. Can only be called on a ‘new’ mdcrd, and adds these coordinates to the current end of the file.
- Parameters
- stuffarray or iterable
This must be an iterable of length 3*natom or a numpy array that can be flattened to a 3*natom-length array
- Raises
- If the coordinate file is an old one being parsed or if you are
- currently expected to provide unit cell dimensions, a RuntimeError is
- raised. If the provided coordinate data does not have length 3*natom, or
- cannot be ``flatten()``ed to create a 3*natom array, a ValueError is
- raised.
-
property
box
¶
-
property
coordinates
¶
-
extra_args
= ('natom', 'hasbox')¶
-
property
frame
¶
-
class
parmed.amber.
AmberOFFLibrary
[source]¶ Bases:
object
Class containing static methods responsible for parsing and writing OFF libraries
Methods
id_format
(filename)Sees if an open file is an OFF library file.
parse
(filename)Parses an Amber OFF library
write
(lib, dest)Writes a dictionary of ResidueTemplate units to a file in OFF format
-
static
id_format
(filename)[source]¶ Sees if an open file is an OFF library file.
- Parameters
- filenamestr
The name of the file to see if it is an OFF file format
- Returns
- is_fmtbool
True if it is recognized as OFF, False otherwise
-
static
parse
(filename)[source]¶ Parses an Amber OFF library
- Parameters
- filenamestr or file-like iterable
The file name or file object to parse. If it is an iterable, it will be exhausted
- Returns
- residuesOrderedDict {str
Dictionary pairing residue names with their
ResidueTemplate
objects
- Raises
- ValueError if the first line does not match the file format. This line
- will be consumed
- IOError if filename is the name of a file that does not exist
- RuntimeError if EOF is reached prematurely or other formatting issues
- found
-
static
-
class
parmed.amber.
AmberParameterSet
(*filenames)[source]¶ Bases:
parmed.parameters.ParameterSet
Class storing parameters from an Amber parameter set
- Parameters
- filenamesstr, list of str, file-like, or list of file-like; optional
Either the name of a file or a list of filenames from which parameters should be parsed.
See also
Notes
Order is important in the list of files provided. The parameters are loaded in the order they are provided, and any parameters that are specified in multiple places are overwritten (that is, the last occurrence is the parameter type that is used)
- Attributes
- combining_rule
Methods
condense
([do_dihedrals])This function goes through each of the parameter type dicts and eliminates duplicate types.
from_leaprc
(fname[, search_oldff])Load a parameter set from a leaprc file
from_structure
(struct)Extracts known parameters from a Structure instance
id_format
(filename)Identifies the file type as either an Amber-style frcmod or parm.dat file.
load_parameters
(fname)Load a set of parameters from a single parameter file
typeify_templates
()Assign atom types to atom names in templates
write
(dest[, title, style])Writes a parm.dat file with the current parameters
-
classmethod
from_leaprc
(fname, search_oldff=False)[source]¶ Load a parameter set from a leaprc file
- Parameters
- fnamestr or file-like
Name of the file or open file-object from which a leaprc-style file will be read
- search_oldffbool, optional, default=False
If True, search the oldff directories in the main Amber leap folders. Default is False
Notes
This does not read all parts of a leaprc file – only those pertinent to defining force field information. For instance, the following sections and commands are processed:
addAtomTypes
loadAmberParams
loadOFF
loadMol2
loadMol3
-
classmethod
from_structure
(struct)[source]¶ Extracts known parameters from a Structure instance
- Parameters
- struct
parmed.structure.Structure
The parametrized
Structure
instance from which to extract parameters into a ParameterSet
- struct
- Returns
- params
ParameterSet
The parameter set with all parameters defined in the Structure
- params
-
static
id_format
(filename)[source]¶ Identifies the file type as either an Amber-style frcmod or parm.dat file.
- Parameters
- filenamestr
Name of the file to check format for
- Returns
- is_fmtbool
True if it is an Amber-style parameter file. False otherwise.
-
load_parameters
(fname)[source]¶ Load a set of parameters from a single parameter file
- Parameters
- fnamestr or file-like
Parameter file to parse
-
write
(dest, title='Created by ParmEd', style='frcmod')[source]¶ Writes a parm.dat file with the current parameters
- Parameters
- deststr or file-like
The file name or file-like object to write the parameters to
- titlestr, optional
The title of the frcmod to write. Default is ‘Created by ParmEd’
- stylestr, optional
If ‘frcmod’, the parameters are written in frcmod-format. If ‘parm’, the parameters are written in parm.dat-format. Default is ‘frcmod’
-
class
parmed.amber.
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_h
iterator(Bond)All bonds including hydrogen
bonds_without_h
iterator(Bond)All bonds without hydrogen
angles_inc_h
iterator(Angle)All angles including hydrogen
angles_without_h
iterator(Angle)All angles including hydrogen
dihedrals_inc_h
iterator(Dihedral)All dihedrals including hydrogen
dihedrals_without_h
iterator(Dihedral)All dihedrals including hydrogen
chamber
bool=FalseWhether this instance uses the CHARMM force field
amoeba
bool=FalseWhether this instance uses the Amoeba force field
has_cmap
bool=FalseWhether 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
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.
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.
Loads atom properties into the atoms that have been loaded.
load_dataframe
(df)Loads atomic properties from an input DataFrame
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
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.
Fills the
LENNARD_JONES_ACOEF
andLENNARD_JONES_BCOEF
arrays in theparm_data
raw data dictionary by applying the canonical Lorentz-Berthelot combining rules to the values inLJ_radius
andLJ_depth
.rediscover_molecules
([solute_ions, fix_broken])This determines the molecularity and sets the ATOMS_PER_MOLECULE and SOLVENT_POINTERS sections of the prmtops.
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
, andLJ_types
data structures.
-
classmethod
from_rawdata
(rawdata)[source]¶ Take the raw data from a AmberFormat object and initialize an AmberParm from that data.
- Parameters
- rawdata
AmberFormat
An AmberFormat instance that has already been instantiated
- rawdata
- Returns
- parm
AmberParm
An instance of this type from the data in rawdata
- parm
-
classmethod
from_structure
(struct, copy=False)[source]¶ Take a Structure instance and initialize an AmberParm instance from that data.
- Parameters
- struct
Structure
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
- struct
- Returns
- inst
AmberParm
The AmberParm instance derived from the input structure
- inst
- 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 unlesscopy
isTrue
.
-
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.
- rst7str or
-
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
andLENNARD_JONES_BCOEF
arrays in theparm_data
raw data dictionary by applying the canonical Lorentz-Berthelot combining rules to the values inLJ_radius
andLJ_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.
AmoebaParm
(prm_name=None, xyz=None, box=None, rst7_name=None)[source]¶ Bases:
parmed.amber._amberparm.AmberParm
Tinker Topology (parm7 format) class defining the AMOEBA force field. 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=None
If provided, this file is parsed and the data structures will be loaded from the data in this file
- rst7_namestr=None
If provided, the coordinates and unit cell dimensions from the provided Amber inpcrd/restart file will be loaded into the molecule
- 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
- versionstr
The VERSION string from the Amber file
- namestr
The file name of the originally parsed file (set to the fname parameter)
- 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 regular angles between three atoms in the system
- dihedralsTrackedList(Angle)
List of all proper torsions between 4 atoms in the system
- urey_bradleysTrackedList(UreyBradley)
List of all Urey-Bradley terms between 2 atoms connected by an angle
- trigonal_anglesTrackedList(TrigonalAngle)
List of all trigonal angle terms
- out_of_plane_bendsTrackedList(OutOfPlaneBend)
List of all out-of-plane bending terms
- pi_torsionsTrackedList(PiTorsion)
List of all pi-torsion terms
- stretch_bendsTrackedList(StretchBend)
List of all stretch-bending terms
- torsion_torsionsTrackedList(TorsionTorsion)
List of all coupled torsion-torsion terms
- chiral_framesTrackedList(ChiralFrame)
List of all chiral centers
- multipole_framesTrackedList(MultipoleFrame)
List of all multipole frames of reference
- adjustsTrackedList(NonbondedException)
List of all nonbonded exception parameters used for adjusting nonbonded interactions between particular pairs of atoms
- 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
- urey_bradley_typesTrackedList(BondType)
The Urey-Bradley types containing the parameters for each term
- trigonal_angle_typesTrackedList(AngleType)
The trigonal angle types containing the parameters for each term
- out_of_plane_bend_typesTrackedList(AngleType)
The out-of-plane bending angle type containing parameters for each term
- pi_torsion_typesTrackedList(DihedralType)
The pi-torsion type containing parameters for each torsional term
- stretch_bend_typesTrackedList(StretchBendType)
The stretch-bend type containing parameters for each term
- torsion_torsion_typesTrackedList(TorsionTorsionType)
The coupled torsion-torsion type containing parameters for coupled torsions
- adjust_typesTrackedList(NonbondedExceptionType)
The nonbonded exception scaling factors for pairs of particles
bonds_inc_h
iterator(Bond)All bonds including hydrogen
bonds_without_h
iterator(Bond)All bonds without hydrogen
angles_inc_h
iterator(Angle)All angles including hydrogen
angles_without_h
iterator(Angle)All angles including hydrogen
dihedrals_inc_h
iterator(Dihedral)All dihedrals including hydrogen
dihedrals_without_h
iterator(Dihedral)All dihedrals including hydrogen
chamber
bool=FalseWhether this instance uses the CHARMM force field
amoeba
bool=FalseWhether this instance uses the Amoeba force field
has_cmap
bool=FalseWhether 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.
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
Loads all of the topology instance variables.
Returns the skeleton of an mdin file with the &amoeba namelist set up correctly for the potential terms that are present in this topology file.
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
andLENNARD_JONES_BCOEF
arrays in theparm_data
raw data dictionary by applying the canonical Lorentz-Berthelot combining rules to the values inLJ_radius
andLJ_depth
.rediscover_molecules
([solute_ions, fix_broken])This determines the molecularity and sets the ATOMS_PER_MOLECULE and SOLVENT_POINTERS sections of the prmtops.
Recomputes the topology file parameters and fills parm_data
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
-
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.
- Raises
- AmberError if it is not an Amoeba-styled topology file
-
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_structure
()[source]¶ Loads all of the topology instance variables. This is necessary if we actually want to modify the topological layout of our system
-
mdin_skeleton
()[source]¶ Returns the skeleton of an mdin file with the &amoeba namelist set up correctly for the potential terms that are present in this topology file.
- Returns
- str
A skeleton MDIN file with all of the do_* variables in the &amoeba section set correctly. It is commented for easy editing
-
class
parmed.amber.
BeemanRestart
(fname=None)[source]¶ Bases:
parmed.amber.amberformat.AmberFormat
The restart files written for/by the Beeman integrator has the same type of format as the topology file
- Attributes
- accelerations
- box
- coordinates
- natom
- old_accelerations
- velocities
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
from_rawdata
(rawdata)Take the raw data from a AmberFormat object and initialize a BeemanRestart from that data.
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
-
property
accelerations
¶
-
property
box
¶
-
property
coordinates
¶
-
classmethod
from_rawdata
(rawdata)[source]¶ Take the raw data from a AmberFormat object and initialize a BeemanRestart from that data.
- Parameters
- rawdata
AmberFormat
An AmberFormat instance that has already been instantiated
- rawdata
- Returns
- inst
BeemanRestart
An instance of this type from the data in rawdata
- inst
-
property
natom
¶
-
property
old_accelerations
¶
-
property
velocities
¶
-
class
parmed.amber.
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
- 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
chamber
bool=TrueWhether this instance uses the CHARMM force field
amoeba
bool=FalseWhether this instance uses the Amoeba force field
has_cmap
boolWhether 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
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
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.
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.
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
- inst
ChamberParm
The ChamberParm instance derived from the input structure
- inst
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 unlesscopy
isTrue
.
-
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)
-
parmed.amber.
ConvertFromPSF
(struct, params, title='')[source]¶ This function instantiates a ChamberParm instance from a data structure instantiated by a CHARMM PSF.
- Parameters
- structStructure
The structure object (typically loaded from a PSF file)
- paramsCharmmParameterSet
The parameter set describing the parameters of the input struct
- titlestr=’’
The title to assign to the topology file
- Returns
- ChamberParm
ChamberParm instance with all parameters loaded
-
class
parmed.amber.
FortranFormat
(format_string, strip_strings=True)[source]¶ Bases:
object
Processes Fortran format strings according to the Fortran specification for such formats. This object handles reading and writing data with any valid Fortran format. It does this by using the fortranformat project [https://bitbucket.org/brendanarnold/py-fortranformat].
However, while fortranformat is very general and adheres well to the standard, it is very slow. As a result, simple, common format strings have been optimized and processes reads and writes between 3 and 5 times faster. The format strings (case-insensitive) of the following form (where # can be replaced by any number) are optimized:
#E#.#
#D#.#
#F#.#
#(F#.#)
#a#
#I#
- Parameters
- format_stringstr
The Fortran Format string to process
- strip_stringsbool=True
If True, strings are stripped before being processed by stripping (only) trailing whitespace
Methods
read
(line)Reads the line and returns the converted data
write
(items, dest)Writes an iterable of data (or a single item) to the passed file-like object
-
floatre
= re.compile('(\\d+)?[edf](\\d+)\\.(\\d+)$', re.IGNORECASE)¶
-
floatre2
= re.compile('(\\d+)?\\([edf](\\d+)\\.(\\d+)\\)$', re.IGNORECASE)¶
-
intre
= re.compile('(\\d+)?i(\\d+)$', re.IGNORECASE)¶
-
strre
= re.compile('(\\d+)?a(\\d+)$', re.IGNORECASE)¶
-
write
(items, dest)[source]¶ Writes an iterable of data (or a single item) to the passed file-like object
- Parameters
- itemsiterable or single float/str/int
These are the objects to write in this format. The types of each item should match the type specified in this Format for that argument
- destfile or file-like
This is the file to write the data to. It must have a write method or an AttributeError will be raised
Notes
This method may be replaced with _write_string (for #a#-style formats) or _write_ffwriter in the class initializer if no optimization is provided for this format, but the call signatures and behavior are the same for each of those functions.
-
parmed.amber.
LoadParm
(parmname, xyz=None, box=None)[source]¶ Loads a topology file using the correct class.
- Parameters
- parmname
str
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)
- parmname
- Returns
- parm
AmberParm
(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.
- parm
-
class
parmed.amber.
NetCDFRestart
(fname, mode='r')[source]¶ Bases:
object
Class to read or write NetCDF restart files
- Attributes
- box
- cell_angles
- cell_lengths
- coordinates
- remd_dimtype
- remd_indices
- temp0
- time
- velocities
Methods
id_format
(filename)Identifies the file type as an Amber NetCDF restart file
open_new
(fname, natom, box, vels[, title, …])Opens a new NetCDF file and sets the attributes
open_old
(fname)Opens the NetCDF file and sets the global attributes that the file sets
parse
(fname)Opens the NetCDF file and sets the global attributes that the file sets
close
flush
-
property
box
¶
-
property
cell_angles
¶
-
property
cell_lengths
¶
-
property
coordinates
¶
-
static
id_format
(filename)[source]¶ Identifies the file type as an Amber NetCDF restart file
- Parameters
- filenamestr
Name of the file to check format for
- Returns
- is_fmtbool
True if it is an Amber NetCDF restart file. False otherwise
Notes
Remote NetCDF files cannot be loaded
-
classmethod
open_new
(fname, natom, box, vels, title='', remd=None, temp=None, remd_dimtypes=None)[source]¶ Opens a new NetCDF file and sets the attributes
- Parameters
- fnamestr
Name of the new file to open (overwritten)
- natomint
The number of atoms in the system
- boxbool
Whether unit cell information is written or not
- velsbool
Whether velocity information is written or not
- titlestr=’’
The title to write to the NetCDF restart file
- remdstr=None
None – No REMD information is written ‘T[emperature]’ – target temperature (or pH) will be written ‘M[ulti-D]’ – remd_dimtypes will be written
- remd_dimtypesiterable of int=None
Array of exchange types for each group. The length will be the REMD dimension (if remd above is “M[ulti-D]”)
Notes
remd is case-insensitive, and done based on first-letter matching
-
classmethod
open_old
(fname)[source]¶ Opens the NetCDF file and sets the global attributes that the file sets
- Parameters
- fnamestr
Name of the file to read
-
classmethod
parse
(fname)¶ Opens the NetCDF file and sets the global attributes that the file sets
- Parameters
- fnamestr
Name of the file to read
-
property
remd_dimtype
¶
-
property
remd_indices
¶
-
property
temp0
¶
-
property
time
¶
-
property
velocities
¶
-
class
parmed.amber.
NetCDFTraj
(fname, mode='r')[source]¶ Bases:
object
Class to read or write NetCDF restart files
- Parameters
- fnamestr
Name of the file to open
- modestr
- Mode to open in:
‘w’ means write-mode
‘r’ means read-mode
Notes
You should use the open_new and open_old alternative constructors instead of the default constructor
- Attributes
- box
- cell_lengths_angles
- coordinates
- forces
- remd_dimtype
- remd_indices
- temp0
- time
- velocities
Methods
add_box
(lengths[, angles])Adds a new cell length and angle frame to the end of a NetCDF trajectory.
add_cell_lengths_angles
(lengths[, angles])Adds a new cell length and angle frame to the end of a NetCDF trajectory.
add_coordinates
(stuff)Adds a new coordinate frame to the end of a NetCDF trajectory.
add_forces
(stuff)Adds a new coordinate frame to the end of a NetCDF trajectory.
add_remd_indices
(stuff)Add REMD indices to the current frame of the NetCDF file
add_temp0
(stuff)The temperature to add to the current frame of the NetCDF file
add_time
(stuff)Adds the time to the current frame of the NetCDF file
add_velocities
(stuff)Adds a new velocities frame to the end of a NetCDF trajectory.
close
()Closes the NetCDF file
id_format
(filename)Identifies the file type as an Amber NetCDF trajectory file
open_new
(fname, natom, box[, crds, vels, …])Opens a new NetCDF file and sets the attributes
open_old
(fname)Opens the NetCDF file and sets the global attributes that the file sets
flush
-
add_box
(lengths, angles=None)¶ Adds a new cell length and angle frame to the end of a NetCDF trajectory. This should only be called on objects created with the “open_new” constructor.
- Parameters
- lengthsarray of 3 (or 6) floats (or Quantities)
This should be a 1-D array of 3 or 6 elements. If 6 elements, angles should be None (below) and the first 3 elements are the box lengths (angstroms) and the last 3 are the box angles (degrees).
- angles3-item iterable = None
These are the box angles (if lengths contains only 3 elements) in degrees. Must be a 1-D array of 3 elements or None if lengths includes angles as well.
-
add_cell_lengths_angles
(lengths, angles=None)[source]¶ Adds a new cell length and angle frame to the end of a NetCDF trajectory. This should only be called on objects created with the “open_new” constructor.
- Parameters
- lengthsarray of 3 (or 6) floats (or Quantities)
This should be a 1-D array of 3 or 6 elements. If 6 elements, angles should be None (below) and the first 3 elements are the box lengths (angstroms) and the last 3 are the box angles (degrees).
- angles3-item iterable = None
These are the box angles (if lengths contains only 3 elements) in degrees. Must be a 1-D array of 3 elements or None if lengths includes angles as well.
-
add_coordinates
(stuff)[source]¶ Adds a new coordinate frame to the end of a NetCDF trajectory. This should only be called on objects created with the “open_new” constructor.
- Parameters
- stuffiterable of floats or distance Quantity
This array of floats is converted into a numpy array of shape (natom, 3). It can be passed either in the 2-D format of [ [x1, y1, z1], [x2, y2, z2], … ] or in the 1-D format of [x1, y1, z1, x2, y2, z2, … ].
-
add_forces
(stuff)[source]¶ Adds a new coordinate frame to the end of a NetCDF trajectory. This should only be called on objects created with the “open_new” constructor.
- Parameters
- stuffiterable of floats or energy/distance Quantity
This array of floats is converted into a numpy array of shape (natom, 3). It can be passed either in the 2-D format of [ [x1, y1, z1], [x2, y2, z2], … ] or in the 1-D format of [x1, y1, z1, x2, y2, z2, … ].
-
add_remd_indices
(stuff)[source]¶ Add REMD indices to the current frame of the NetCDF file
- Parameters
- stuffiterable of int
The indices in each REMD dimension
-
add_temp0
(stuff)[source]¶ The temperature to add to the current frame of the NetCDF file
- Parameters
- stufffloat or temperature Quantity
The temperature to add to the current NetCDF file
-
add_time
(stuff)[source]¶ Adds the time to the current frame of the NetCDF file
- Parameters
- stufffloat or time-dimension Quantity
The time to add to the current frame
-
add_velocities
(stuff)[source]¶ Adds a new velocities frame to the end of a NetCDF trajectory. This should only be called on objects created with the “open_new” constructor.
- Parameters
- stuffiterable of floats or distance/time Quantity
This array of floats is converted into a numpy array of shape (natom, 3). It can be passed either in the 2-D format of [ [x1, y1, z1], [x2, y2, z2], … ] or in the 1-D format of [x1, y1, z1, x2, y2, z2, … ].
-
property
box
¶
-
property
cell_lengths_angles
¶
-
property
coordinates
¶
-
property
forces
¶
-
static
id_format
(filename)[source]¶ Identifies the file type as an Amber NetCDF trajectory file
- Parameters
- filenamestr
Name of the file to check format for
- Returns
- is_fmtbool
True if it is an Amber NetCDF trajectory file. False otherwise
Notes
Remote NetCDF files cannot be loaded
-
classmethod
open_new
(fname, natom, box, crds=True, vels=False, frcs=False, remd=None, remd_dimension=None, title='')[source]¶ Opens a new NetCDF file and sets the attributes
- Parameters
- fnamestr
Name of the new file to open (overwritten)
- natomint
Number of atoms in the restart
- boxbool
Indicates if cell lengths and angles are written to the NetCDF file
- crdsbool=True
Indicates if coordinates are written to the NetCDF file
- velsbool=False
Indicates if velocities are written to the NetCDF file
- frcsbool=False
Indicates if forces are written to the NetCDF file
- remdstr=None
‘T[emperature]’ if replica temperature is written ‘M[ulti]’ if Multi-D REMD information is written None if no REMD information is written
- remd_dimensionint=None
If remd above is ‘M[ulti]’, this is how many REMD dimensions exist
- titlestr=’’
The title of the NetCDF trajectory file
-
classmethod
open_old
(fname)[source]¶ Opens the NetCDF file and sets the global attributes that the file sets
- Parameters
- fnamestr
File name of the trajectory to open. It must exist
-
property
remd_dimtype
¶
-
property
remd_indices
¶
-
property
temp0
¶
-
property
time
¶
-
property
velocities
¶
-
class
parmed.amber.
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