votca 2024.2-dev
Loading...
Searching...
No Matches
xyzreader.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18// Standard includes
19#include <vector>
20
21// Third party includes
22#include <boost/lexical_cast.hpp>
23
24// VOTCA includes
25#include <votca/tools/getline.h>
26
27// Local VOTCA includes
28#include "votca/csg/xyzreader.h"
29
30namespace votca {
31namespace csg {
32using namespace boost;
33using namespace std;
34
35bool XYZReader::ReadTopology(string file, Topology &top) {
36 top.Cleanup();
37 file_ = file;
38 fl_.open(file);
39 if (!fl_.is_open()) {
40 throw std::ios_base::failure("Error on open topology file: " + file);
41 }
42
43 top.CreateResidue("DUM");
44
46
47 fl_.close();
48
49 return true;
50}
51
52bool XYZReader::Open(const string &file) {
53 file_ = file;
54 fl_.open(file);
55 if (!fl_.is_open()) {
56 throw std::ios_base::failure("Error on open trajectory file: " + file);
57 }
58 line_ = 0;
59 return true;
60}
61
62void XYZReader::Close() { fl_.close(); }
63
64bool XYZReader::FirstFrame(Topology &top) { return NextFrame(top); }
65
67 bool success = ReadFrame<false, Topology>(top);
68 return success;
69}
70
71} // namespace csg
72} // namespace votca
topology of the whole system
Definition topology.h:81
Residue & CreateResidue(std::string name)
Create a new resiude.
Definition topology.h:462
void Cleanup()
Cleans up all the stored data.
Definition topology.cc:49
bool Open(const std::string &file) override
open a trajectory file
Definition xyzreader.cc:52
bool FirstFrame(Topology &top) override
read in the first frame
Definition xyzreader.cc:64
bool ReadFrame(T &container)
Definition xyzreader.h:114
bool NextFrame(Topology &top) override
read in the next frame
Definition xyzreader.cc:66
bool ReadTopology(std::string file, Topology &top) override
open a topology file
Definition xyzreader.cc:35
void Close() override
Definition xyzreader.cc:62
std::ifstream fl_
Definition xyzreader.h:108
STL namespace.
base class for all analysis tools
Definition basebead.h:33