pywindow.DLPOLY

class pywindow.DLPOLY(filepath)[source]

Bases: Trajectory

A container for a DL_POLY_C type trajectory (HISTORY).

This function takes a DL_POLY_C trajectory file and maps it for the binary points in the file where each frame starts/ends. This way the process is fast, as it not require loading the trajectory into computer memory. When a frame is being extracted, it is only this frame that gets loaded to the memory.

Frames can be accessed individually and loaded as an unmodified string, returned as a pywindow.MolecularSystem (and analysed), dumped as PDB or XYZ or JSON (if dumped as a pywindow.MolecularSystem.system)

Parameters:

filepath (pathlib.Path | str)

filepath

str The filepath.

system_id

str The system id inherited from the filename.

frames

dict A dictionary that is populated, on the fly, with the extracted frames.

analysis_output

dict A dictionary that is populated, on the fly, with the analysis output.

Methods

analysis(frames='all', ncpus=1, ncpus_analysis=1, override=False, modular=False, rebuild=False, swap_atoms=None, forcefield=None)

Perform structural analysis on a frame/ set of frames.

Depending on the passed parameters a frame, a list of particular frames, a range of frames (from, to), or all frames can be analysed with this function.

The analysis is performed on each frame and each discrete molecule in that frame separately. The steps are as follows:

  1. A frame is extracted and returned as a MolecularSystem.

  2. If swap_atoms is set the atom ids are swapped.

  3. If forcefield is set the atom ids are deciphered.

  4. If rebuild is set the molecules in the system are rebuild.

  5. Each discrete molecule is extracted as Molecule

  6. Each molecule is analysed with Molecule.full_analysis()

  7. Analysis output populates the analysis_output dictionary.

As the analysis of trajectories often have to be unique, many options are conditional.

A side effect of this function is that the analysed frames are also returned to the frames mimicking the behaviour of the get_frames().

Parameters:
  • frames (int | list | tuple | str) – int or list or tuple or str Specified frame (int), or frames (list), or range (touple), or all/everything (str). (default=’all’)

  • override (bool) – bool If True, an output already storred in analysis_output can be override. (default=False)

  • swap_atoms (dict | None) – dict, optional If this kwarg is passed with an appropriate dictionary a pywindow.MolecularSystem.swap_atom_keys() will be applied to the extracted frame.

  • forcefield (str | None) – str, optional If this kwarg is passed with appropriate forcefield keyword a pywindow.MolecularSystem.decipher_atom_keys() will be applied to the extracted frame.

  • modular (bool) – bool, optional If this kwarg is passed a pywindow.MolecularSystem.make_modular() will be applied to the extracted frame. (default=False)

  • rebuild (bool) – bool, optional If this kwarg is passed a rebuild=True is passed to pywindow.MolecularSystem.make_modular() that will be applied to the extracted frame. (default=False)

  • ncpus (int) – int, optional If ncpus > 1, then the analysis is performed in parallel for the specified number of parallel jobs. Otherwise, it runs in serial. (default=1)

  • ncpus_analysis (int) – int, optional If ncpus > 1, then the analysis is performed in parallel for the specified number of parallel jobs. Otherwise, it runs in serial. (default=1)

Returns:

NoneType

The function returns None, the analysis output is returned to analysis_output dictionary.

Return type:

None

get_frames(frames='all', override=False, swap_atoms=None, forcefield=None, extract_data=True)

Extract frames from the trajectory file.

Depending on the passed parameters a frame, a list of particular frames, a range of frames (from, to), or all frames can be extracted with this function.

Parameters:
Returns:

Dictionary of frames.

Return type:

dict[int, MolecularSystem]

save_analysis(filepath=None, override=False)

Dump the content of analysis_output as JSON dictionary.

Parameters:
Return type:

None

save_frames(frames='all', filepath=None, decipher=True, swap_atoms=None, forcefield=None)
Parameters:
Return type:

None