parmed.charmm.parameters module

This module contains classes for parsing and processing CHARMM parameter, topology, and stream files.

Author: Jason M. Swails Contributors: Date: Mar. 26, 2017

class parmed.charmm.parameters.CharmmImproperMatchingMixin[source]

Bases: object

Implements CHARMM-style improper matching

Methods

match_improper_type(a1, a2, a3, a4)

Matches an improper type based on atom type names

match_improper_type(a1, a2, a3, a4)[source]

Matches an improper type based on atom type names

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

Bases: parmed.parameters.ParameterSet, parmed.charmm.parameters.CharmmImproperMatchingMixin

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
*filenamesvariable 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 file (or just a Parameter file if it has all information)

match_improper_type(a1, a2, a3, a4)

Matches an improper type based on atom type names

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 sections to read_topology_file or read_parameter_file

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

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
paramsparmed.parameters.ParameterSet

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

copybool, 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_paramsCharmmParameterSet

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
structparmed.structure.Structure

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

Returns
paramsParameterSet

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
tfilestr

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

pfilestr

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

sfileslist(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
pfilestr or list of lines

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

commentslist 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
sfilestr 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
tfilestr

Name of the CHARMM topology file to read

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

Write a CHARMM parameter set to a file

Parameters
topstr or file-like object, optional

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

parstr 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

strstr 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