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:
Parse all the parameter files that were used in the build.
Merge them into a single
CharmmParamFile.Extract the subset of parameters needed for the atom types present in the PSF.
Write the result as a single
.prmfile.
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:
objectA CHARMM angle parameter record (with optional Urey-Bradley terms).
- class pestifer.charmmff.charmmffprm.CharmmBondParam(type1: str, type2: str, Kb: float, b0: float, comment: str = '')[source]¶
Bases:
objectA CHARMM bond parameter record.
- class pestifer.charmmff.charmmffprm.CharmmCMAPParam(types: list, grid_size: int, data: list, comment: str = '')[source]¶
Bases:
objectA CHARMM CMAP correction record.
- class pestifer.charmmff.charmmffprm.CharmmDihedralParam(type1: str, type2: str, type3: str, type4: str, Kchi: float, n: int, delta: float, comment: str = '')[source]¶
Bases:
objectA CHARMM dihedral parameter record.
Note that multiple records with the same four atom types are allowed (different multiplicities). The wildcard atom type
Xmay appear in position 1 or 4 (or both).
- class pestifer.charmmff.charmmffprm.CharmmImproperParam(type1: str, type2: str, type3: str, type4: str, Kpsi: float, n: int, psi0: float, comment: str = '')[source]¶
Bases:
objectA CHARMM improper dihedral parameter record.
- class pestifer.charmmff.charmmffprm.CharmmNBFixParam(type1: str, type2: str, Emin: float, Rmin: float, comment: str = '')[source]¶
Bases:
objectA CHARMM NBFIX record (pairwise LJ override).
- 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:
objectA CHARMM Lennard-Jones (nonbonded) parameter record for one atom type.
- class pestifer.charmmff.charmmffprm.CharmmParamFile[source]¶
Bases:
objectParses, merges, filters, and writes CHARMM parameter files.
Supports both standalone
.prmfiles and the parameter sections embedded in.str(stream) files.:param None – use the class-methods
from_file()orfrom_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
CharmmParamFilecontaining 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.
- 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
.prmfiles (bare section headers at top level) and.strfiles (sections insideread para … ENDblocks).
- 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 APPENDbehaviour. For dihedrals, entries with the same atom-type quartet but different multiplicitynare kept as separate terms (they are summed by the force field); only exact duplicates (same quartet and samen) are deduplicated.
- nbfix: list[CharmmNBFixParam]¶
- nonbonded: dict[str, CharmmNonbondedParam]¶