msd_input_file_reader

A module containing a class to read input files to setup the MSD class.

Summary

Classes:

MSDInputFileReader

A class to read input files to setup the

Reference

class MSDInputFileReader(filename: str)[source]

Bases: _TopologyFilesMixin, PQAnalysisInputFileReader

A class to read input files to setup the MSD class.

For the MSD analysis input file several keys are available of which some are required and some are optional. For more details on the grammar and syntax of the input file see Analysis Input Files.

The following keys are required:

Key

Value

traj_files

The trajectory files to read. This can be a single file or a list of files.

target_selection

The selection string to select the atoms for which the MSD is calculated. For more details see Selection.

out_file

The output file to write the MSD data to. It must not exist yet.

The following keys are optional:

Key

Value

window

The correlation window size in frames. Default is 1000. It has to be an integer multiple of the gap.

gap

The gap between two time origins in frames. Default is 10.

first_frame

The first frame (1-based frame counter) at which processing starts. Default is 0. The key start is an alias for this key (legacy Diffcalc naming).

time_step

The time step between two frames in ps. If given, diffusion coefficients are calculated from a linear fit of the MSD tail and written to the log output. It has to be positive.

fit_window

The number of trailing MSD points used for the diffusion fit. Default is the last 20% of the window. It has to be at least 2 and at most window + 1.

log_file

The log file to write the log information to.

use_full_atom_info

Whether to use full atom information for the selections.

target_com

Whether the targets are the centers of mass of the molecules instead of atoms, so that the MSD and the diffusion coefficients are those of the molecules. The target selection then picks the atoms that define each center. Needs the restart file and the moldescriptor file. Default is false.

restart_file

The restart file that defines the molecules, needed for target_com. Inferred from the first trajectory file if omitted (trajectory.xyz maps to trajectory.rst).

moldescriptor_file

The moldescriptor file with the molecule types, needed for target_com. Inferred from the trajectory directory (moldescriptor.dat) if omitted.

Note

The MSD output file follows the legacy Diffcalc format. See MSD output files for its columns and units.

Parameters:

filename (str) – the filename of the input file

check_known_keys(
known_keys: list[str] | None = None,
)

Checks if all keys in the input file are known.

Parameters:

known_keys (List[str] | None, optional) – the known keys, by default None

Warns:

InputFileWarning – if unknown keys were set in the input file

check_required_keys(
required_keys: list[str],
)

Checks if all required keys are set in the input file.

Parameters:

required_keys (List[str]) – the required keys

Raises:

InputFileError – if not all required keys are set in the input file

not_defined_optional_keys(
optional_keys: list[str],
)

Checks if optional keys are set in the input file. If not set, it sets them to None.

Parameters:

optional_keys (List[str]) – the optional keys

read()[source]

Reads the input file and parses it. It also sets the raw_input_file and the dictionary. It checks if all required keys are set and if all keys are known.

Raises:
  • InputFileError – if not all required keys are set in the input file

  • InputFileWarning – if unknown keys are set in the input file

  • InputFileError – if both the first_frame and the start key are set

  • InputFileError – if the first_frame or start key is negative

  • InputFileError – if the time_step key is not positive

  • InputFileError – if the target_com key is used without a restart file and a moldescriptor file that can be given or inferred

  • InputFileError – if the moldescriptor_file key is used without a restart file

resolve_path(
path: str | None,
) → str | None

Resolves a filename from the input file against the directory of the input file.

Relative filenames in an input file refer to the directory that contains the input file, not to the working directory of the process. Absolute filenames are returned unchanged.

Parameters:

path (str | None) – the filename as written in the input file

Returns:

the resolved filename, or None if path is None

Return type:

str | None

resolve_paths(
paths: list[str] | None,
) → list[str] | None

Resolves a list of filenames with resolve_path().

Parameters:

paths (List[str] | None) – the filenames as written in the input file

Returns:

the resolved filenames, or None if paths is None

Return type:

List[str] | None

property delta_r: PositiveReal | None

The radius step size of the PQAnalysis.

Type:

PositiveReal | None

delta_r_key = 'delta_r'
first_frame_key = 'first_frame'
property fit_window: PositiveInt | None

The number of trailing MSD points to fit.

Type:

PositiveInt | None

fit_window_key = 'fit_window'
property gap: PositiveInt | None

The gap between two time origins in frames.

Type:

PositiveInt | None

gap_key = 'gap'
known_keys = ['r_max', 'r_min', 'delta_r', 'n_bins', 'traj_files', 'selection', 'reference_selection', 'target_selection', 'use_full_atom_info', 'out_file', 'log_file', 'no_intra_molecular', 'reference_com', 'target_com', 'moldescriptor_file', 'restart_file']
property log_file: str | None

The log file of the simulation.

Type:

str | None

log_file_key = 'log_file'
logger = <CustomLogger PQAnalysis.MSDInputFileReader (INFO)>
property moldescriptor_file: str | None

The moldescriptor file of the simulation.

Type:

str | None

moldescriptor_file_key = 'moldescriptor_file'
property n_bins: PositiveInt | None

The number of bins of the PQAnalysis.

Type:

PositiveInt | None

n_bins_key = 'n_bins'
property n_start: int | None

The first frame at which processing starts.

Type:

int | None

property no_intra_molecular: bool | None

Whether intra molecular interactions should be excluded.

Type:

bool | None

no_intra_molecular_key = 'no_intra_molecular'
optional_keys = ['traj_files', 'target_selection', 'out_file', 'window', 'gap', 'first_frame', 'start', 'time_step', 'fit_window', 'log_file', 'use_full_atom_info', 'target_com', 'restart_file', 'moldescriptor_file']

The optional keys of the input file

Type:

List[str]

property out_file: str | None

The out file of the simulation.

Type:

str | None

out_file_key = 'out_file'
property r_max: PositiveReal | None

The maximum radius of the PQAnalysis.

Type:

PositiveReal | None

r_max_key = 'r_max'
property r_min: PositiveReal | None

The minimum radius of the PQAnalysis.

Type:

PositiveReal | None

r_min_key = 'r_min'
property reference_com: bool | None

Whether the reference entities are molecule centers.

Type:

bool | None

reference_com_key = 'reference_com'
property reference_selection: str | None

The reference selection of the simulation.

Type:

str | None

reference_selection_key = 'reference_selection'
required_keys = ['traj_files', 'target_selection', 'out_file']

The required keys of the input file

Type:

List[str]

property restart_file: str | None

The restart file of the simulation.

Type:

str | None

restart_file_key = 'restart_file'
property selection: str | None

The selection of the simulation.

Type:

str | None

selection_key = 'selection'
start_key = 'start'
property target_com: bool | None

Whether the target entities are molecule centers.

Type:

bool | None

target_com_key = 'target_com'
property target_selection: str | None

The target selection of the simulation.

Type:

str | None

target_selection_key = 'target_selection'
property time_step: PositiveReal | None

The time step between two frames in ps.

Type:

PositiveReal | None

time_step_key = 'time_step'
property traj_files: list[str] | None

The trajectory files of the simulation.

Type:

List[str] | None

traj_files_key = 'traj_files'
property use_full_atom_info: bool | None

Whether the full atom information should be used.

Type:

bool | None

use_full_atom_info_key = 'use_full_atom_info'
property window: PositiveInt | None

The correlation window size in frames.

Type:

PositiveInt | None

window_key = 'window'