Trajectory

Chemfiles.TrajectoryType

A Trajectory represents a simulation file on the hard drive. It can read or write one or many Frames 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.

source
Chemfiles.TrajectoryType
Trajectory(path::AbstractString) -> Trajectory
Trajectory(path::AbstractString, mode::Char) -> Trajectory
Trajectory(
    path::AbstractString,
    mode::Char,
    format::AbstractString
) -> Trajectory

Opens the trajectory 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.

source
Chemfiles.TrajectoryMethod
Trajectory(f::Function, args...) -> Any

Apply the function f to the result of Trajectory(args...) and close the resulting trajectory upon completion, similar to open(f, args...).

source
Base.closeMethod
close(trajectory::Trajectory)

Close a trajectory. This function flushes any buffer content to the hard drive, and frees the associated memory. Necessary when running on the REPL to finish writing.

source
Base.isopenMethod
isopen(trajectory::Trajectory) -> Bool

Check if the trajectory is open.

source
Base.lengthMethod
length(trajectory::Trajectory) -> UInt64

Get the number of steps (the number of frames) in a trajectory.

source
Base.read!Method
read!(trajectory::Trajectory, frame::Frame)

Read the next step of the trajectory data into the preexisting Frame structure.

source
Base.readMethod
read(trajectory::Trajectory) -> Frame

Read the next step of the trajectory, and return the corresponding Frame.

source
Base.sizeMethod
size(trajectory::Trajectory) -> UInt64

Get the number of steps (the number of frames) in a trajectory.

source
Base.take!Method
take!(trajectory::Trajectory) -> Vector{UInt8}

Obtain the memory buffer of a in-memory trajectory writer as a Vector{UInt8}, without copying.

If more data is written to the trajectory, the buffer is invalidated.

source
Base.writeMethod
write(trajectory::Trajectory, frame::Frame)

Write the given frame to the trajectory.

source
Chemfiles.MemoryTrajectoryFunction
MemoryTrajectory(format::AbstractString) -> Trajectory
MemoryTrajectory(
    format::AbstractString,
    data::Union{Nothing, AbstractString, Vector{UInt8}}
) -> Trajectory

Open a trajectory that read in-memory data as if it were a formatted file.

The format of the data is mandatory, and must match one of the known formats. If data is nothing, this function creates a memory writer, the resulting data can be retrieved with buffer. Else, this function creates a memory reader using the given data.

source
Chemfiles.pathMethod
path(trajectory::Trajectory) -> String

Get the path used to open a trajectory.

source
Chemfiles.read_step!Method
read_step!(
    trajectory::Trajectory,
    step::Integer,
    frame::Frame
)

Read the given step of the trajectory into an preexisting Frame structure.

source
Chemfiles.read_stepMethod
read_step(trajectory::Trajectory, step::Integer) -> Frame

Read the given step of the trajectory, and return the corresponding Frame.

source
Chemfiles.set_cell!Method
set_cell!(trajectory::Trajectory, cell::UnitCell)

Set the cell associated with a trajectory. This cell will be used when reading and writing the file, replacing any unit cell in the file.

source
Chemfiles.set_topology!Function
set_topology!(trajectory::Trajectory, path::AbstractString)
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.

source
Chemfiles.set_topology!Method
set_topology!(trajectory::Trajectory, topology::Topology)

Set the Topology associated with a trajectory. This topology will be used when reading and writing the file, replacing any topology in the file.

source
Chemfiles.DataBufferType

Data (either binary or string) used for in-memory reading of trajectory

DataBuffer = Union{AbstractString,Vector{UInt8},Nothing}
source