Trajectory type and associated functions

type Trajectory

A Trajectory represents a simulation file on the hard drive. It can read or write one or many Frame to this file. The file format can be automatically determined from the extention, or manually specified. Writing to a Trajectory is buffered, which means that one needs to close() the trajectory and flush the buffer before being able to read the file again.

function Trajectory(ptr::Ptr{lib.CHFL_TRAJECTORY})
A Trajectory represents a simulation file on the hard drive. It can read or write one or many Frame to this file. The file format can be automatically determined from the extention, or manually specified. Writing to a Trajectory is buffered, which means that one needs to close() the trajectory and flush the buffer before being able to read the file again.
function Trajectory(path::AbstractString, mode::Char = r, format::AbstractString = "")
The Trajectory function open a trajectory file, using the file at the given path. The opening mode can be 'r' for read, 'w' for write or 'a' for append, and defaults to 'r'. The optional format parameter give a specific file format to use when opening the file.
function read(trajectory::Trajectory)
Read the next step of the trajectory, and return the corresponding Frame.
function read!(trajectory::Trajectory, frame::Frame)
Read the next step of the trajectory in the given frame.
function read_step(trajectory::Trajectory, step::Integer)
Read the given step of the trajectory, and return the corresponding Frame.
function read_step!(trajectory::Trajectory, step::Integer, frame::Frame)
Read the given step of the trajectory in the given frame.
function write(trajectory::Trajectory, frame::Frame)
Write the given frame to the trajectory.
function set_topology!(trajectory::Trajectory, topology::Topology)
Set the Topology associated with a trajectory. This topology will be used when reading and writing the files, replacing any topology in the file.
function set_topology!(trajectory::Trajectory, path::AbstractString, format::AbstractString = "")
Set the Topology associated with a trajectory by reading the first frame of the file at path; and extracting the topology of this frame. The optional format parameter can be used to specify the file format.
function set_cell!(trajectory::Trajectory, cell::UnitCell)
Set the cell associated with a trajectory. This cell will be used when reading and writing the files, replacing any unit cell in the file.
function nsteps(trajectory::Trajectory)
Get the number of steps (the number of frames) in a trajectory.
function close(trajectory::Trajectory)
Close a trajectory, flushing any buffer content to the hard drive, and freeing the associated memory. Necessary when running on the REPL to finish writing.
function isopen(trajectory::Trajectory)
Check is the trajectory is open