parmed.charmm.CharmmPsfFile

class parmed.charmm.CharmmPsfFile(psf_name=None)[source]

A chemical Structure instantiated from CHARMM files.

Parameters:

psf_name : str, optional

Name of the PSF file (it must exist)

Raises:

IOError : If file psf_name does not exist

CharmmPsfError : If 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
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
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
omm_bond_force([constraints, rigidWater, ...]) Creates an OpenMM Bond Force object (or AmoebaBondForce if the bonds are
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
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
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
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(struct, dest[, renumber, ...]) Write a PDB file from the current Structure instance
write_pdb(struct, dest[, renumber, ...]) Write a PDB file from a Structure instance
write_psf(struct, dest[, vmd]) Writes a PSF file from the stored molecule
__init__(psf_name=None)[source]

Opens and parses a PSF file, then instantiates a CharmmPsfFile instance from the data.

Methods

__init__([psf_name]) Opens and parses a PSF file, then instantiates a CharmmPsfFile instance from the data.
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
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
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
omm_bond_force([constraints, rigidWater, ...]) Creates an OpenMM Bond Force object (or AmoebaBondForce if the bonds are
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
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
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
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(struct, dest[, renumber, ...]) Write a PDB file from the current Structure instance
write_pdb(struct, dest[, renumber, ...]) Write a PDB file from a Structure instance
write_psf(struct, 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
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
add_atom(atom, resname, resnum, chain='', inscode='', segid='')

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.

Parameters:

atom : Atom

The atom to add to this residue list

resname : str

The name of the residue this atom belongs to

resnum : int

The number of the residue this atom belongs to

chain : str

The chain ID character for this residue

inscode : str

The insertion code ID character for this residue (it is stripped)

segid : str

The segment identifier for this residue (it is stripped)

Notes

If the residue name and number differ from the last residue in this list, a new residue is added and the atom is added to that residue

add_atom_to_residue(atom, residue)

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

Parameters:

atom : Atom

The atom to add to the system

residue : Residue

The residue to which to add this atom. It MUST be part of this Structure instance already or a ValueError is raised

Notes

This atom is added at the end of the residue and is inserted into the atoms list in such a way that all residues are composed of atoms contiguous in the atoms list. For large systems, this may be a relatively expensive operation

assign_bonds(*reslibs)

Assigns bonds to all atoms based on the provided residue template libraries. Atoms whose names are not in the templates, as well as those residues for whom no template is found, is assigned to bonds based on distances.

Parameters:

reslibs : dict{str: ResidueTemplate}

Any number of residue template libraries. By default, assign_bonds knows about the standard amino acid, RNA, and DNA residues.

box_vectors

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

clear_cmap()[source]

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

copy(cls, split_dihedrals=False)

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

Parameters:

cls : Structure subclass

The returned object is a copy of this structure as a cls instance

split_dihedrals : bool

If True, then the Dihedral entries will be split up so that each one is paired with a single DihedralType (rather than a DihedralTypeList)

Returns:

cls instance

The instance of the Structure subclass cls with a copy of the current Structure’s topology information

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:

params : CharmmParameterSet=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:

struct : parmed.structure.Structure

The input structure to convert to a CharmmPsfFile instance

copy : bool, optional

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

Returns:

psf : CharmmPsfFile

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

get_box(frame='all')

In some cases, multiple conformations may be stored in the Structure. This function retrieves a particular frame’s unit cell (box) dimensions

Parameters:

frame : int or ‘all’, optional

The frame number whose unit cell should be retrieved. Default is ‘all’

Returns:

box : np.ndarray, shape([#,] 6) or None

If frame is ‘all’, all unit cells are returned with shape (#, 6). Otherwise the requested frame is returned with shape (6,). If no unit cell exist and ‘all’ is requested, None is returned

Raises:

IndexError if there are fewer than ``frame`` unit cell dimensions

get_coordinates(frame='all')

In some cases, multiple conformations may be stored in the Structure. This function retrieves a particular frame’s coordinates

Parameters:

frame : int or ‘all’, optional

The frame number whose coordinates should be retrieved. Default is ‘all’

Returns:

coords : np.ndarray, shape([#,] natom, 3) or None

If frame is ‘all’, all coordinates are returned with shape (#, natom, 3). Otherwise the requested frame is returned with shape (natom, 3). If no coordinates exist and ‘all’ is requested, None is returned

Raises:

IndexError if there are fewer than ``frame`` coordinates

has_NBFIX()

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

Returns:

has_nbfix : bool

If True, at least two atom types have NBFIX mod definitions

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. If any dihedrals are already DihedralTypeList instances, or any are not parametrized, or there are no dihedral_types, this method returns without doing anything

load_dataframe(df)

Loads atomic properties from an input DataFrame

Parameters:

df : pandas.DataFrame

A pandas DataFrame with atomic properties that will be used to set the properties on the current list of atoms

load_parameters(parmset, copy_parameters=True)[source]

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

Parameters:

parmset : CharmmParameterSet

List of all parameters

copy_parameters : bool, 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
omm_add_constraints(system, constraints, rigidWater)

Adds constraints to a given system

Parameters:

system : mm.System

The OpenMM system for which constraints should be added

constraints : None, app.HBonds, app.AllBonds, or app.HAngles

Which kind of constraints should be used

rigidWater : bool

If True, water bonds are constrained regardless of whether constrains is None

omm_angle_force(constraints=None, flexibleConstraints=True)

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

Parameters:

constraints : None, app.HBonds, app.AllBonds, or app.HAngles

The types of constraints that are on the system. If flexibleConstraints is False, then the constrained bonds will not be added to the resulting Force

flexibleConstraints : bool=True

If True, all bonds are added to the force regardless of constraints

Returns:

force

HarmonicAngleForce (or AmoebaAngleForce if this is an Amoeba system), or None if there are no angles to add

omm_bond_force(constraints=None, rigidWater=True, flexibleConstraints=True)

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

Parameters:

constraints : None, app.HBonds, app.AllBonds, or app.HAngles

The types of constraints that are on the system. If flexibleConstraints is False, then the constrained bonds will not be added to the resulting Force

rigidWater : bool=True

Should water-H bonds be constrained regardless of constraints?

flexibleConstraints : bool=True

If True, all bonds are added to the force regardless of constraints

Returns:

force

HarmonicBondForce (or AmoebaBondForce if this is an Amoeba system), or None if there are no bonds to add

omm_cmap_force()

Creates the OpenMM CMAP torsion force

Returns:

CMAPTorsionForce

Or None, if no CMAP terms are present

omm_dihedral_force(split=False)

Creates the OpenMM PeriodicTorsionForce modeling dihedrals

Parameters:

split : bool, optional, default=False

If True, separate PeriodicTorsionForce instances with the propers in the first and impropers in the second return item. If no impropers or propers are present, the instances with zero terms are not returned.

Returns:

PeriodicTorsionForce[, PeriodicTorsionForce]

Or None if no torsions are present in this system

omm_gbsa_force(implicitSolvent, nonbondedMethod=None, nonbondedCutoff=Quantity(value=30.0, unit=angstrom), soluteDielectric=1.0, solventDielectric=78.5, implicitSolventKappa=None, implicitSolventSaltConc=Quantity(value=0.0, unit=mole/liter), temperature=Quantity(value=298.15, unit=kelvin), useSASA=True)

Creates a Generalized Born force for running implicit solvent calculations

Parameters:

implicitSolvent : app.HCT, app.OBC1, app.OBC2, app.GBn, app.GBn2

The Generalized Born implicit solvent model to use.

nonbondedMethod : cutoff method

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

nonbondedCutoff : float or distance Quantity

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

implicitSolventKappa : float or 1/distance Quantity = None

This is the Debye kappa property related to modeling saltwater conditions in GB. It should have units of 1/distance (1/nanometers is assumed if no units present). A value of None means that kappa will be calculated from implicitSolventSaltConc (below)

implicitSolventSaltConc : float or amount/volume Quantity=0 moles/liter

If implicitSolventKappa is None, the kappa will be computed from the salt concentration. It should have units compatible with mol/L

temperature : float or temperature Quantity = 298.15 kelvin

This is only used to compute kappa from implicitSolventSaltConc

soluteDielectric : float=1.0

The dielectric constant of the protein interior used in GB

solventDielectric : float=78.5

The dielectric constant of the water used in GB

omm_improper_force()

Creates the OpenMM improper torsion force (quadratic bias)

Returns:

CustomTorsionForce

With the formula k*(phi-phi0)^2, or None if there are no impropers

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

Creates the OpenMM NonbondedForce instance

Parameters:

nonbondedMethod : cutoff method

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

nonbondedCutoff : float 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.

switchDistance : float 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

ewaldErrorTolerance : float=0.0005

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

reactionFieldDielectric : float=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

This just implements the very basic NonbondedForce with the typical charge-charge and 12-6 Lennard-Jones interactions with the Lorentz-Berthelot combining rules.

Notes

Subclasses of Structure for which this nonbonded treatment is inadequate should override this method to implement what is needed.

If nrexcl is set to 3 and no exception parameters are stored in the adjusts list, the 1-4 interactions are determined from the list of dihedrals

omm_out_of_plane_bend_force()

Creates the Amoeba out-of-plane bend force

Returns:

AmoebaOutOfPlaneBendForce

The out-of-plane bend Angle force

omm_pi_torsion_force()

Creates the Amoeba pi-torsion force

Returns:

AmoebaPiTorsionForce

The pi-torsion force

omm_rb_torsion_force()

Creates the OpenMM RBTorsionForce for Ryckaert-Bellemans torsions

Returns:

RBTorsionForce

Or None if no torsions are present in this system

omm_set_virtual_sites(system)

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

Parameters:

system : mm.System

The system for which the virtual sites will be set. All particles must have already been added to this System before calling this method

omm_stretch_bend_force()

Create the OpenMM Amoeba stretch-bend force for this system

Returns:

AmoebaStretchBendForce

The stretch-bend force containing all terms in this system

omm_torsion_torsion_force()

Create the OpenMM Amoeba coupled-torsion (CMAP) force

Returns:

AmoebaTorsionTorsionForce

The torsion-torsion (CMAP) force with all coupled-torsion parameters for this system

omm_trigonal_angle_force()

Creates the Amoeba trigonal-angle force

Returns:

AmoebaInPlaneAngleForce

The trigonal in-plane Angle force

omm_urey_bradley_force()

Creates the OpenMM Urey-Bradley force

Returns:

HarmonicBondForce

Or None, if no urey-bradleys are present

positions

A list of 3-element Quantity tuples of dimension length representing the atomic positions for every atom in the system. If set with unitless numbers, those numbers are assumed to be in angstroms. If any atoms do not have coordinates, this is simply None.

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=None, overwrite=False, **kwargs)

Saves the current Structure in the requested file format. Supported formats can be specified explicitly or determined by file-name extension. The following formats are supported, with the recognized suffix and format keyword shown in parentheses:

  • PDB (.pdb, pdb)
  • PDBx/mmCIF (.cif, cif)
  • PQR (.pqr, pqr)
  • Amber topology file (.prmtop/.parm7, amber)
  • CHARMM PSF file (.psf, psf)
  • CHARMM coordinate file (.crd, charmmcrd)
  • Gromacs topology file (.top, gromacs)
  • Gromacs GRO file (.gro, gro)
  • Mol2 file (.mol2, mol2)
  • Mol3 file (.mol3, mol3)
  • Amber ASCII restart (.rst7/.inpcrd/.restrt, rst7)
  • Amber NetCDF restart (.ncrst, ncrst)
Parameters:

fname : str or file-like object

Name of the file or file-like object to save. If format is None (see below), the file type will be determined based on the filename extension. If fname is file-like object, format must be provided. If the type cannot be determined, a ValueError is raised.

format : str, optional

The case-insensitive keyword specifying what type of file fname should be saved as. If None (default), the file type will be determined from filename extension of fname

overwrite : bool, optional

If True, allow the target file to be overwritten. Otherwise, an IOError is raised if the file exists. Default is False

kwargs : keyword-arguments

Remaining arguments are passed on to the file writing routines that are called by this function

Raises:

ValueError if either filename extension or ``format`` are not recognized

TypeError if the structure cannot be converted to the desired format for

whatever reason

IOError if the file cannot be written either because it exists and

``overwrite`` is ``False``, the filesystem is read-only, or write

permissions are not granted for the user

split()

Split the current Structure into separate Structure instances for each unique molecule. A molecule is defined as all atoms connected by a graph of covalent bonds.

Returns:

[structs, counts] : list of (Structure, list) tuples

List of all molecules in the order that they appear first in the parent structure accompanied by the list of the molecule numbers in which that molecule appears in the Structure

strip(selection)

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

Parameters:

selection : AmberMask, str, or iterable

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.

to_dataframe()

Generates a DataFrame from the current Structure’s atomic properties

Returns:

df : DataFrame

DataFrame with all atomic properties

topology

The OpenMM Topology object. Cached when possible, but any changes to the Structure instance results in the topology being deleted and rebuilt

Notes

This function calls prune_empty_terms if any topology lists have changed.

unchange()

Toggles all lists so that they do not indicate any changes

update_dihedral_exclusions()

Nonbonded exclusions and exceptions have the following priority:

bond -> angle -> dihedral

Since bonds and angles are completely excluded, any ring systems in which two atoms are attached by a bond or angle as well as a dihedral should be completely excluded as the bond and angle exclusion rules take precedence. If a Bond or Angle was _added_ to the structure between a pair of atoms previously connected only by a dihedral term, it’s possible that those two atoms have both an exclusion and an exception defined. The result of this scenario is that sander and pmemd will happily compute an energy, _including_ the 1-4 nonbonded terms between atoms now connected by a bond or an Angle. OpenMM, on the other hand, will complain about an exception specified multiple times. This method scans through all of the dihedrals in which ignore_end is False and turns it to True if the two end atoms are in the bond or angle partners arrays

velocities

A (natom, 3)-shape numpy array with atomic velocities for every atom in the system (in units of angstrom/picosecond), or None if there are no velocities

view

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

See also

Structure.__getitem__

visualize(*args, **kwargs)

Use nglview for visualization. This only works with Jupyter notebook and require to install nglview

Parameters:args and kwargs : positional and keyword arguments given to nglview, optional

Examples

>>> import parmed as pmd
>>> parm = pmd.download_PDB('1tsu')
>>> parm.visualize()
write_cif(struct, dest, renumber=True, coordinates=None, altlocs='all', write_anisou=False, standard_resnames=False)

Write a PDB file from the current Structure instance

Parameters:

struct : Structure

The structure from which to write the PDBx/mmCIF file

dest : str or file-like

Either a file name or a file-like object containing a write method to which to write the PDB file. If it is a filename that ends with .gz or .bz2, a compressed version will be written using either gzip or bzip2, respectively.

renumber : bool

If True, renumber the atoms and residues sequentially as they are stored in the structure. If False, use the original numbering if it was assigned previously

coordinates : array-like of float

If provided, these coordinates will be written to the PDB file instead of the coordinates stored in the structure. These coordinates should line up with the atom order in the structure (not necessarily the order of the “original” PDB file if they differ)

altlocs : str

Keyword controlling which alternate locations are printed to the resulting PDB file. Allowable options are:

  • ‘all’ : (default) print all alternate locations
  • ‘first’ : print only the first alternate locations
  • ‘occupancy’ : print the one with the largest occupancy. If two conformers have the same occupancy, the first one to occur is printed

Input is case-insensitive, and partial strings are permitted as long as it is a substring of one of the above options that uniquely identifies the choice.

write_anisou : bool

If True, an ANISOU record is written for every atom that has one. If False, ANISOU records are not written

standard_resnames : bool, optional

If True, common aliases for various amino and nucleic acid residues will be converted into the PDB-standard values. Default is False

Notes

If multiple coordinate frames are present, these will be written as separate models (but only the unit cell from the first model will be written, as the PDBx standard dictates that only one set of unit cells shall be present).

write_pdb(struct, dest, renumber=True, coordinates=None, altlocs='all', write_anisou=False, charmm=False, standard_resnames=False)

Write a PDB file from a Structure instance

Parameters:

struct : Structure

The structure from which to write the PDB file

dest : str or file-like

Either a file name or a file-like object containing a write method to which to write the PDB file. If it is a filename that ends with .gz or .bz2, a compressed version will be written using either gzip or bzip2, respectively.

renumber : bool, optional, default True

If True, renumber the atoms and residues sequentially as they are stored in the structure. If False, use the original numbering if it was assigned previously.

coordinates : array-like of float, optional

If provided, these coordinates will be written to the PDB file instead of the coordinates stored in the structure. These coordinates should line up with the atom order in the structure (not necessarily the order of the “original” PDB file if they differ)

altlocs : str, optional, default ‘all’

Keyword controlling which alternate locations are printed to the resulting PDB file. Allowable options are:

  • ‘all’ : print all alternate locations
  • ‘first’ : print only the first alternate locations
  • ‘occupancy’ : print the one with the largest occupancy. If two conformers have the same occupancy, the first one to occur is printed

Input is case-insensitive, and partial strings are permitted as long as it is a substring of one of the above options that uniquely identifies the choice.

write_anisou : bool, optional, default False

If True, an ANISOU record is written for every atom that has one. If False, ANISOU records are not written.

charmm : bool, optional, default False

If True, SEGID will be written in columns 73 to 76 of the PDB file in the typical CHARMM-style PDB output. This will be omitted for any atom that does not contain a SEGID identifier.

standard_resnames : bool, optional, default False

If True, common aliases for various amino and nucleic acid residues will be converted into the PDB-standard values.

Notes

If multiple coordinate frames are present, these will be written as separate models (but only the unit cell from the first model will be written, as the PDB standard dictates that only one set of unit cells shall be present).

write_psf(struct, dest, vmd=False)

Writes a PSF file from the stored molecule

Parameters:

struct : Structure

The Structure instance from which the PSF should be written

dest : str or file-like

The place to write the output PSF file. If it has a “write” attribute, it will be used to print the PSF file. Otherwise, it will be treated like a string and a file will be opened, printed, then closed

vmd : bool

If True, it will write out a PSF in the format that VMD prints it in (i.e., no NUMLP/NUMLPH or MOLNT sections)

Examples

>>> cs = CharmmPsfFile('testfiles/test.psf')
>>> cs.write_psf('testfiles/test2.psf')