Coverage for local_installation/dynasor/trajectory/abstract_trajectory_reader.py: 77%
13 statements
« prev ^ index » next coverage.py v7.3.2, created at 2024-09-27 15:43 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2024-09-27 15:43 +0000
1from abc import ABC, abstractmethod
4class AbstractTrajectoryReader(ABC):
5 """Provides a way to iterate through a molecular dynamics (MD) trajectory
6 file.
8 Each frame/time-step is returned as a trajectory_frame.
9 """
11 # unit conversion tables
12 lengthunits_to_nm_table = {
13 'Angstrom': 1.0,
14 'nm': 10.0,
15 'pm': 1e3,
16 'fm': 1e6,
17 }
19 timeunits_to_fs_table = {
20 'fs': 1.0,
21 'ps': 1000,
22 'ns': 1000000,
23 }
25 @abstractmethod
26 def __iter__(self):
27 """ Iterates through the trajectory file, frame by frame. """
28 pass
30 @abstractmethod
31 def __next__(self):
32 """ Gets next trajectory frame. """
33 pass
35 @abstractmethod
36 def close(self):
37 """ Closes down, release resources etc. """
38 pass