Trajectory class¶
-
class
chemfiles.Trajectory(path, mode='r', format='')¶ A
Trajectoryis a chemistry file on the hard drive. It is the main entry point of Chemfiles.Open the
Trajectoryat the givenpathusing the givenmodeand 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
Trajectoryand write any buffered content to the hard drive.
-
property
nsteps¶ Get the number of steps (the number of frames) in a
Trajectory.
-
property
path¶ Get the path used to open this
Trajectory.
-
read()¶ Read the next step of the
Trajectoryand return the correspondingFrame.
-
read_step(step)¶ Read a specific
stepin theTrajectoryand return the correspondingFrame.
-
set_cell(cell)¶ Set the
UnitCellassociated with aTrajectory. ThisUnitCellwill be used when reading and writing the files, replacing anyUnitCellin the frames or files.
-
set_topology(topology, format='')¶ Set the
Topologyassociated with aTrajectory. ThisTopologywill be used when reading and writing the files, replacing anyTopologyin the frames or files.If
topologyis aTopologyinstance, it is used directly. Iftopologyis a string, the firstFrameof the corresponding file is read, and the topology of this frame is used.When reading from a file, if
formatis not the empty string, the code uses this file format instead of guessing it from the file extension.
-
write(frame)¶ Write a
Frameto theTrajectory.
-