Skip to content

Io

write_pdbs

A class for converting numpy arrays into PDB-formatted strings.

__create_pdb_line(numpy_array, index, resname, letter)

Create a string formatted according to the PDB standard.

PARAMETER DESCRIPTION

numpy_array

A 1x3 np.array representing a 3D point.

index

An integer, the atom index to use in the string.

resname

A string, the RESNAME to use.

letter

A string, the atom name/chain/etc to use for the output.

RETURNS DESCRIPTION

A string, formatted according to the PDB standard.

numpy_to_pdb(narray, letter, resname='')

Create a string formatted according to the PDB standard.

Args: narray: A nx3 np.array representing a 3D point. letter: A string, the atom name/chain/etc to use for the output. resname: An optional string, the RESNAME to use for the output.

Returns: A string, formatted according to the PDB standard.

create_pdb_line(numpy_array, index, resname, letter)

Create a string formatted according to the PDB standard.

PARAMETER DESCRIPTION

numpy_array

A 1x3 np.array representing a 3D point.

letter

A string, the atom name/chain/etc to use for the output.

RETURNS DESCRIPTION

A string, formatted according to the PDB standard.

dx_freq(freq_mat, output_prefix, config)

Generates a DX file that records the frequency that a volume element is open.

PARAMETER DESCRIPTION

freq_mat

a Nx4 matrix, where the first 3 columns are the x,y,z coords of the point, and the 4th column is the frequency of emptiness for that point in space

TYPE: NDArray[float64]

fix_filename(path, must_exist=True)

Returns a standardized Path object, handling both Windows and Unix-formatted paths.

PARAMETER DESCRIPTION

path

The file path to standardize.

TYPE: str

must_exist

If True, verifies that the path exists.

TYPE: bool DEFAULT: True

RAISES DESCRIPTION
FileNotFoundError

If the path does not exist and must_exist is True.

ValueError

If the path format is invalid.

RETURNS DESCRIPTION
Path

A pathlib.Path object representing the standardized path.

TYPE: Path

gzopenfile(path, mode='r')

Opens a gz compressed file, regardless of whether unix or windows formatted path.

PARAMETER DESCRIPTION

path

A string, the path.

mode

A string, the file mode. Defaults to "r".

DEFAULT: 'r'

RETURNS DESCRIPTION

The file object.

numpy_to_pdb(narray, letter, resname='')

Create a string formatted according to the PDB standard.

PARAMETER DESCRIPTION

narray

A nx3 np.array representing a 3D point.

letter

A string, the atom name/chain/etc to use for the output.

RETURNS DESCRIPTION

A string, formatted according to the PDB standard.

openfile(path, mode='r')

Opens a file, regardless of whether unix or windows formatted path.

PARAMETER DESCRIPTION

path

A string, the path.

mode

A string, the file mode. Defaults to "r".

DEFAULT: 'r'

RETURNS DESCRIPTION

The file object.

write_to_file(fo, s, encode=True)

Writes to a file, encoding if necessary.

PARAMETER DESCRIPTION

fo

The file object.

s

The string to write.

encode

Whether to encode the file before writing. Defaults to True.

TYPE: bool DEFAULT: True