parmed.charmm.CharmmParameterSet

class parmed.charmm.CharmmParameterSet(*args)[source]

Stores a parameter set defined by CHARMM files. It stores the equivalent of the information found in the MASS section of the CHARMM topology file (TOP/RTF) and all of the information in the parameter files (PAR)

Parameters:

*filenames : variable length arguments of str

The list of topology, parameter, and stream files to load into the parameter set. The following file type suffixes are recognized:

.rtf, .top – Residue topology file .par, .prm – Parameter file .str – Stream file .inp – If “par” is in the file name, it is a parameter file. If

“top” is in the file name, it is a topology file. Otherwise, ValueError is raised.

Attributes

combining_rule

Methods

condense([do_dihedrals]) This function goes through each of the parameter type dicts and eliminates duplicate types.
from_parameterset(params[, copy]) Instantiates a CharmmParameterSet from another ParameterSet (or subclass).
from_structure(struct) Extracts known parameters from a Structure instance
load_set([tfile, pfile, sfiles]) Instantiates a CharmmParameterSet from a Topology file and a Parameter
read_parameter_file(pfile[, comments]) Reads all of the parameters from a parameter file.
read_stream_file(sfile) Reads RTF and PAR sections from a stream file and dispatches the
read_topology_file(tfile) Reads _only_ the atom type definitions from a topology file.
typeify_templates() Assign atom types to atom names in templates
write([top, par, str]) Write a CHARMM parameter set to a file
__init__(*args)[source]

Methods

__init__(\*args)
condense([do_dihedrals]) This function goes through each of the parameter type dicts and eliminates duplicate types.
from_parameterset(params[, copy]) Instantiates a CharmmParameterSet from another ParameterSet (or subclass).
from_structure(struct) Extracts known parameters from a Structure instance
load_set([tfile, pfile, sfiles]) Instantiates a CharmmParameterSet from a Topology file and a Parameter
read_parameter_file(pfile[, comments]) Reads all of the parameters from a parameter file.
read_stream_file(sfile) Reads RTF and PAR sections from a stream file and dispatches the
read_topology_file(tfile) Reads _only_ the atom type definitions from a topology file.
typeify_templates() Assign atom types to atom names in templates
write([top, par, str]) Write a CHARMM parameter set to a file

Attributes

combining_rule
condense(do_dihedrals=True)

This function goes through each of the parameter type dicts and eliminates duplicate types. After calling this function, every unique bond, angle, dihedral, improper, or cmap type will pair with EVERY key in the type mapping dictionaries that points to the equivalent type

Parameters:

do_dihedrals : bool=True

Dihedrals can take the longest time to compress since testing their equality takes the longest (this is complicated by the existence of multi-term torsions). This flag will allow you to skip condensing the dihedral parameter types (for large parameter sets, this can cut the compression time in half)

Returns:

self

The instance that is being condensed

Notes

The return value allows you to condense the types at construction time.

classmethod from_parameterset(params, copy=False)[source]

Instantiates a CharmmParameterSet from another ParameterSet (or subclass). The main thing this feature is responsible for is converting lower-case atom type names into all upper-case and decorating the name to ensure each atom type name is unique.

Parameters:

params : parmed.parameters.ParameterSet

ParameterSet containing the list of parameters to be converted to a CHARMM-compatible set

copy : bool, optional

If True, the returned parameter set is a deep copy of params. If False, the returned parameter set is a shallow copy, and the original set may be modified if any lower-case atom type names are present. Default is False.

Returns:

new_params : CharmmParameterSet

The parameter set whose atom type names are converted to all upper-case

classmethod from_structure(struct)[source]

Extracts known parameters from a Structure instance

Parameters:

struct : parmed.structure.Structure

The parametrized Structure instance from which to extract parameters into a ParameterSet

Returns:

params : ParameterSet

The parameter set with all parameters defined in the Structure

Notes

The parameters here are copies of the ones in the Structure, so modifying the generated ParameterSet will have no effect on struct. Furthermore, the first occurrence of each parameter will be used. If future ones differ, they will be silently ignored, since this is expected behavior in some instances (like with Gromacs topologies in the ff99sb-ildn force field).

Dihedrals are a little trickier. They can be multi-term, which can be represented either as a single entry in dihedrals with a type of DihedralTypeList or multiple entries in dihedrals with a DihedralType parameter type. In this case, the parameter is constructed from either the first DihedralTypeList found or the first DihedralType of each periodicity found if no matching DihedralTypeList is found.

classmethod load_set(tfile=None, pfile=None, sfiles=None)[source]

Instantiates a CharmmParameterSet from a Topology file and a Parameter file (or just a Parameter file if it has all information)

Parameters:

tfile : str

The name of the Topology (RTF/TOP) file to parse

pfile : str

The name of the Parameter (PAR/PRM) file to parse

sfiles : list(str)

Iterable of stream (STR) file names

Returns:

New CharmmParameterSet populated with parameters found in the provided

files

Notes

The RTF file is read first (if provided), followed by the PAR file, followed by the list of stream files (in the order they are provided). Parameters in each stream file will overwrite those that came before (or simply append to the existing set if they are different)

read_parameter_file(pfile, comments=None)[source]

Reads all of the parameters from a parameter file. Versions 36 and later of the CHARMM force field files have an ATOMS section defining all of the atom types. Older versions need to load this information from the RTF/TOP files.

Parameters:

pfile : str or list of lines

Name of the CHARMM parameter file to read or list of lines to parse as a file

comments : list of str, optional

List of comments on each of the pfile lines (if pfile is a list of lines)

Notes

The atom types must all be loaded by the end of this routine. Either supply a PAR file with atom definitions in them or read in a RTF/TOP file first. Failure to do so will result in a raised RuntimeError.

read_stream_file(sfile)[source]

Reads RTF and PAR sections from a stream file and dispatches the sections to read_topology_file or read_parameter_file

Parameters:

sfile : str or CharmmStreamFile

Stream file to parse

read_topology_file(tfile)[source]

Reads _only_ the atom type definitions from a topology file. This is unnecessary for versions 36 and later of the CHARMM force field.

Parameters:

tfile : str

Name of the CHARMM topology file to read

typeify_templates()

Assign atom types to atom names in templates

write(top=None, par=None, str=None)[source]

Write a CHARMM parameter set to a file

Parameters:

top : str or file-like object, optional

If provided, the atom types will be written to this file in RTF format.

par : str or file-like object, optional

If provided, the parameters will be written to this file in PAR format. Either this or the str argument must be provided

str : str or file-like object, optional

If provided, the atom types and parameters will be written to this file as separate RTF and PAR cards that can be read as a CHARMM stream file. Either this or the par argument must be provided

Raises:

ValueError if both par and str are None