LOOS  v2.3.2
tinker_arc.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_TINKER_ARC_HPP)
23 #define LOOS_TINKER_ARC_HPP
24 
25 
26 #include <iostream>
27 #include <string>
28 #include <stdexcept>
29 
30 #include <loos_defs.hpp>
31 #include <Trajectory.hpp>
32 
33 #include <tinkerxyz.hpp>
34 
35 
36 namespace loos {
37 
39 
60  class TinkerArc : public Trajectory {
61  public:
62  explicit TinkerArc(const std::string& s) : Trajectory(s), _natoms(0), _nframes(0),
63  current_index(0), at_end(false) { init(); }
64 
65  explicit TinkerArc(std::istream& is) : Trajectory(is), _natoms(0),
66  _nframes(0), current_index(0), at_end(false) { init(); }
67 
68  std::string description() const { return("Tinker Archive"); }
69 
70  static pTraj create(const std::string& fname, const AtomicGroup& model) {
71  return(pTraj(new TinkerArc(fname)));
72  }
73 
74  virtual uint nframes(void) const { return(_nframes); }
75  virtual uint natoms(void) const { return(_natoms); }
76  virtual std::vector<GCoord> coords(void);
77 
78  virtual bool hasPeriodicBox(void) const { return(frame.isPeriodic()); }
79  virtual GCoord periodicBox(void) const { return(frame.periodicBox()); }
80 
81  virtual float timestep(void) const { return(0.001); }
82 
84 
87  TinkerXYZ currentFrame(void) const { return(frame); }
88 
89  virtual bool parseFrame(void);
90 
91 
92  private:
93  void init(void);
94  virtual void rewindImpl(void) { ifs()->clear(); ifs()->seekg(0); current_index = 0; at_end = false; }
95  virtual void seekNextFrameImpl(void);
96  virtual void seekFrameImpl(const uint);
97  virtual void updateGroupCoordsImpl(AtomicGroup& g);
98 
99 
100  private:
101  uint _natoms, _nframes;
102  uint current_index;
103  bool at_end;
104  TinkerXYZ frame;
105  std::vector<long> indices;
106  };
107 
108 
109 }
110 
111 
112 #endif
virtual std::vector< GCoord > coords(void)
Returns the current frames coordinates as a vector of GCoords.
Definition: tinker_arc.cpp:87
virtual bool hasPeriodicBox(void) const
Definition: tinker_arc.hpp:78
Class for reading a subset of the TinkerXYZ format.
Definition: tinkerxyz.hpp:47
bool isPeriodic(void) const
Test whether or not periodic boundary conditions are set.
std::string description() const
Return a string describing trajectory format.
Definition: tinker_arc.hpp:68
virtual uint natoms(void) const
of atoms per frame
Definition: tinker_arc.hpp:75
virtual float timestep(void) const
Timestep per frame.
Definition: tinker_arc.hpp:81
virtual GCoord periodicBox(void) const
Returns the periodic box for the current frame/trajectory.
Definition: tinker_arc.hpp:79
virtual bool parseFrame(void)
Parse an actual frame.
Definition: tinker_arc.cpp:71
Class for handling Tinker ARC files (concatenation of .xyz files)
Definition: tinker_arc.hpp:60
Class for handling groups of Atoms (pAtoms, actually)
Definition: AtomicGroup.hpp:87
TinkerXYZ currentFrame(void) const
Returns the contained TinkerXYZ object.
Definition: tinker_arc.hpp:87
Namespace for most things not already encapsulated within a class.
virtual uint nframes(void) const
Number of frames in the trajectory.
Definition: tinker_arc.hpp:74
Base-class for polymorphic trajectories.
Definition: Trajectory.hpp:64
GCoord periodicBox(void) const
Fetch the periodic boundary conditions.