Modifier
Module
viennaptm.modification.application.modifier
- class Modifier(library: ModificationLibrary = None)
Bases:
BaseModelApplies residue-level chemical modifications to a biomolecular structure.
The
Modifierclass acts as a high-level interface between aModificationLibraryand an annotated structure. It locates a specific residue within a structure, removes hydrogen atoms from the target residue, applies the requested modification using a template residue, and records the modification in the structure’s modification log.- Parameters:
library (ModificationLibrary, optional) – Library containing residue modification definitions and template residues. If
None, an internal defaultModificationLibraryis loaded.
- static atoms_to_array(atoms: List[Atom]) ndarray
Convert a list of atoms to a NumPy coordinate array.
- Parameters:
atoms (list[Atom]) – Atoms whose coordinates should be extracted.
- Returns:
Array of shape
(n_atoms, 3)containing atomic coordinates.- Return type:
numpy.ndarray
- get_library()
Return the associated modification library.
- Returns:
The library used by this
Modifierinstance.- Return type:
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- modify(structure: AnnotatedStructure, chain_identifier: str, residue_number: int, target_abbreviation: str, inplace: bool = True) AnnotatedStructure
Apply a residue modification to a structure.
This method locates a residue by chain identifier and residue number, removes all hydrogen atoms, applies a modification defined in the modification library, and optionally returns a modified copy of the structure.
- Parameters:
structure (AnnotatedStructure) – The structure to be modified.
chain_identifier (str) – Chain identifier of the target residue (commonly a single uppercase letter).
residue_number (int) – Position of the residue in the polypeptide chain, Residue number as defined in the structure (PDB numbering).
target_abbreviation (str) – Three-letter abbreviation of the target (modified) residue.
inplace (bool) – If
True, the structure is modified in place. IfFalse, a deep copy of the structure is created and modified.
- Returns:
The modified structure. This is either the original structure (if
inplace=True) or a modified copy.- Return type:
- Raises:
ValueError – If no residue matching the given chain identifier and residue number can be found in the structure.
KeyError – If atom names required for the modification do not match those in the structure or the template residue.
Note
This method assumes that:
Chain identifiers are unique across all models.
A template PDB exists for every supported modification.
The structure supports modification logging via
add_to_modification_log.
- static remove_hydrogens(residue: Residue)
Remove all hydrogen atoms from a residue.
Hydrogen atoms are identified by atom names starting with
"H". This step avoids inconsistencies in atom naming schemes during modification.- Parameters:
residue (Residue) – Residue from which hydrogen atoms will be removed.
Methods
|
Initialize a |
|
Convert a list of atoms to a NumPy coordinate array. |
|
|
|
Returns a copy of the model. |
|
|
|
|
Return the associated modification library. |
|
|
|
|
Creates a new instance of the Model class with validated data. |
|
!!! abstract "Usage Documentation" |
|
!!! abstract "Usage Documentation" |
|
!!! abstract "Usage Documentation" |
|
Generates a JSON schema for a model class. |
|
Compute the class name for parametrizations of generic classes. |
|
Override this method to perform additional initialization after __init__ and model_construct. |
|
Try to rebuild the pydantic-core schema for the model. |
|
Validate a pydantic model instance. |
|
!!! abstract "Usage Documentation" |
|
Validate the given object with string data against the Pydantic model. |
|
Apply a residue modification to a structure. |
|
|
|
|
|
|
|
Remove all hydrogen atoms from a residue. |
|
|
|
|
|
|
|