pestifer.charmmff.segtype_classifier module

Derive a residue’s segtype from the CHARMM topology/stream file it is defined in.

The CHARMM force field already organizes residues by category across its topology and stream files (*_lipid_* for lipids, *_carb_* for carbohydrates, *_prot_* for protein, *_na_* for nucleic acids, *_cgenff* for CGenFF ligands, water_ions for water and ions, …). Classifying by the defining file therefore replaces a large hand-maintained enumeration of residue names: a residue added to a CHARMM lipid stream is a lipid automatically.

This module is deliberately dependency-free (it takes a plain resname -> topfile mapping) so it can be exercised in isolation and reused by the persist-time generator.

pestifer.charmmff.segtype_classifier.derive_segtypes(resi_to_topfile_map, curated_names=frozenset({}), water_resnames=frozenset({}))[source]

Classify every residue in resi_to_topfile_map by its defining topology file.

Parameters:
  • resi_to_topfile_map (dict) – resname -> topfile-basename (a CHARMMFFContent attribute).

  • curated_names (set) – Residue names that are classified explicitly elsewhere (the curated core in pestifer.core.labels); these are skipped so an explicit classification is never overridden by a derived one.

  • water_resnames (set) – Residue names treated as water when they come from water_ions.

Returns:

segtype -> sorted list of resnames for every residue that a rule classified and that is not already curated.

Return type:

dict

pestifer.charmmff.segtype_classifier.segtype_of_topfile(topfile, water_resnames=frozenset({}), resname=None)[source]

Return the segtype implied by topfile (a topology/stream file basename), or None if no rule matches (e.g. topfile is None because the name is a PDB-style alias not defined directly in the force field).

toppar_water_ions.str holds both water and ions; when a residue comes from it, resname is classified as water if it is in water_resnames and ion otherwise.