Frame
Chemfiles.Frame
— TypeA Frame
holds data for one step of a simulation. As not all formats provide all the types of information, some fields may be initialized to a default value. A Frame
may contain the following data:
Chemfiles.Frame
— MethodFrame() -> Frame
Create a new empty Frame
.
Base.angle
— Methodangle(
frame::Frame,
i::Integer,
j::Integer,
k::Integer
) -> Float64
Calculate the angle made by three atoms.
Base.deepcopy
— Methoddeepcopy(frame::Frame) -> Frame
Make a deep copy of a Frame
.
Base.getindex
— Methodgetindex(frame::Frame, index::Integer) -> Chemfiles.Atom
Get the Atom
at the given index
of the frame
. By default this creates a copy so as to be safe. To not create a copy, use @view frame[index]
.
Base.length
— Methodlength(frame::Frame) -> Int64
Get the number of atoms in the frame
.
Base.resize!
— Methodresize!(frame::Frame, natoms::Integer)
Resize the positions and the velocities in the frame
, to make space for natoms
atoms. This function may invalidate any pointer to the positions or the velocities if the new size is bigger than the old one. In all the cases, previous data is conserved. This function conserve the presence or absence of velocities.
Base.size
— Methodsize(frame::Frame) -> Int64
Get the number of atoms in the frame
.
Base.step
— Methodstep(frame::Frame) -> UInt64
Get the frame
step, i.e. the frame number in the trajectory.
Base.view
— Methodview(frame::Frame, index::Integer) -> Chemfiles.Atom
Get the Atom
at the given index
of the frame
without creating a copy.
This function can lead to unefined behavior when keeping the returned Atom
around. Whith code like this:
frame = Frame()
resize!(frame, 3)
atom = @view frame[0]
resize!(frame, 4)
atom
contains a pointer to memory owned by frame
, but this pointer has been invalidated when resizing the frame. Using atom
after the second call to resize!
might trigger undefined behavior (segmentation fault in the best case, silent data corruption in the worst case).
Chemfiles.add_atom!
— Functionadd_atom!(
frame::Frame,
atom::Chemfiles.Atom,
position::Vector{Float64}
)
add_atom!(
frame::Frame,
atom::Chemfiles.Atom,
position::Vector{Float64},
velocity::Vector{Float64}
)
Add an atom
and the corresponding position
and velocity
data to a frame
.
Chemfiles.add_bond!
— Functionadd_bond!(frame::Frame, i::Integer, j::Integer)
add_bond!(frame::Frame, i::Integer, j::Integer, order)
Add an additional bond to the Frame
's Topology
.
Chemfiles.add_residue!
— Methodadd_residue!(frame::Frame, residue::Residue)
Add a residue to the Frame
's Topology
.
Chemfiles.add_velocities!
— Methodadd_velocities!(frame::Frame)
Add velocities to this frame
. The storage is initialized with the result of size(frame)
as the number of atoms. If the frame already has velocities, this does nothing.
Chemfiles.clear_bonds!
— Methodclear_bonds!(frame::Frame)
Remove all bonds, angles and dihedral angles from the Frame
's Topology
.
Chemfiles.dihedral
— Methoddihedral(
frame::Frame,
i::Integer,
j::Integer,
k::Integer,
m::Integer
) -> Float64
Calculate the dihedral (torsional) angle made by four unbranched atoms.
Chemfiles.distance
— Methoddistance(frame::Frame, i::Integer, j::Integer) -> Float64
Calculate the distance between two atoms.
Chemfiles.guess_bonds!
— Methodguess_bonds!(frame::Frame)
Guess the bonds, angles, and dihedrals in the frame
using a distance criteria.
Chemfiles.has_velocities
— Methodhas_velocities(frame::Frame) -> Bool
Check if a frame
contains velocity data or not.
Chemfiles.list_properties
— Methodlist_properties(frame::Frame) -> Vector{String}
Get the names of all properties associated with a frame.
Chemfiles.out_of_plane
— Methodout_of_plane(
frame::Frame,
i::Integer,
j::Integer,
k::Integer,
m::Integer
) -> Float64
Calculate the out-of-plane (improper) angle made by four atoms.
Chemfiles.positions
— Methodpositions(frame::Frame) -> Chemfiles.ChemfilesArray
Get the positions in a Frame
as an array. The positions are readable and writable from this array. If the frame is resized (by writing to it, or calling resize!
), the array is invalidated.
Chemfiles.properties_count
— Methodproperties_count(frame::Frame) -> Int64
Get the number of properties associated with a frame.
Chemfiles.property
— Methodproperty(frame::Frame, name::String) -> Any
Get a named property for the given atom.
Chemfiles.remove_atom!
— Methodremove_atom!(frame::Frame, index::Integer)
Remove the atom
at index
from the frame
.
This function modifies all the atoms
indexes after index
, and invalidates any array obtained using positions
or velocities
.
Chemfiles.remove_bond!
— Methodremove_bond!(frame::Frame, i::Integer, j::Integer)
Remove a bond from the Frame
's Topology
.
Chemfiles.set_cell!
— Methodset_cell!(frame::Frame, cell::UnitCell)
Set the cell
associated with a frame
.
Chemfiles.set_property!
— Methodset_property!(frame::Frame, name::String, value)
Set a named property for the given Frame
.
Chemfiles.set_step!
— Methodset_step!(frame::Frame, step::Integer)
Set the frame
step to step
.
Chemfiles.set_topology!
— Methodset_topology!(frame::Frame, topology::Topology)
Set the topology
associated with a frame
.
Chemfiles.velocities
— Methodvelocities(frame::Frame) -> Chemfiles.ChemfilesArray
Get the velocities in a Frame
as an array. The velocities are readable and writable from this array. If the frame is resized (by writing to it, or calling resize!
), the array is invalidated.
If the frame do not have velocity, this function will error. You can use add_velocities!
to add velocities to a frame before calling this function.