Trajectory class

class chemfiles.Trajectory(path, mode='r', format='')

A Trajectory represent a physical file from which we can read Frame.

Open the file at the given path using the given mode and optional file format.

Valid modes are 'r' for read, 'w' for write and 'a' for append.

The format parameter is needed when the file format does not match the extension, or when there is not standard extension for this format. If format is an empty string, the format will be guessed from the file extension.

close()

Close this Trajectory and write any buffered content to the file.

property ffi

Allow to access the C interface from any instance of CxxPointer

classmethod from_const_ptr(origin, ptr)

Create a new instance from a const pointer

classmethod from_mutable_ptr(origin, ptr)

Create a new instance from a mutable pointer

property mut_ptr

Get the mutable C++ pointer for this object

property nsteps

Get the current number of steps in this Trajectory.

property path

Get the path used to open this Trajectory.

property ptr

Get the const C++ pointer for this object

read()

Read the next step of this Trajectory and return the corresponding Frame.

read_step(step)

Read a specific step in this Trajectory and return the corresponding Frame.

set_cell(cell)

Set the UnitCell associated with this Trajectory to a copy of cell.

This UnitCell will be used when reading and writing the files, replacing any unit cell in the frames or files.

set_topology(topology, format='')

Set the Topology associated with this Trajectory.

The new topology will be used when reading and writing the files, replacing any topology in the frames or files.

If the topology parameter is a Topology instance, it is used directly. If the topology parameter is a string, the first Frame of the corresponding file is read, and the topology of this frame is used.

When reading from a file, if format is not the empty string, it is used as the file format instead of guessing it from the file extension.

write(frame)

Write a Frame to this Trajectory.

class chemfiles.MemoryTrajectory(data='', mode='r', format='')

A MemoryTrajectory allow to read/write in-memory data as though it was a formatted file.

The format parameter is always required.

When reading (mode is 'r'), the data parameter will be used as the formatted file.

When writing (mode is 'w'), the data parameter is ignored. To get the memory buffer containing everything already written, use the buffer() function.

buffer()

Get the data written to this in-memory trajectory. This is not valid to call when reading in-memory data.

close()

Close this Trajectory and write any buffered content to the file.

property ffi

Allow to access the C interface from any instance of CxxPointer

classmethod from_const_ptr(origin, ptr)

Create a new instance from a const pointer

classmethod from_mutable_ptr(origin, ptr)

Create a new instance from a mutable pointer

property mut_ptr

Get the mutable C++ pointer for this object

property nsteps

Get the current number of steps in this Trajectory.

property path

Get the path used to open this Trajectory.

property ptr

Get the const C++ pointer for this object

read()

Read the next step of this Trajectory and return the corresponding Frame.

read_step(step)

Read a specific step in this Trajectory and return the corresponding Frame.

set_cell(cell)

Set the UnitCell associated with this Trajectory to a copy of cell.

This UnitCell will be used when reading and writing the files, replacing any unit cell in the frames or files.

set_topology(topology, format='')

Set the Topology associated with this Trajectory.

The new topology will be used when reading and writing the files, replacing any topology in the frames or files.

If the topology parameter is a Topology instance, it is used directly. If the topology parameter is a string, the first Frame of the corresponding file is read, and the topology of this frame is used.

When reading from a file, if format is not the empty string, it is used as the file format instead of guessing it from the file extension.

write(frame)

Write a Frame to this Trajectory.