packing_defect.core.classification
classification.py
Implements the Strategy pattern for atom classification, with a default that matches your original logic and an optional JSON-driven rule set.
Classes
Abstract interface for atom classification strategies. |
|
Default logic (mirrors your original default_classify): - For non-TRIO residues: tail atoms → 1, else → -1 - For TRIO residues: glycerol atoms → 2, else → 3 |
|
|
Load classification codes from a JSON file of the form. |
- class packing_defect.core.classification.ClassificationStrategy[source]
Bases:
ABCAbstract interface for atom classification strategies.
- class packing_defect.core.classification.DefaultClassification[source]
Bases:
ClassificationStrategyDefault logic (mirrors your original default_classify): - For non-TRIO residues: tail atoms → 1, else → -1 - For TRIO residues: glycerol atoms → 2, else → 3
- class packing_defect.core.classification.UserDictClassification(rules: Dict[Tuple[str, str], int], label_to_code: Dict[str, int])[source]
Bases:
ClassificationStrategyLoad classification codes from a JSON file of the form:
{ "RES1": {"ATOM1": "heads", "ATOM2": "tails", ...}, "RES2": { ... } }
Labels (“heads”, “tails”) are automatically mapped to integer codes.
- classify(resname: str, atom_name: str) int[source]
Given a residue name and atom name, return an integer code.
- classmethod from_json(json_file: str) UserDictClassification[source]