LOOS  v2.3.2
amber_traj.hpp
1 /*
2  This file is part of LOOS.
3 
4  LOOS (Lightweight Object-Oriented Structure library)
5  Copyright (c) 2008, Tod D. Romo, Alan Grossfield
6  Department of Biochemistry and Biophysics
7  School of Medicine & Dentistry, University of Rochester
8 
9  This package (LOOS) is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation under version 3 of the License.
12 
13  This package is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #if !defined(LOOS_AMBER_TRAJ_HPP)
23 #define LOOS_AMBER_TRAJ_HPP
24 
25 
26 #include <string>
27 
28 #include <loos_defs.hpp>
29 #include <Coord.hpp>
30 #include <Trajectory.hpp>
31 
32 
33 namespace loos {
34 
36 
48  class AmberTraj : public Trajectory {
49  public:
50  explicit AmberTraj(const std::string& s, const int na) : Trajectory(s),
51  _natoms(na), frame_offset(0),
52  frame_size(0), periodic(false) { init(); }
53 
54  explicit AmberTraj(std::istream& is, const int na) : Trajectory(is), _natoms(na),
55  frame_offset(0), frame_size(0),
56  periodic(false) { init(); }
57 
58  std::string description() const { return("Amber trajectory"); }
59  static pTraj create(const std::string& fname, const AtomicGroup& model) {
60  return(pTraj(new AmberTraj(fname, model.size())));
61  }
62 
63 
64  virtual uint nframes(void) const { return(_nframes); }
65  virtual uint natoms(void) const { return(_natoms); }
66  virtual std::vector<GCoord> coords(void) { return(frame); }
67 
68  virtual bool hasPeriodicBox(void) const { return(periodic); }
69  virtual GCoord periodicBox(void) const { return(box); }
70 
76  virtual float timestep(void) const { return(0.0); } // Dummy routine...
77 
78  virtual bool parseFrame(void);
79 
80 
81  private:
82  void init(void);
83  virtual void rewindImpl(void) { ifs()->clear(); ifs()->seekg(frame_offset); }
84  virtual void seekNextFrameImpl(void) { }
85  virtual void seekFrameImpl(const uint);
86  virtual void updateGroupCoordsImpl(AtomicGroup&);
87 
88 
89  private:
90  uint _natoms, _nframes;
91  unsigned long frame_offset, frame_size;
92  bool periodic;
93  GCoord box;
94  std::vector<GCoord> frame;
95 
96  };
97 
98 
99 }
100 #endif
Class for reading amber coordinate trajectories.
Definition: amber_traj.hpp:48
virtual bool parseFrame(void)
Parse an actual frame.
Definition: amber_traj.cpp:86
virtual float timestep(void) const
Definition: amber_traj.hpp:76
std::string description() const
Return a string describing trajectory format.
Definition: amber_traj.hpp:58
virtual bool hasPeriodicBox(void) const
Definition: amber_traj.hpp:68
virtual uint nframes(void) const
Number of frames in the trajectory.
Definition: amber_traj.hpp:64
virtual std::vector< GCoord > coords(void)
Returns the current frames coordinates as a vector of GCoords.
Definition: amber_traj.hpp:66
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
Namespace for most things not already encapsulated within a class.
virtual uint natoms(void) const
of atoms per frame
Definition: amber_traj.hpp:65
Base-class for polymorphic trajectories.
Definition: Trajectory.hpp:64
virtual GCoord periodicBox(void) const
Returns the periodic box for the current frame/trajectory.
Definition: amber_traj.hpp:69