Trajectory class¶
- class chemfiles.Trajectory(path, mode='r', format='')¶
A
Trajectory
represent a physical file from which we can readFrame
.Open the file at the given
path
using the givenmode
and optional fileformat
.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 correspondingFrame
.
- read_step(step)¶
Read a specific
step
in thisTrajectory
and return the correspondingFrame
.
- set_cell(cell)¶
Set the
UnitCell
associated with thisTrajectory
to a copy ofcell
.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 thisTrajectory
.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 aTopology
instance, it is used directly. If thetopology
parameter is a string, the firstFrame
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 thisTrajectory
.
- 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'
), thedata
parameter will be used as the formatted file.When writing (
mode
is'w'
), thedata
parameter is ignored. To get the memory buffer containing everything already written, use thebuffer()
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 correspondingFrame
.
- read_step(step)¶
Read a specific
step
in thisTrajectory
and return the correspondingFrame
.
- set_cell(cell)¶
Set the
UnitCell
associated with thisTrajectory
to a copy ofcell
.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 thisTrajectory
.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 aTopology
instance, it is used directly. If thetopology
parameter is a string, the firstFrame
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 thisTrajectory
.