LOOS  v2.3.2
loos::Trajectory Class Referenceabstract

Base-class for polymorphic trajectories. More...

#include <Trajectory.hpp>

Inheritance diagram for loos::Trajectory:
Collaboration diagram for loos::Trajectory:

Public Member Functions

 Trajectory (const std::string &s)
 Automatically open the file named s.
 Trajectory (std::istream &fs)
 Open using the given stream...
virtual std::string description () const
 Return a string describing trajectory format.
virtual uint natoms (void) const =0

of atoms per frame

virtual float timestep (void) const =0
 Timestep per frame.
virtual uint nframes (void) const =0
 Number of frames in the trajectory.
bool rewind (void)
 Rewinds the readFrame() iterator.
virtual bool hasPeriodicBox (void) const =0
virtual GCoord periodicBox (void) const =0
 Returns the periodic box for the current frame/trajectory.
virtual std::vector< GCoordcoords (void)=0
 Returns the current frames coordinates as a vector of GCoords. More...
void updateGroupCoords (AtomicGroup &g)
 Update the coordinates in an AtomicGroup with the current frame. More...
void seekNextFrame (void)
void seekFrame (const uint i)
virtual bool parseFrame (void)=0
 Parse an actual frame. More...
bool readFrame (void)
 Reads the next frame in a trajectory, returning false if at the end.
bool readFrame (const int i)
 Reads a specific frame in a trajectory. More...

Protected Attributes

StreamWrapper ifs
bool cached_first
std::string _filename

Detailed Description

Base-class for polymorphic trajectories.

This is the interface for trajectories in LOOS. It is expected that at least one frame of coordinates will be buffered internally at any given time.

Additionally, this class is not designed to provide output, only input...

+IMPORTANT NOTE+ The derived classes MUST read in and cache the first frame as part of their initialization. This prevents problems where updateGroupCoords() is called prior to the class reading any trajectory data (which can occur with some formats, such as DCD's, that only have to read a header to configure the internal data... However, just inserting a readFrame(0) in the constructor will leave the trajectory iterator in an incorrect state–the first call to readFrame() will return the 2nd frame, not the first, which is probably not the desired behavior. The derived class must also then set the cached_first flag to true after the readFrame(0). See the DCD class for an example of this.

Definition at line 64 of file Trajectory.hpp.

Member Function Documentation

virtual std::vector<GCoord> loos::Trajectory::coords ( void  )
pure virtual

Returns the current frames coordinates as a vector of GCoords.

Some formats, notably DCDs, do not interleave their coordinates. This means that this could be a potentially expensive operation.

Implemented in loos::DCD, loos::TRR, loos::AmberNetcdf, loos::XTC, loos::PDBTraj, loos::TinkerArc, loos::AmberTraj, loos::CCPDB, and loos::AmberRst.

virtual bool loos::Trajectory::hasPeriodicBox ( void  ) const
pure virtual

Tests whether or not the given frame/trajectory has periodic boundary information. The presence of periodic box information does not necessarily indicate that said information has been read in yet. For example, the presence of crystal data is in the header so this can be detected before any frame is read, but the crystal data itself is only read when a frame is read in.

Implemented in loos::TRR, loos::AmberNetcdf, loos::DCD, loos::XTC, loos::PDBTraj, loos::TinkerArc, loos::AmberTraj, loos::CCPDB, and loos::AmberRst.

virtual bool loos::Trajectory::parseFrame ( void  )
pure virtual

Parse an actual frame.

parseFrame() is expected to read in a frame through the Trajectory's StreamWrapper. It returns a bool indicating whether or not it was able to actually read a frame (i.e. false indicates EOF).

Implemented in loos::TRR, loos::DCD, loos::PDBTraj, loos::CCPDB, loos::TinkerArc, loos::AmberTraj, and loos::AmberRst.

bool loos::Trajectory::readFrame ( const int  i)

Reads a specific frame in a trajectory.

Reading a specific frame also resets the readFrame() iterator version so it will continue where readFrame(i) left off...

Definition at line 185 of file Trajectory.hpp.

void loos::Trajectory::seekFrame ( const uint  i)

Seek to a specific frame, be it in the same contiguous file or in separate files.

Definition at line 155 of file Trajectory.hpp.

void loos::Trajectory::seekNextFrame ( void  )

Seek to the next frame in the sequence (used by readFrame() when operating as an iterator).

Definition at line 148 of file Trajectory.hpp.

void loos::Trajectory::updateGroupCoords ( AtomicGroup g)

Update the coordinates in an AtomicGroup with the current frame.

The Atom::index() property is used as an index into the current frame for retrieving coordinates. The index property is typically set when a model is read in by the corresponding class (e.g. PDB, Amber, etc) and is determined by the ordering of the atoms in that file. This is not the same as an atomid. For example, the first atom in a structure could have an atomid of 1000, but its index would be 0.

updateGroupCoords() normally assumes that the passed AtomicGroup has valid indices. As a safety check, the createTrajectory() function will check that the AtomicGroup passed to it has indices. Turning on debugging (i.e. the DEBUG compile-flag) will force updateGroupCoords() to validate the passed AtomicGroup every time, with correspondingly poorer performance.

Also note that the declaration of this function has changed in release 2.1.0. It is no longer virtual, using the NVI-idiom instead. Derived classes should override the updateGroupCoordsImpl() function.

Definition at line 135 of file Trajectory.hpp.

The documentation for this class was generated from the following file: