Trajectory class¶
-
class
chemfiles.
Trajectory
(path, mode='r', format='')¶ A
Trajectory
is a chemistry file on the hard drive. It is the main entry point of Chemfiles.Open the
Trajectory
at the givenpath
using the givenmode
and optional specific fileformat
.Valid modes are
'r'
for read,'w'
for write and'a'
for append.The specific file format 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 the
Trajectory
and write any buffered content to the hard drive.
-
nsteps
¶ Get the number of steps (the number of frames) in a
Trajectory
.
-
path
¶ Get the path used to open this
Trajectory
.
-
read
()¶ Read the next step of the
Trajectory
and return the correspondingFrame
.
-
read_step
(step)¶ Read a specific
step
in theTrajectory
and return the correspondingFrame
.
-
set_cell
(cell)¶ Set the
UnitCell
associated with aTrajectory
. ThisUnitCell
will be used when reading and writing the files, replacing anyUnitCell
in the frames or files.
-
set_topology
(topology, format='')¶ Set the
Topology
associated with aTrajectory
. ThisTopology
will be used when reading and writing the files, replacing anyTopology
in the frames or files.If
topology
is aTopology
instance, it is used directly. Iftopology
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, the code uses this file format instead of guessing it from the file extension.
-
write
(frame)¶ Write a
Frame
to theTrajectory
.
-