packing_defect.core.topology

Classes

TopologyReader(radii, classifier)

Read CHARMM RTF/STR topology files (*.rtf, *.str) and extract atom properties for a given residue.

class packing_defect.core.topology.TopologyReader(radii: Dict[str, float], classifier: ClassificationStrategy | Callable[[str, str], int])[source]

Bases: object

Read CHARMM RTF/STR topology files (*.rtf, *.str) and extract atom properties for a given residue.

Each atom is mapped to a tuple (radius, code), where:

  • radius is looked up from a provided radii dictionary

  • code is determined using a classification strategy

The classifier may be either:

  • An object with a .classify(resname, atom_name) method

  • A plain function f(resname, atom_name) -> int

read(resname: str, topo_path: str) Dict[str, Tuple[float, int]][source]

Parse the RESI block for a given residue in the topology file.

Parameters:
  • resname (str) – Residue name to search for (e.g., POPC).

  • topo_path (str) – Path to a CHARMM topology file (.rtf or .str).

Returns:

dict of {str – Mapping from atom name to a tuple (radius, code).

Return type:

(float, int)}

Raises:
  • FileNotFoundError – If the topology file does not exist.

  • KeyError – If an atom type is not found in the radii map.

  • TypeError – If the classifier is not callable or does not implement .classify().