LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
gro.hpp
1/*
2 This file is part of LOOS.
3
4 LOOS (Lightweight Object-Oriented Structure library)
5 Copyright (c) 2009, 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_GRO_HPP)
23#define LOOS_GRO_HPP
24
25#include <iostream>
26#include <string>
27#include <sstream>
28#include <fstream>
29#include <stdexcept>
30
31#include <loos_defs.hpp>
32#include <AtomicGroup.hpp>
33
34namespace loos
35{
36
38 class Gromacs : public AtomicGroup
39 {
40 public:
41 Gromacs() {}
42
43 explicit Gromacs(const std::string &fname) : _filename(fname), _max_index(0), _has_velocities(false)
44 {
45 std::ifstream ifs(fname.c_str());
46 if (!ifs)
47 throw(FileOpenError(fname));
48 read(ifs);
49 }
50
51 explicit Gromacs(std::istream &ifs) : _filename("stream"), _max_index(0), _has_velocities(false) { read(ifs); }
52
53 static pAtomicGroup create(const std::string &fname)
54 {
55 return (pAtomicGroup(new Gromacs(fname)));
56 }
57
58 bool hasVelocities() const { return (_has_velocities); }
59
60 std::string asString() const;
62 friend std::ostream &operator<<(std::ostream &, const Gromacs &);
63
64 std::string title(void) const { return (title_); }
65
67 static Gromacs fromAtomicGroup(const AtomicGroup &);
68
69 private:
70 std::string _filename;
71 std::string title_;
72 uint _max_index;
73 bool _has_velocities;
74
75 private:
76 void read(std::istream &ifs);
77
78 // Convert an Atom to a string representation in PDB format...
79 std::string atomAsString(const pAtom p) const;
80
82 Gromacs(const AtomicGroup &grp) : AtomicGroup(grp) {}
83 };
84
85}
86
87#endif
Class for handling groups of Atoms (pAtoms, actually)
Definition AtomicGroup.hpp:108
Error while opening a file.
Definition exceptions.hpp:175
Implements a GROMACS model file (.gro)
Definition gro.hpp:39
friend std::ostream & operator<<(std::ostream &, const Gromacs &)
Output as a GRO.
Definition gro.cpp:144
static Gromacs fromAtomicGroup(const AtomicGroup &)
Class method for creating a GRO from an AtomicGroup.
Definition gro.cpp:125
Namespace for most things not already encapsulated within a class.
Definition version.cpp:3