parmed.gromacs.GromacsTopologyFile

class parmed.gromacs.GromacsTopologyFile(fname=None, defines=None, parametrize=True, xyz=None, box=None)[source]

Class providing a parser and writer for a GROMACS topology file

Parameters
fnamestr

The name of the file to read

defineslist of str=None

If specified, this is the set of defines to use when parsing the topology file

parametrizedbool, optional

If True, parameters are assigned after parsing is done from the parametertypes sections. If False, only parameter types defined in the parameter sections themselves are loaded (i.e., on the same line as the parameter was defined). Default is True

xyzstr or array, optional

The source of atomic coordinates. It can be a string containing the name of a coordinate file from which to fill the coordinates (and optionally the unit cell information), or it can be an array with the coordinates. Default is None

boxarray, optional

If provided, the unit cell information will be set from this variable. If provided, it must be a collection of 6 floats representing the unit cell dimensions a, b, c, alpha, beta, and gamma, respectively. Default is None.

Notes

If the xyz argument is a file name that contains the unit cell information, this unit cell information is set. However, the box argument takes precedence and will override values given in the coordinate file unless it has its default value of None.

Attributes
box
box_vectors

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

combining_rule
coordinates
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

A (natom, 3)-shape numpy array with atomic velocities for every atom in

view

Returns an indexable object that can be indexed like a standard

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

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.

from_structure(struct[, copy])

Instantiates a GromacsTopologyFile instance from a Structure

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_NBFIX()

Returns whether or not any pairs of atom types have their LJ interactions modified by an NBFIX definition

id_format(filename)

Identifies the file as a GROMACS topology file

is_changed()

Determines if any of the topology has changed for this structure

join_dihedrals()

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

load_dataframe(df)

Loads atomic properties from an input DataFrame

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 instance

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

parametrize()

Assign parameters to the current structure.

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)

read(fname[, defines, parametrize])

Reads the topology file into the current instance

save(fname[, format, overwrite])

Saves the current Structure in the requested file format.

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:

visualize(*args, **kwargs)

Use nglview for visualization.

write(dest[, combine, parameters, molfile, itp])

Write a Gromacs Topology File from a Structure

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

Write a PDB file from the current Structure instance

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

__init__(fname=None, defines=None, parametrize=True, xyz=None, box=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([fname, defines, parametrize, xyz, box])

Initialize self.

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

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.

from_structure(struct[, copy])

Instantiates a GromacsTopologyFile instance from a Structure

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_NBFIX()

Returns whether or not any pairs of atom types have their LJ interactions modified by an NBFIX definition

id_format(filename)

Identifies the file as a GROMACS topology file

is_changed()

Determines if any of the topology has changed for this structure

join_dihedrals()

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

load_dataframe(df)

Loads atomic properties from an input DataFrame

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 instance

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

parametrize()

Assign parameters to the current structure.

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)

read(fname[, defines, parametrize])

Reads the topology file into the current instance

save(fname[, format, overwrite])

Saves the current Structure in the requested file format.

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:

visualize(*args, **kwargs)

Use nglview for visualization.

write(dest[, combine, parameters, molfile, itp])

Write a Gromacs Topology File from a Structure

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

Write a PDB file from the current Structure instance

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

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

box

box_vectors

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

combining_rule

coordinates

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