# parmed.structure.Structure¶

class parmed.structure.Structure[source]

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

 positions A list of 3-element Quantity tuples of dimension length representing the atomic positions for every atom in the system.
 atoms (AtomList) List of all atoms in the structure residues (ResidueList) List of all residues in the structure bonds (TrackedList (Bond)) List of all bonds in the structure angles (TrackedList (Angle)) List of all angles in the structure dihedrals (TrackedList (Dihedral)) List of all dihedrals in the structure rb_torsions (TrackedList (Dihedral)) List of all Ryckaert-Bellemans torsions in the structure urey_bradleys (TrackedList (UreyBradley)) List of all Urey-Bradley angle bends in the structure impropers (TrackedList (Improper)) List of all CHARMM-style improper torsions in the structure cmaps (TrackedList (Cmap)) List of all CMAP objects in the structure trigonal_angles (TrackedList (TrigonalAngle)) List of all AMOEBA-style trigonal angles in the structure out_of_plane_bends (TrackedList (OutOfPlaneBends)) List of all AMOEBA-style out-of-plane bending angles pi_torsions (TrackedList (PiTorsion)) List of all AMOEBA-style pi-torsion angles stretch_bends (TrackedList (StretchBend)) List of all AMOEBA-style stretch-bend compound bond/angle terms torsion_torsions (TrackedList (TorsionTorsion)) List of all AMOEBA-style coupled torsion-torsion terms chiral_frames (TrackedList (ChiralFrame)) List of all AMOEBA-style chiral frames defined in the structure multipole_frames (TrackedList (MultipoleFrame)) List of all AMOEBA-style multipole frames defined in the structure adjusts (TrackedList (NonbondedException)) List of all nonbonded pair-exception rules acceptors (TrackedList (AcceptorDonor)) List of all H-bond acceptors, if that information is present donors (TrackedList (AcceptorDonor)) List of all H-bond donors, if that information is present groups (TrackedList (Group)) List of all CHARMM-style GROUP objects (whatever those are used for) box (list 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_group (str) The space group of the structure (default is “P 1”) nrexcl (int) The number of bonds away that an atom can be in order to be excluded from the direct nonbonded summation title (str) Cosmetic only, it is an arbitrary title assigned to the system. Default value is an empty string coordinates (np.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. symmetry (Symmetry) if no symmetry is set, this is set to None.

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

Methods

 __init__() 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 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 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 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='')[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: 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)[source]

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)[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: 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

copy(cls, split_dihedrals=False)[source]

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) 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: 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 constraints : None, 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 rigidWater : bool=True If True, water is kept rigid regardless of the value of constraints. A value of False is ignored if constraints is not None. implicitSolvent : None, app.HCT, app.OBC1, app.OBC2, app.GBn, app.GBn2 The Generalized Born implicit solvent model to use. 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 useSASA : bool=False If True, use the ACE non-polar solvation model. Otherwise, use no SASA-based nonpolar solvation model. removeCMMotion : bool=True If True, the center-of-mass motion will be removed periodically during the simulation. If False, it will not. hydrogenMass : float 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) ewaldErrorTolerance : float=0.0005 When using PME or Ewald, the Ewald parameters will be calculated from this value flexibleConstraints : bool=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). verbose : bool=False If True, the progress of this subroutine will be printed to stdout splitDihedrals : bool=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: frame : int or ‘all’, optional The frame number whose unit cell should be retrieved. Default is ‘all’ 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 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: frame : int or ‘all’, optional The frame number whose coordinates should be retrieved. Default is ‘all’ 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 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_nbfix : bool 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: df : pandas.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: 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)[source]

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

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

Generates a DataFrame from the current Structure’s atomic properties

Returns: df : DataFrame DataFrame with all atomic properties

parmed.utils.pandautils.create_dataframe(), documentation

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

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

Structure.__getitem__

visualize(*args, **kwargs)[source]

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.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')