Skip to content

Io

Reading and writing field of points.

parse_pdb_fop(file_path)

Parse and return the field of points (FOP) stored in a PDB file.

This function reads a PDB file, extracts the XYZ coordinates from lines that start with 'ATOM', and returns them as a list of lists of floats.

PARAMETER DESCRIPTION
file_path

Path to the PDB file containing the field of points.

TYPE: str

RETURNS DESCRIPTION
Sequence[Sequence[float]]

A list of [X, Y, Z] coordinates.

RAISES DESCRIPTION
FileNotFoundError

If the file at the given path does not exist.

ValueError

If the file contains improperly formatted lines.

parse_xyz_fop(file_path)

Reads a filename and parses the field of points (FOP) from an XYZ file format.

This function reads an XYZ file, extracts the XYZ coordinates from the lines, and returns them as a list of lists of floats. The first two lines are typically headers and are skipped.

PARAMETER DESCRIPTION
file_path

Filename of the field of points to open and parse.

TYPE: str

RETURNS DESCRIPTION
Sequence[Sequence[float]]

A list of [X, Y, Z] coordinates.

RAISES DESCRIPTION
FileNotFoundError

If the file at the given path does not exist.

ValueError

If the file contains improperly formatted lines.

points_to_pdb(file_path, fop_input)

Writes a PDB file full of C-alphas so users can visualize the field of points in software such as VMD.

This function creates a PDB file with each point represented as a C-alpha (CA) atom, allowing for visualization in molecular visualization software. The function supports creating a multiframe PDB file if the input sequence contains multiple frames of points.

PARAMETER DESCRIPTION
file_path

Name of the PDB file to create.

TYPE: str

fop_input

Field of points XYZ coordinates. Can contain multiple frames of points.

TYPE: Sequence[Sequence[float]] | Sequence[Sequence[Sequence[float]]]

points_to_xyz(file_path, fop_input)

Writes an XYZ file that users can load into visualization software such as VMD.

This function creates an XYZ file with each point represented as a CA atom, allowing for visualization in molecular visualization software. The function supports creating a multiframe XYZ file if the input sequence contains multiple frames of points.

PARAMETER DESCRIPTION
file_path

Name for the XYZ file to be created.

TYPE: str

fop

Contains XYZ coordinates for each atom. Can be a 2D list (single frame) or a 3D list (multiple frames).

read_fop(file_path)

Load field of points (FOP) from supported file types (.xyz or .pdb).

This function determines the file type based on the file extension and calls the appropriate parsing function to load the field of points.

PARAMETER DESCRIPTION
file_path

Path to the .xyz or .pdb file containing the field of points.

TYPE: str

RETURNS DESCRIPTION
Sequence[Sequence[float]]

A list of [X, Y, Z] coordinates.

RAISES DESCRIPTION
ValueError

If the file extension is not supported.

FileNotFoundError

If the file at the given path does not exist.

ValueError

If the file contains improperly formatted lines.

write_fop(fop, f_path, data_dir=None)

Writes the field of points (FOP) to a file in either XYZ or PDB format.

This function saves the given field of points to a specified file path. It supports both XYZ and PDB file formats and can handle both single-frame and multi-frame data.

PARAMETER DESCRIPTION
fop

Field of points XYZ coordinates. Can be a 2D list (single frame) or a 3D list (multiple frames).

TYPE: Sequence[Sequence[float]] | Sequence[Sequence[Sequence[float]]]

f_path

File path where the FOP should be saved. The file extension must be either .xyz or .pdb.

TYPE: str

data_dir

Directory to save the file in. If None, the file will be saved in the current directory.

TYPE: str | None DEFAULT: None

RAISES DESCRIPTION
ValueError

If the file extension is not .xyz or .pdb.