Skip to content

Io

Handle IO of auxillary data.

load_data(subpex_config, data_dir=None)

Populate subpex_config auxillary data with the last value found in data_dir.

Calls

PARAMETER DESCRIPTION
subpex_config

The Subpex configuration.

TYPE: SubpexConfig

data_dir

Directory to search for auxillary data files. If None, then no data is appended to subpex_config.

TYPE: str | None DEFAULT: None

RETURNS DESCRIPTION
SubpexConfig

The updated SubpexConfig object with the last value of data found appended to

SubpexConfig

the respective auxiliary data.

write_data(subpex_config, data_dir=None)

Writes activated auxiliary data from the subpex_config to files in the specified directory.

This function iterates through the active auxiliary data in the provided subpex_config and writes them to files in the data_dir. The format of the output files is determined by their extensions:

  • .xyz and .pdb: The data is expected to be a field of points and is written using the write_fop function.
  • .txt: The data is written as plain text. If the data consists of floats, each value is written on a new line. If the data is iterable (e.g., a list of lists), each sublist is written on a new line, with values formatted to four decimal places and separated by spaces.
PARAMETER DESCRIPTION
subpex_config

The Subpex configuration object containing auxiliary data to be written to files.

TYPE: SubpexConfig

data_dir

The directory where the data files will be written. If None, an empty string is used as the directory.

TYPE: str | None DEFAULT: None

Warning
  • If the file extension is not supported (.xyz, .pdb, or .txt), the function logs a warning and skips writing the data.
  • If the data type does not match the expected format for a given file extension, the function logs a warning and skips writing the data.
  • If the data type is not accounted for, the function logs a warning and skips writing the data.
Example
subpex_config = SubpexConfig(...)
write_data(subpex_config, data_dir="/path/to/data")