frame_reader

A module containing classes for reading a frame from a string.

Summary

Classes:

BaseFrameReader

Base class for frame readers.

ExtXYZFrameReader

A frame reader for extended xyz position frames.

XYZFrameReader

This class provides methods for reading a frame from a string.

Functions:

get_frame_reader

Return the frame reader implementation for a trajectory format.

Reference

class BaseFrameReader(
md_format: MDEngineFormat | str = MDEngineFormat.PQ,
)[source]

Bases: ABC

Base class for frame readers.

Subclasses implement the parsing for a concrete frame format while this class provides shared MD-engine handling and topology construction.

Parameters:

md_format (MDEngineFormat | str, optional) – The format of the MD engine. Default is “PQ”.

abstractmethod read(
frame_string: str,
topology: Topology | None = None,
traj_format: TrajectoryFormat | str = TrajectoryFormat.XYZ,
) AtomicSystem[source]

Reads a frame from a string.

logger = <CustomLogger PQAnalysis.BaseFrameReader (INFO)>
class ExtXYZFrameReader(
md_format: MDEngineFormat | str = MDEngineFormat.PQ,
)[source]

Bases: BaseFrameReader

A frame reader for extended xyz position frames.

Parameters:

md_format (MDEngineFormat | str, optional) – The format of the MD engine. Default is “PQ”.

read(
frame_string: str,
topology: Topology | None = None,
traj_format: TrajectoryFormat | str = TrajectoryFormat.EXTXYZ,
) AtomicSystem[source]

Reads an extended xyz frame from a string.

logger = <CustomLogger PQAnalysis.ExtXYZFrameReader (INFO)>
class XYZFrameReader(
md_format: MDEngineFormat | str = MDEngineFormat.PQ,
)[source]

Bases: BaseFrameReader

This class provides methods for reading a frame from a string. The string can be a single frame or a whole trajectory. The format of the string can be specified with the format parameter. Generally, this class should not be used directly. Instead, the TrajectoryReader class can be used to read a whole trajectory as well as a single frame from a file.

For more information about the format of the string, see TrajectoryFormat.

Parameters:

md_format (MDEngineFormat | str, optional) – The format of the MD engine. Default is “PQ”.

read(
frame_string: str,
topology: Topology | None = None,
traj_format: TrajectoryFormat | str = TrajectoryFormat.XYZ,
) AtomicSystem[source]

Reads a frame from a string.

Parameters:
  • frame_string (str) – The string to read the frame from.

  • topology (Topology | None, optional) – The topology of the frame. Default is None.

  • traj_format (TrajectoryFormat | str, optional) – The format of the trajectory. Default is TrajectoryFormat.XYZ.

Returns:

The frame read from the string.

Return type:

AtomicSystem

Raises:

FrameReaderError – If the given format is not valid.

read_charges(
frame_string: str,
) AtomicSystem[source]

Reads the charge values of the atoms in a frame from a string.

Parameters:

frame_string (str) – The string to read the frame from.

Returns:

The frame read from the string.

Return type:

AtomicSystem

read_forces(
frame_string: str,
) AtomicSystem[source]

Reads the forces of the atoms in a frame from a string.

Parameters:

frame_string (str) – The string to read the frame from.

Returns:

The frame read from the string.

Return type:

AtomicSystem

read_positions(
frame_string: str,
) AtomicSystem[source]

Reads the positions of the atoms in a frame from a string.

Parameters:

frame_string (str) – The string to read the frame from.

Returns:

The frame read from the string.

Return type:

AtomicSystem

read_velocities(
frame_string: str,
) AtomicSystem[source]

Reads the velocities of the atoms in a frame from a string.

Parameters:

frame_string (str) – The string to read the frame from.

Returns:

The frame read from the string.

Return type:

AtomicSystem

logger = <CustomLogger PQAnalysis.XYZFrameReader (INFO)>
get_frame_reader(
traj_format: TrajectoryFormat | str,
md_format: MDEngineFormat | str = MDEngineFormat.PQ,
)[source]

Return the frame reader implementation for a trajectory format.