LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
|
Base-class for polymorphic trajectories. More...
#include <Trajectory.hpp>
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< GCoord > | coords (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< GCoord > | velocities (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 |
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.
|
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.
|
inlinevirtual |
Return a string describing trajectory format.
Reimplemented in loos::AmberNetcdf, loos::AmberRst, loos::AmberTraj, loos::CCPDB, loos::DCD, loos::MDTrajTraj, loos::MultiTrajectory, loos::PDBTraj, loos::TinkerArc, loos::TRR, and loos::XTC.
|
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.
|
inlinevirtual |
Whether or not the trajectory format supports velocities.
Reimplemented in loos::AmberNetcdf, loos::DCD, loos::MultiTrajectory, and loos::TRR.
|
pure virtual |
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.
|
pure virtual |
Number of frames in the 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.
|
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.
|
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.
|
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...
|
inline |
Seek to a specific frame, be it in the same contiguous file or in separate files.
|
inline |
Seek to the next frame in the sequence (used by readFrame() when operating as an iterator).
|
pure virtual |
Timestep per frame.
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.
|
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.
|
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.
|
inlinevirtual |
Conversion applied to velocities to get to \AA/ps.
Reimplemented in loos::AmberNetcdf, loos::AmberTraj, and loos::DCD.