parmed.charmm.psf module

Provides a Python class for parsing a PSF file and setting up a system structure for it

Author: Jason M. Swails Contributors: Date: April 20, 2014

class parmed.charmm.psf.CharmmPsfFile(**kwargs)[source]

Bases: parmed.structure.Structure

A chemical Structure instantiated from CHARMM files.

Parameters
psf_namestr, optional

Name of the PSF file (it must exist)

Raises
IOErrorIf file psf_name does not exist
CharmmPsfErrorIf any parsing errors are encountered
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.

clear_cmap()

Clear the cmap list to prevent any CMAP parameters from being used

copy(cls[, split_dihedrals])

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

createSystem([params])

Creates an OpenMM System object from the CHARMM PSF file.

from_structure(struct[, copy])

Instantiates a CharmmPsfFile from an input Structure instance.

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

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

load_parameters(parmset[, copy_parameters])

Loads parameters from a parameter set that was loaded via CHARMM RTF, PAR, and STR files.

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

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)

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_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

clear_cmap()[source]

Clear the cmap list to prevent any CMAP parameters from being used

createSystem(params=None, *args, **kwargs)[source]

Creates an OpenMM System object from the CHARMM PSF file. This is a shortcut for calling load_parameters followed by Structure.createSystem. If params is not None, load_parameters will be called on that parameter set, and Structure.createSystem will be called with the remaining args and kwargs

Parameters
paramsCharmmParameterSet=None

If not None, this parameter set will be loaded

See also

parmed.structure.Structure.createSystem()

In addition to params, this method also takes all arguments for parmed.structure.Structure.createSystem()

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

Instantiates a CharmmPsfFile from an input Structure instance. This method makes sure all atom types have uppercase-only names

Parameters
structparmed.structure.Structure

The input structure to convert to a CharmmPsfFile instance

copybool, optional

If True, a copy of all items are made. Otherwise, the resulting CharmmPsfFile is a shallow copy

Returns
psfCharmmPsfFile

CHARMM PSF file

Raises
ValueError if the functional form is not recognized or cannot be
implemented through the PSF and parameter/stream files

Notes

If copy is False, the original object may have its atom type names changed if any of them have lower-case letters

load_parameters(parmset, copy_parameters=True)[source]

Loads parameters from a parameter set that was loaded via CHARMM RTF, PAR, and STR files.

Parameters
parmsetCharmmParameterSet

List of all parameters

copy_parametersbool, optional, default=True

If False, parmset will not be copied.

Not copying parmset will cause ParameterSet and Structure to share references to types. If you modify the original parameter set, the references in Structure list_types will be silently modified. However, if you change any reference in the parameter set, then that reference will no longer be shared with structure.

Example where the reference in ParameterSet is changed. The following will NOT modify the parameters in the psf:

psf.load_parameters(parmset, copy_parameters=False)
parmset.angle_types[('a1', 'a2', a3')] = AngleType(1, 2)

The following WILL change the parameter in the psf because the reference has not been changed in ParameterSet:

psf.load_parameters(parmset, copy_parameters=False)
a = parmset.angle_types[('a1', 'a2', 'a3')]
a.k = 10
a.theteq = 100

Extra care should be taken when trying this with dihedral_types. Since dihedral_type is a Fourier sequence, ParameterSet stores DihedralType for every term in DihedralTypeList. Therefore, the example below will STILL modify the type in the Structure list_types:

parmset.dihedral_types[('a', 'b', 'c', 'd')][0] = DihedralType(1, 2, 3)

This assigns a new instance of DihedralType to an existing DihedralTypeList that ParameterSet and Structure are tracking and the shared reference is NOT changed.

Use with caution!

Raises
ParameterError if any parameters cannot be found

Notes

  • If any dihedral or improper parameters cannot be found, I will try inserting wildcards (at either end for dihedrals and as the two central atoms in impropers) and see if that matches. Wild-cards will apply ONLY if specific parameters cannot be found.

  • This method will expand the dihedrals attribute by adding a separate Dihedral object for each term for types that have a multi-term expansion

parmed.charmm.psf.set_molecules(atoms)[source]

Correctly sets the molecularity of the system based on connectivity.