# mdtraj.formats.BINPOSTrajectoryFile¶

class mdtraj.formats.BINPOSTrajectoryFile(filename, mode='r', force_overwrite=True, **kwargs)

Interface for reading and writing to an AMBER BINPOS file. This is a file-like object, that both reading or writing depending on the mode flag. It implements the context manager protocol, so you can also use it with the python ‘with’ statement.

The conventional units in the BINPOS file are angstroms. The format only supports storing the cartesian coordinates.

Parameters
filenamestr

The filename to open. A path to a file on disk.

mode{‘r’, ‘w’}

The mode in which to open the file, either ‘r’ for read or ‘w’ for write.

force_overwritebool

If opened in write mode, and a file by the name of filename already exists on disk, should we overwrite it?

Other Parameters
min_chunk_sizeint, default=100

BINPOS, In read mode, we need to allocate a buffer in which to store the data without knowing how many frames are in the file. This parameter is the minimum size of the buffer to allocate.

chunk_size_multiplierint, default=1.5

In read mode, we need to allocate a buffer in which to store the data without knowing how many frames are in the file. We can guess this information based on the size of the file on disk, but it’s not perfect. This parameter inflates the guess by a multiplicative factor.

mdtraj.load_binpos

High-level wrapper that returns a md.Trajectory

Examples

>>> # copy data from one file to another
>>> with BINPOSTrajectoryFile('traj.binpos') as f:
>>> with BINPOSTrajectoryFile('out.binpos') as f:
>>>    f.write(xyz)

Attributes
distance_unit

Methods

 close() Close the BINPOS file read([n_frames, stride, atom_indices]) Read data from a BINPOS file read_as_traj(topology[, n_frames, stride, …]) Read a trajectory from a BINPOS file seek(offset[, whence]) Move to a new file position tell() Current file position write(xyz) Write cartesian coordinates to a binpos file
__init__(self, /, \*args, \*\*kwargs)

Initialize self. See help(type(self)) for accurate signature.

Methods

 __init__(self, /, \*args, \*\*kwargs) Initialize self. close() Close the BINPOS file read([n_frames, stride, atom_indices]) Read data from a BINPOS file read_as_traj(topology[, n_frames, stride, …]) Read a trajectory from a BINPOS file seek(offset[, whence]) Move to a new file position tell() Current file position write(xyz) Write cartesian coordinates to a binpos file

Attributes

 distance_unit