molgri.molecules.writers
Write pseudo-trajectories to files.
This module contains PtWriter object to write Pseudotrajectories to trajectory/topology files and a PtIOManager that is a high-level function combining: parsing from input files, creating grids and writing the outputs.
Classes
|
This class gets only strings as inputs - what a user is expected to provide. |
|
This class writes a pseudotrajectory to a file. |
- class molgri.molecules.writers.PtIOManager(name_central_molecule: str, name_rotating_molecule: str, o_grid_name: str, b_grid_name: str, t_grid_name: str, output_name: str | None = None)
This class gets only strings as inputs - what a user is expected to provide. The first two strings determine where to find input molecular structures, last three how to construct a full grid. This object manages Parsers and Writers that provide a smooth input/output to a Pseudotrajectory.
- Args:
- name_central_molecule: name of the molecule that stays fixed (with or without extension,
should be located in the input/ folder)
- name_rotating_molecule: name of the molecule that moves in a pseudotrajectory (with or without extension,
should be located in the input/ folder)
- o_grid_name: name of the grid for rotations around the origin in form ‘algorithm_num’ (eg. ‘ico_50) OR
in form ‘num’ (eg. ‘50’) OR as string ‘zero’ or ‘None’ if no rotations needed
- b_grid_name: name of the grid for rotations around the body in form ‘algorithm_num’ (eg. ‘ico_50) OR
in form ‘num’ (eg. ‘50’) OR as string ‘zero’ or ‘None’ if no rotations needed
- t_grid_name: translation grid that will be forwarded to TranslationParser, can be a list of numbers,
a range or linspace function inside a string
output_name: select the name under which all associated files will be saved (if None use names of molecules)
- __init__(name_central_molecule: str, name_rotating_molecule: str, o_grid_name: str, b_grid_name: str, t_grid_name: str, output_name: str | None = None)
This class gets only strings as inputs - what a user is expected to provide. The first two strings determine where to find input molecular structures, last three how to construct a full grid. This object manages Parsers and Writers that provide a smooth input/output to a Pseudotrajectory.
- Args:
- name_central_molecule: name of the molecule that stays fixed (with or without extension,
should be located in the input/ folder)
- name_rotating_molecule: name of the molecule that moves in a pseudotrajectory (with or without extension,
should be located in the input/ folder)
- o_grid_name: name of the grid for rotations around the origin in form ‘algorithm_num’ (eg. ‘ico_50) OR
in form ‘num’ (eg. ‘50’) OR as string ‘zero’ or ‘None’ if no rotations needed
- b_grid_name: name of the grid for rotations around the body in form ‘algorithm_num’ (eg. ‘ico_50) OR
in form ‘num’ (eg. ‘50’) OR as string ‘zero’ or ‘None’ if no rotations needed
- t_grid_name: translation grid that will be forwarded to TranslationParser, can be a list of numbers,
a range or linspace function inside a string
output_name: select the name under which all associated files will be saved (if None use names of molecules)
- get_decorator_name() str
- get_name()
- determine_pt_name() str
Determine the base name of pseudotrajectory file/directory without any paths or extensions.
- Returns:
PT name, eg H2O_CL_o_ico_15_b_cube3D_45_t_123456
- construct_pt(extension_trajectory: str = 'xtc', extension_structure: str = 'gro', as_dir: bool = False, print_messages=False)
The highest-level method to be called in order to generate and save a pseudotrajectory.
- Args:
extension_trajectory: what extension to provide to the trajectory file extension_structure: what extension to provide to the structure (topology) file as_dir: if True, don’t save trajectory in one file but split it in frames
- construct_pt_and_time(**kwargs)
Same as construct_pt, but time the execution and write out a message about duration.
- Args:
see construct_pt
- class molgri.molecules.writers.PtWriter(name_to_save: str, parsed_central_molecule: ParsedMolecule)
This class writes a pseudotrajectory to a file. A PT consists of one molecule that is stationary at origin and one that moves with every time step. The fixed molecule is provided when the class is created and the mobile molecule as a generator when the method write_full_pt is called. Writing is done with MDAnalysis module, so all formats implemented there are supported.
- Args:
name_to_save: base name of the PT file without paths or extensions parsed_central_molecule: a ParsedMolecule object describing the central molecule, will only be translated
so that COM lies at (0, 0, 0) but not manipulated in any other way.
- __init__(name_to_save: str, parsed_central_molecule: ParsedMolecule)
This class writes a pseudotrajectory to a file. A PT consists of one molecule that is stationary at origin and one that moves with every time step. The fixed molecule is provided when the class is created and the mobile molecule as a generator when the method write_full_pt is called. Writing is done with MDAnalysis module, so all formats implemented there are supported.
- Args:
name_to_save: base name of the PT file without paths or extensions parsed_central_molecule: a ParsedMolecule object describing the central molecule, will only be translated
so that COM lies at (0, 0, 0) but not manipulated in any other way.
- write_structure(pt: Pseudotrajectory, path_structure: str)
Write the one-frame topology file, eg in .gro format.
- Args:
pt: a Pseudotrajectory object with method .get_molecule() that returns current ParsedMolecule path_structure: where topology should be saved
- write_full_pt(pt: Pseudotrajectory, path_trajectory: str, path_structure: str)
Write the trajectory file as well as the structure file (only at the first time-step).
- Args:
pt: a Pseudotrajectory object with method .generate_pseudotrajectory() that generates ParsedMolecule objects path_trajectory: where trajectory should be saved path_structure: where topology should be saved
- write_frames_in_directory(pt: Pseudotrajectory, path_trajectory: str, path_structure: str)
As an alternative to saving a full PT in a single trajectory file, you can create a directory with the same name and within it single-frame trajectories named with their frame index. Also save the structure file at first step.
pt: a Pseudotrajectory object with method .generate_pseudotrajectory() that generates ParsedMolecule objects path_trajectory: where trajectory should be saved path_structure: where topology should be saved