LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
loos::Trajectory Class Referenceabstract

Base-class for polymorphic trajectories. More...

#include <Trajectory.hpp>

Inheritance diagram for loos::Trajectory:
Inheritance graph
[legend]
Collaboration diagram for loos::Trajectory:
Collaboration graph
[legend]

Public Types

typedef boost::shared_ptr< std::istream > pStream
 

Public Member Functions

 Trajectory (const std::string &s)
 Automatically open the file named s.
 
 Trajectory (std::istream &fs)
 Open using the given stream...
 
 Trajectory (const Trajectory &t)
 
virtual std::string description () const
 Return a string describing trajectory format.
 
virtual std::string filename () const
 Return the stored filename.
 
virtual uint natoms (void) const =0
 
virtual float timestep (void) const =0
 Timestep per frame.
 
virtual uint nframes (void) const =0
 Number of frames in the trajectory.
 
virtual bool hasVelocities () const
 Whether or not the trajectory format supports velocities.
 
virtual double velocityConversionFactor () const
 Conversion applied to velocities to get to \AA/ps.
 
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) const =0
 Returns the current frames coordinates as a vector of GCoords.
 
void updateGroupCoords (AtomicGroup &g)
 Update the coordinates in an AtomicGroup with the current frame.
 
virtual std::vector< GCoordvelocities (void) const
 Returns the current frame's velocities as a vector of GCoords.
 
void updateGroupVelocities (AtomicGroup &g)
 
void seekNextFrame (void)
 
void seekFrame (const uint i)
 
virtual bool parseFrame (void)=0
 Parse an actual frame.
 
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.
 
bool atEnd () const
 
uint currentFrame () const
 

Protected Member Functions

void setInputStream (const std::string &fname)
 
void setInputStream (std::istream &fs)
 

Protected Attributes

pStream ifs
 
bool cached_first
 
std::string _filename
 
uint _current_frame
 

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.

Member Function Documentation

◆ coords()

virtual std::vector< GCoord > loos::Trajectory::coords ( void ) const
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::AmberNetcdf, loos::MultiTrajectory, loos::AmberRst, loos::AmberTraj, loos::CCPDB, loos::DCD, loos::MDTrajTraj, loos::PDBTraj, loos::TinkerArc, loos::TRR, and loos::XTC.

◆ description()

virtual std::string loos::Trajectory::description ( ) const
inlinevirtual

◆ hasPeriodicBox()

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::AmberNetcdf, loos::MultiTrajectory, loos::AmberRst, loos::AmberTraj, loos::CCPDB, loos::DCD, loos::MDTrajTraj, loos::PDBTraj, loos::TinkerArc, loos::TRR, and loos::XTC.

◆ hasVelocities()

virtual bool loos::Trajectory::hasVelocities ( void ) const
inlinevirtual

Whether or not the trajectory format supports velocities.

Reimplemented in loos::AmberNetcdf, loos::DCD, loos::MultiTrajectory, and loos::TRR.

◆ natoms()

virtual uint loos::Trajectory::natoms ( void ) const
pure virtual

◆ nframes()

virtual uint loos::Trajectory::nframes ( void ) const
pure virtual

◆ parseFrame()

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::AmberRst, loos::AmberTraj, loos::CCPDB, loos::DCD, loos::MDTrajTraj, loos::PDBTraj, loos::TinkerArc, and loos::TRR.

◆ periodicBox()

virtual GCoord loos::Trajectory::periodicBox ( void ) const
pure virtual

Returns the periodic box for the current frame/trajectory.

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

◆ readFrame()

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

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...

◆ seekFrame()

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

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

◆ seekNextFrame()

void loos::Trajectory::seekNextFrame ( void )
inline

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

◆ timestep()

virtual float loos::Trajectory::timestep ( void ) const
pure virtual

◆ updateGroupCoords()

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

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. Only the first atom is tested, unless the DEBUG compile-flig is turned on, which will force updateGroupCoords() to validate the entire 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.

◆ velocities()

virtual std::vector< GCoord > loos::Trajectory::velocities ( void ) const
inlinevirtual

Returns the current frame's velocities as a vector of GCoords.

If the trajectory format supports velocities "natively", then those will be returned. If not, the velocities will be assumed to be stored in the coordinates. Those will be scaled by the velcotiyConversionFactor() and then returned.

◆ velocityConversionFactor()

virtual double loos::Trajectory::velocityConversionFactor ( ) const
inlinevirtual

Conversion applied to velocities to get to \AA/ps.

Reimplemented in loos::AmberNetcdf, loos::AmberTraj, and loos::DCD.


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