Input/Output & Utilities
File handling and helper functions.
- class ensemble_analyzer.io_utils.SerialiseEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
Custom JSON Encoder for Ensemble Analyzer objects.
Handles serialization of: - NumPy arrays (converted to lists). - NumPy numeric types (converted to Python scalars). - NaN / Inf floats (converted to None). - Complex numbers (converted to [real, imag]). - Custom objects with ‘__dict__’ (via obj.__dict__).
- ensemble_analyzer.io_utils.mkdir(directory: str) bool[source]
Create a directory, ensuring parent directories exist.
- Parameters:
directory (str) – Path of the folder to be created.
- Returns:
True if creation was successful (or directory already exists).
- Return type:
bool
- ensemble_analyzer.io_utils.move_files(conf: Conformer, protocol: Protocol, label: str) None[source]
Move calculation output files to the conformer’s specific folder.
Identifies files generated by the calculator (based on label) and moves them to conf_X/protocol_Y/.
- Parameters:
conf (Conformer) – The conformer instance associated with the files.
protocol (Protocol) – The protocol instance defining the step.
label (str) – The calculator label used as a prefix/suffix for files.
- Returns:
None
- ensemble_analyzer.io_utils.tail(file_path: str, num_lines: int = 100) str[source]
Read the last N lines of a file.
Useful for extracting summary information from large log files.
- Parameters:
file_path (str) – Path to the file.
num_lines (int, optional) – Number of lines to read from the end. Defaults to 100.
- Returns:
The tail of the file content as a single string.
- Return type:
str