pestifer.charmmff.charmmffprm module

Parsing and writing CHARMM parameter files (.prm and the parameter sections of .str files).

The main class is CharmmParamFile, which can be used to parse, merge, filter, and write CHARMM parameter files. The typical workflow for generating a minimal consolidated parameter file for a simulation system is:

  1. Parse all the parameter files that were used in the build.

  2. Merge them into a single CharmmParamFile.

  3. Extract the subset of parameters needed for the atom types present in the PSF.

  4. Write the result as a single .prm file.

Usage example:

from pestifer.charmmff.charmmffprm import CharmmParamFile

combined = CharmmParamFile()
for fname in ['par_all36m_prot.prm', 'toppar_water_ions.str']:
    combined.merge(CharmmParamFile.from_file(fname))

atom_types = {'C', 'NH1', 'CT1', ...}   # from PSF
minimal = combined.extract_for_atomtypes(atom_types)
minimal.write('my_system_minimal.prm')
class pestifer.charmmff.charmmffprm.CharmmAngleParam(type1: str, type2: str, type3: str, Ktheta: float, Theta0: float, Kub: float | None = None, S0: float | None = None, comment: str = '')[source]

Bases: object

A CHARMM angle parameter record (with optional Urey-Bradley terms).

Ktheta: float
Kub: float | None = None
S0: float | None = None
Theta0: float
comment: str = ''
type1: str
type2: str
type3: str
class pestifer.charmmff.charmmffprm.CharmmBondParam(type1: str, type2: str, Kb: float, b0: float, comment: str = '')[source]

Bases: object

A CHARMM bond parameter record.

Kb: float
b0: float
comment: str = ''
type1: str
type2: str
class pestifer.charmmff.charmmffprm.CharmmCMAPParam(types: list, grid_size: int, data: list, comment: str = '')[source]

Bases: object

A CHARMM CMAP correction record.

comment: str = ''
data: list
grid_size: int
types: list
class pestifer.charmmff.charmmffprm.CharmmDihedralParam(type1: str, type2: str, type3: str, type4: str, Kchi: float, n: int, delta: float, comment: str = '')[source]

Bases: object

A CHARMM dihedral parameter record.

Note that multiple records with the same four atom types are allowed (different multiplicities). The wildcard atom type X may appear in position 1 or 4 (or both).

Kchi: float
comment: str = ''
delta: float
n: int
type1: str
type2: str
type3: str
type4: str
class pestifer.charmmff.charmmffprm.CharmmImproperParam(type1: str, type2: str, type3: str, type4: str, Kpsi: float, n: int, psi0: float, comment: str = '')[source]

Bases: object

A CHARMM improper dihedral parameter record.

Kpsi: float
comment: str = ''
n: int
psi0: float
type1: str
type2: str
type3: str
type4: str
class pestifer.charmmff.charmmffprm.CharmmNBFixParam(type1: str, type2: str, Emin: float, Rmin: float, comment: str = '')[source]

Bases: object

A CHARMM NBFIX record (pairwise LJ override).

Emin: float
Rmin: float
comment: str = ''
type1: str
type2: str
class pestifer.charmmff.charmmffprm.CharmmNonbondedParam(atomtype: str, ignored: float, epsilon: float, Rmin_half: float, ignored14: float | None = None, epsilon14: float | None = None, Rmin_half14: float | None = None, comment: str = '')[source]

Bases: object

A CHARMM Lennard-Jones (nonbonded) parameter record for one atom type.

Rmin_half: float
Rmin_half14: float | None = None
atomtype: str
comment: str = ''
epsilon: float
epsilon14: float | None = None
ignored: float
ignored14: float | None = None
class pestifer.charmmff.charmmffprm.CharmmParamFile[source]

Bases: object

Parses, merges, filters, and writes CHARMM parameter files.

Supports both standalone .prm files and the parameter sections embedded in .str (stream) files.

:param None – use the class-methods from_file() or from_text(): :param to construct an instance from existing data.:

angles: list[CharmmAngleParam]
bonds: list[CharmmBondParam]
cmaps: list[CharmmCMAPParam]
dihedrals: list[CharmmDihedralParam]
extract_for_atomtypes(atomtypes: set[str]) CharmmParamFile[source]

Return a new CharmmParamFile containing only the records relevant to atomtypes.

A record is included when every non-wildcard (X) atom type in that record appears in atomtypes. This is a conservative filter: it may include a handful of wildcard entries that are not strictly needed, but it never omits a record that is needed.

Parameters:

atomtypes (set of str) – The set of atom types present in the target PSF.

Returns:

A new instance containing the filtered records.

Return type:

CharmmParamFile

classmethod from_file(filename: str) CharmmParamFile[source]

Parse a CHARMM parameter file (or stream file) from disk.

classmethod from_text(text: str) CharmmParamFile[source]

Parse CHARMM parameter content from a string.

Works for both .prm files (bare section headers at top level) and .str files (sections inside read para END blocks).

impropers: list[CharmmImproperParam]
merge(other: CharmmParamFile) None[source]

Merge other into this instance (in-place).

Uses last-wins semantics for all sections, matching CHARMM’s READ PARAM APPEND behaviour. For dihedrals, entries with the same atom-type quartet but different multiplicity n are kept as separate terms (they are summed by the force field); only exact duplicates (same quartet and same n) are deduplicated.

nbfix: list[CharmmNBFixParam]
nonbonded: dict[str, CharmmNonbondedParam]
nonbonded_header: str
summary() str[source]

Return a one-line summary of the parameter counts.

write(filename: str, title: str = '') None[source]

Write this parameter set to filename in CHARMM format.

Parameters:
  • filename (str) – Output file path.

  • title (str, optional) – A short description written into the file header.