parmed.structure module

This module contains the core base class for all of the chemical structures with various topological and force field features.

class parmed.structure.Structure[source]

Bases: object

A chemical structure composed of atoms, bonds, angles, torsions, and other topological features

Notes

This class also has a handful of type lists for each of the attributes above (excluding atoms, residues, chiral_frames, and multipole_frames). They are all TrackedList instances that are designed to hold the relevant parameter type. The list is:

bond_types, angle_types, dihedral_types, urey_bradley_types, improper_types, cmap_types, trigonal_angle_types, out_of_plane_bend_types, pi_torsion_types, stretch_bend_types, torsion_torsion_types, adjust_types

dihedral_types _may_ be a list of DihedralType instances, since torsion profiles are often represented by a Fourier series with multiple terms

Attributes
atomsAtomList

List of all atoms in the structure

residuesResidueList

List of all residues in the structure

bondsTrackedList (Bond)

List of all bonds in the structure

anglesTrackedList (Angle)

List of all angles in the structure

dihedralsTrackedList (Dihedral)

List of all dihedrals in the structure

rb_torsionsTrackedList (Dihedral)

List of all Ryckaert-Bellemans torsions in the structure

urey_bradleysTrackedList (UreyBradley)

List of all Urey-Bradley angle bends in the structure

impropersTrackedList (Improper)

List of all CHARMM-style improper torsions in the structure

cmapsTrackedList (Cmap)

List of all CMAP objects in the structure

trigonal_anglesTrackedList (TrigonalAngle)

List of all AMOEBA-style trigonal angles in the structure

out_of_plane_bendsTrackedList (OutOfPlaneBends)

List of all AMOEBA-style out-of-plane bending angles

pi_torsionsTrackedList (PiTorsion)

List of all AMOEBA-style pi-torsion angles

stretch_bendsTrackedList (StretchBend)

List of all AMOEBA-style stretch-bend compound bond/angle terms

torsion_torsionsTrackedList (TorsionTorsion)

List of all AMOEBA-style coupled torsion-torsion terms

chiral_framesTrackedList (ChiralFrame)

List of all AMOEBA-style chiral frames defined in the structure

multipole_framesTrackedList (MultipoleFrame)

List of all AMOEBA-style multipole frames defined in the structure

adjustsTrackedList (NonbondedException)

List of all nonbonded pair-exception rules

acceptorsTrackedList (AcceptorDonor)

List of all H-bond acceptors, if that information is present

donorsTrackedList (AcceptorDonor)

List of all H-bond donors, if that information is present

groupsTrackedList (Group)

List of all CHARMM-style GROUP objects (whatever those are used for)

boxlist of 6 floats

Box dimensions (a, b, c, alpha, beta, gamma) for the unit cell. If no box is defined, box is set to None

space_groupstr

The space group of the structure (default is “P 1”)

nrexclint

The number of bonds away that an atom can be in order to be excluded from the direct nonbonded summation

titlestr

Cosmetic only, it is an arbitrary title assigned to the system. Default value is an empty string

positionsu.Quantity(list(Vec3), u.angstroms)

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

coordinatesnp.ndarray of shape (nframes, natom, 3)

If no coordinates are set, this is set to None. The first frame will match the coordinates present on the atoms.

symmetrySymmetry

if no symmetry is set, this is set to None.

linksTrackedList (Link)

The list of Link definitions for this Structure

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.

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

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

ANGLE_FORCE_GROUP = 1
BOND_FORCE_GROUP = 0
CMAP_FORCE_GROUP = 5
DIHEDRAL_FORCE_GROUP = 2
IMPROPER_FORCE_GROUP = 4
NONBONDED_FORCE_GROUP = 11
OUT_OF_PLANE_BEND_FORCE_GROUP = 7
PI_TORSION_FORCE_GROUP = 8
RB_TORSION_FORCE_GROUP = 12
STRETCH_BEND_FORCE_GROUP = 9
TORSION_TORSION_FORCE_GROUP = 10
TRIGONAL_ANGLE_FORCE_GROUP = 6
UREY_BRADLEY_FORCE_GROUP = 3
add_atom(atom, resname, resnum, chain='', inscode='', segid='')[source]

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
atomAtom

The atom to add to this residue list

resnamestr

The name of the residue this atom belongs to

resnumint

The number of the residue this atom belongs to

chainstr

The chain ID character for this residue

inscodestr

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

segidstr

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)[source]

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

Parameters
atomAtom

The atom to add to the system

residueResidue

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)[source]

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
reslibsdict{str: ResidueTemplate}

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

property box
property box_vectors

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

property combining_rule
property coordinates
copy(cls, split_dihedrals=False)[source]

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

Parameters
clsStructure subclass

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

split_dihedralsbool

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(nonbondedMethod=None, nonbondedCutoff=Quantity(value=8.0, unit=angstrom), switchDistance=Quantity(value=0.0, unit=angstrom), constraints=None, rigidWater=True, implicitSolvent=None, implicitSolventKappa=None, implicitSolventSaltConc=Quantity(value=0.0, unit=mole / liter), temperature=Quantity(value=298.15, unit=kelvin), soluteDielectric=1.0, solventDielectric=78.5, useSASA=False, removeCMMotion=True, hydrogenMass=None, ewaldErrorTolerance=0.0005, flexibleConstraints=True, verbose=False, splitDihedrals=False)[source]

Construct an OpenMM System representing the topology described by the prmtop file.

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

constraintsNone, app.HBonds, app.HAngles, or app.AllBonds

Which type of constraints to add to the system (e.g., SHAKE). None means no bonds are constrained. HBonds means bonds with hydrogen are constrained

rigidWaterbool=True

If True, water is kept rigid regardless of the value of constraints. A value of False is ignored if constraints is not None.

implicitSolventNone, app.HCT, app.OBC1, app.OBC2, app.GBn, app.GBn2

The Generalized Born implicit solvent model to use.

implicitSolventKappafloat 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)

implicitSolventSaltConcfloat 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

temperaturefloat or temperature Quantity = 298.15 kelvin

This is only used to compute kappa from implicitSolventSaltConc

soluteDielectricfloat=1.0

The dielectric constant of the protein interior used in GB

solventDielectricfloat=78.5

The dielectric constant of the water used in GB

useSASAbool=False

If True, use the ACE non-polar solvation model. Otherwise, use no SASA-based nonpolar solvation model.

removeCMMotionbool=True

If True, the center-of-mass motion will be removed periodically during the simulation. If False, it will not.

hydrogenMassfloat or mass quantity = None

If not None, hydrogen masses will be changed to this mass and the difference subtracted from the attached heavy atom (hydrogen mass repartitioning)

ewaldErrorTolerancefloat=0.0005

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

flexibleConstraintsbool=True

If False, the energies and forces from the constrained degrees of freedom will NOT be computed. If True, they will (but those degrees of freedom will still be constrained).

verbosebool=False

If True, the progress of this subroutine will be printed to stdout

splitDihedralsbool=False

If True, the dihedrals will be split into two forces – proper and impropers. This is primarily useful for debugging torsion parameter assignments.

Notes

This function calls prune_empty_terms if any Topology lists have changed

get_box(frame='all')[source]

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

Parameters
frameint or ‘all’, optional

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

Returns
boxnp.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')[source]

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

Parameters
frameint or ‘all’, optional

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

Returns
coordsnp.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()[source]

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

Returns
has_nbfixbool

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

is_changed()[source]

Determines if any of the topology has changed for this structure

join_dihedrals()[source]

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)[source]

Loads atomic properties from an input DataFrame

Parameters
dfpandas.DataFrame

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

omm_add_constraints(system, constraints, rigidWater)[source]

Adds constraints to a given system

Parameters
systemmm.System

The OpenMM system for which constraints should be added

constraintsNone, app.HBonds, app.AllBonds, or app.HAngles

Which kind of constraints should be used

rigidWaterbool

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

omm_angle_force(constraints=None, flexibleConstraints=True)[source]

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

Parameters
constraintsNone, 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

flexibleConstraintsbool=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)[source]

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

Parameters
constraintsNone, 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

rigidWaterbool=True

Should water-H bonds be constrained regardless of constraints?

flexibleConstraintsbool=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()[source]

Creates the OpenMM CMAP torsion force

Returns
CMAPTorsionForce

Or None, if no CMAP terms are present

omm_dihedral_force(split=False)[source]

Creates the OpenMM PeriodicTorsionForce modeling dihedrals

Parameters
splitbool, 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)[source]

Creates a Generalized Born force for running implicit solvent calculations

Parameters
implicitSolventapp.HCT, app.OBC1, app.OBC2, app.GBn, app.GBn2

The Generalized Born implicit solvent model to use.

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. Default is NoCutoff

nonbondedCutofffloat 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

implicitSolventKappafloat 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)

implicitSolventSaltConcfloat 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

temperaturefloat or temperature Quantity = 298.15 kelvin

This is only used to compute kappa from implicitSolventSaltConc

soluteDielectricfloat=1.0

The dielectric constant of the protein interior used in GB

solventDielectricfloat=78.5

The dielectric constant of the water used in GB

omm_improper_force()[source]

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)[source]

Creates the OpenMM NonbondedForce instance

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

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()[source]

Creates the Amoeba out-of-plane bend force

Returns
AmoebaOutOfPlaneBendForce

The out-of-plane bend Angle force

omm_pi_torsion_force()[source]

Creates the Amoeba pi-torsion force

Returns
AmoebaPiTorsionForce

The pi-torsion force

omm_rb_torsion_force()[source]

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)[source]

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

Parameters
systemmm.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()[source]

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()[source]

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()[source]

Creates the Amoeba trigonal-angle force

Returns
AmoebaInPlaneAngleForce

The trigonal in-plane Angle force

omm_urey_bradley_force()[source]

Creates the OpenMM Urey-Bradley force

Returns
HarmonicBondForce

Or None, if no urey-bradleys are present

property 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()[source]

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)[source]

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
fnamestr 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.

formatstr, 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

overwritebool, optional

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

kwargskeyword-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()[source]

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)[source]

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

Parameters
selectionAmberMask, 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()[source]

Generates a DataFrame from the current Structure’s atomic properties

Returns
dfDataFrame

DataFrame with all atomic properties

property 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()[source]

Toggles all lists so that they do not indicate any changes

update_dihedral_exclusions()[source]

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

property velocities
property 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)[source]

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

Parameters
args and kwargspositional and keyword arguments given to nglview, optional

Examples

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

Write a PDB file from the current Structure instance

Parameters
structStructure

The structure from which to write the PDBx/mmCIF file

deststr 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.

renumberbool

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

coordinatesarray-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)

altlocsstr

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_anisoubool

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

standard_resnamesbool, 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(dest, renumber=True, coordinates=None, altlocs='all', write_anisou=False, charmm=False, use_hetatoms=True, standard_resnames=False, increase_tercount=True, write_links=False)

Write a PDB file from a Structure instance

Parameters
structStructure

The structure from which to write the PDB file

deststr 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.

renumberbool, 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.

coordinatesarray-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)

altlocsstr, 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_anisoubool, optional, default False

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

charmmbool, 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.

use_hetatoms: bool, optional, default True

If True, certain atoms will have the HETATM tag instead of ATOM as per the PDB-standard.

standard_resnamesbool, optional, default False

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

increase_tercountbool, optional, default True

If True, the TER atom number field increased by one compared to atom card preceding it; this conforms to PDB standard.

write_linksbool, optional, default False

If True, any LINK records stored in the Structure will be written to the LINK records near the top of the PDB file. If this is True, then renumber must be False or a ValueError will be thrown

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(dest, vmd=False)

Writes a PSF file from the stored molecule

Parameters
structStructure

The Structure instance from which the PSF should be written

deststr 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

vmdbool

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')
class parmed.structure.StructureView[source]

Bases: object

A view of a Structure. In many cases, this can serve as a duck-typed Structure and it has many of the same attributes. However, none of its lists own their objects, and the lists of atoms, residues, and parameters/topologies are regular lists, rather than TrackedList instances. Therefore, the indexes correspond to the indexes from the original Structure from which this view was taken. Furthermore, there are no “type” lists, as they would be exactly equivalent to the type lists of the parent Structure instance.

Attributes
atomsAtomList

List of all atoms in the structure

residuesResidueList

List of all residues in the structure

bondsTrackedList (Bond)

List of all bonds in the structure

anglesTrackedList (Angle)

List of all angles in the structure

dihedralsTrackedList (Dihedral)

List of all dihedrals in the structure

rb_torsionsTrackedList (RBTorsion)

List of all Ryckaert-Bellemans torsions in the structure

urey_bradleysTrackedList (UreyBradley)

List of all Urey-Bradley angle bends in the structure

impropersTrackedList (Improper)

List of all CHARMM-style improper torsions in the structure

cmapsTrackedList (Cmap)

List of all CMAP objects in the structure

trigonal_anglesTrackedList (TrigonalAngle)

List of all AMOEBA-style trigonal angles in the structure

out_of_plane_bendsTrackedList (OutOfPlaneBends)

List of all AMOEBA-style out-of-plane bending angles

pi_torsionsTrackedList (PiTorsion)

List of all AMOEBA-style pi-torsion angles

stretch_bendsTrackedList (StretchBend)

List of all AMOEBA-style stretch-bend compound bond/angle terms

torsion_torsionsTrackedList (TorsionTorsion)

List of all AMOEBA-style coupled torsion-torsion terms

chiral_framesTrackedList (ChiralFrame)

List of all AMOEBA-style chiral frames defined in the structure

multipole_framesTrackedList (MultipoleFrame)

List of all AMOEBA-style multipole frames defined in the structure

adjustsTrackedList (NonbondedException)

List of all nonbonded pair-exception rules

acceptorsTrackedList (AcceptorDonor)

List of all H-bond acceptors, if that information is present

donorsTrackedList (AcceptorDonor)

List of all H-bond donors, if that information is present

positionsu.Quantity(list(Vec3), u.angstroms)

Unit-bearing atomic coordinates. If not all atoms have coordinates, this property is None

coordinatesnp.ndarray of shape (nframes, natom, 3)

If no coordinates are set, this is set to None. The first frame will match the coordinates present on the atoms.

Methods

load_dataframe(df)

Loads atomic properties from an input DataFrame

to_dataframe()

Generates a DataFrame from the current Structure’s atomic properties

property coordinates
load_dataframe(df)[source]

Loads atomic properties from an input DataFrame

Parameters
dfpandas.DataFrame

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

property positions
to_dataframe()[source]

Generates a DataFrame from the current Structure’s atomic properties

Returns
dfDataFrame

DataFrame with all atomic properties