ModifierParameters
Module
viennaptm.entrypoints.viennaptm
- class ModifierParameters(*, config: Path | str | None = None, input: Path | str | None = None, modify: list[str] | str | None = None, output: Path | str | None = 'output.pdb', gromacs: GROMACSParameters | None = <factory>, logger: str | None = 'console', debug: bool | None = False, ptm_list: str | None = None)
Bases:
BaseModelConfiguration model for a ViennaPTM command-line run.
This Pydantic model represents the fully resolved configuration used by the ViennaPTM CLI. Parameters can be provided either via command-line arguments or through an external YAML / JSON configuration file.
Configuration resolution follows a strict precedence order:
Values from the configuration file (
--config) are loaded first.Explicit CLI arguments override values from the config file.
The merged configuration is validated and normalized.
Invalid or unknown parameters are rejected.
- Parameters:
config (pathlib.Path or str, optional) – Path to a YAML or JSON configuration file (optional).
input (pathlib.Path or str, optional) – Input structure, either as a local PDB/mmCIF file or a 4-character PDB identifier.
modify (list[str] or str, optional) – One or more residue modification specifications, e.g.,
"A:50=V3H". Multiple modifications can be provided as a list.output (pathlib.Path or str) – Output structure file, must end with
.pdbor.cif. Defaults tooutput.pdb.gromacs (GROMACSParameters) – Nested GROMACS configuration parameters.
logger (str) – Logging destination. Use
"console"for stdout logging or provide a file path to log to a file.debug (bool) – Enable verbose debug logging if
True.
- Raises:
ValueError – If unknown or extra parameters are provided (
extra="forbid").
- config: Path | str | None
- debug: bool | None
- dump_resolved_config() str
Serialize the resolved configuration to YAML.
All paths are converted to strings to ensure clean, human-readable output suitable for logging or inspection.
- Returns:
YAML-formatted configuration string.
- Return type:
str
- gromacs: GROMACSParameters | None
- input: Path | str | None
- is_console_logging() bool
Determine whether logging should be directed to the console.
- Returns:
Trueif logging is configured for stdout,Falseif logging should be written to a file.- Return type:
bool
- classmethod load_config_file(values: Dict[str, Any]) Dict[str, Any]
Load and merge a YAML or JSON configuration file.
If a configuration file is specified via the
configparameter, it is loaded first and used to initialize parameters. Any values provided directly (e.g. via CLI arguments) override those from the config file.- Parameters:
values (dict) – Raw keyword arguments passed to the model constructor.
- Returns:
Merged parameter dictionary with CLI values taking precedence.
- Return type:
dict
- Raises:
ValueError – If the config file does not exist, has an unsupported extension, or does not contain a top-level mapping.
- log_file_path() Path | None
Return the log file path if file logging is enabled.
When logging is set to
"console", no log file is used andNoneis returned. Otherwise, the value ofloggeris interpreted as a file path.- Returns:
Path to the log file, or
Noneif console logging is enabled.- Return type:
pathlib.Path or None
- logger: str | None
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- modify: list[str] | str | None
- output: Path | str | None
- ptm_list: str | None
- classmethod validate_file_input(inp: Path | str)
Validate the input structure source.
If the input is a string ending with
.pdbor.cif, it is treated as a local file path and converted topathlib.Path. Otherwise, it is interpreted as a PDB database identifier and must be exactly four characters long.- Parameters:
inp (pathlib.Path or str) – Input path or PDB identifier.
- Returns:
Validated input value.
- Return type:
pathlib.Path or str
- Raises:
ValueError – If a non-file string input does not conform to the 4-character PDB identifier format.
- classmethod validate_input_modification(input_modification: list[str] | str) list[str]
Normalize modification input to a list of strings.
Single modification specifications are automatically wrapped into a list to ensure consistent downstream handling.
- Parameters:
input_modification (str or list[str]) – Modification specification(s).
- Returns:
List of modification strings.
- Return type:
list[str]
- classmethod validate_output(out: Path | str) Path
Validate and normalize the output structure path.
Ensures that the output filename ends with
.pdbor.cifand converts string paths topathlib.Path.- Parameters:
out (pathlib.Path or str) – Output path or filename.
- Returns:
Validated output path.
- Return type:
pathlib.Path
- Raises:
ValueError – If the output file extension is not supported.
Methods
|
Create a new model by parsing and validating input data from keyword arguments. |
|
|
|
Returns a copy of the model. |
|
|
Serialize the resolved configuration to YAML. |
|
|
|
Determine whether logging should be directed to the console. |
|
|
|
|
Load and merge a YAML or JSON configuration file. |
Return the log file path if file logging is enabled. |
|
|
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. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Validate the input structure source. |
|
Normalize modification input to a list of strings. |
|
Validate and normalize the output structure path. |