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: BaseModel

Configuration 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:

  1. Values from the configuration file (--config) are loaded first.

  2. Explicit CLI arguments override values from the config file.

  3. 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 .pdb or .cif. Defaults to output.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:

True if logging is configured for stdout, False if 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 config parameter, 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 and None is returned. Otherwise, the value of logger is interpreted as a file path.

Returns:

Path to the log file, or None if 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 .pdb or .cif, it is treated as a local file path and converted to pathlib.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 .pdb or .cif and converts string paths to pathlib.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

__init__(**data)

Create a new model by parsing and validating input data from keyword arguments.

construct([_fields_set])

copy(*[, include, exclude, update, deep])

Returns a copy of the model.

dict(*[, include, exclude, by_alias, ...])

dump_resolved_config()

Serialize the resolved configuration to YAML.

from_orm(obj)

is_console_logging()

Determine whether logging should be directed to the console.

json(*[, include, exclude, by_alias, ...])

load_config_file(values)

Load and merge a YAML or JSON configuration file.

log_file_path()

Return the log file path if file logging is enabled.

model_construct([_fields_set])

Creates a new instance of the Model class with validated data.

model_copy(*[, update, deep])

!!! abstract "Usage Documentation"

model_dump(*[, mode, include, exclude, ...])

!!! abstract "Usage Documentation"

model_dump_json(*[, indent, ensure_ascii, ...])

!!! abstract "Usage Documentation"

model_json_schema(by_alias, ref_template, ...)

Generates a JSON schema for a model class.

model_parametrized_name(params)

Compute the class name for parametrizations of generic classes.

model_post_init(context, /)

Override this method to perform additional initialization after __init__ and model_construct.

model_rebuild(*[, force, raise_errors, ...])

Try to rebuild the pydantic-core schema for the model.

model_validate(obj, *[, strict, extra, ...])

Validate a pydantic model instance.

model_validate_json(json_data, *[, strict, ...])

!!! abstract "Usage Documentation"

model_validate_strings(obj, *[, strict, ...])

Validate the given object with string data against the Pydantic model.

parse_file(path, *[, content_type, ...])

parse_obj(obj)

parse_raw(b, *[, content_type, encoding, ...])

schema([by_alias, ref_template])

schema_json(*[, by_alias, ref_template])

update_forward_refs(**localns)

validate(value)

validate_file_input(inp)

Validate the input structure source.

validate_input_modification(input_modification)

Normalize modification input to a list of strings.

validate_output(out)

Validate and normalize the output structure path.