source: src/Parser/PdbAtomInfoContainer.cpp@ ff4fff9

CombiningParticlePotentialParsing
Last change on this file since ff4fff9 was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 7.3 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder 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, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * PdbAtomInfoContainer.cpp
25 *
26 * Created on: Dec 4, 2010
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "CodePatterns/MemDebug.hpp"
36
37#include "CodePatterns/Assert.hpp"
38//#include "CodePatterns/Log.hpp"
39#include "CodePatterns/toString.hpp"
40//#include "CodePatterns/Verbose.hpp"
41#include "LinearAlgebra/Vector.hpp"
42#include "PdbAtomInfoContainer.hpp"
43
44PdbAtomInfoContainer::knownDataKeysMap PdbAtomInfoContainer::knownDataKeys;
45bool PdbAtomInfoContainer::knownDataKeys_Filled = false;
46
47PdbAtomInfoContainer::PdbAtomInfoContainer() :
48 token("ATOM"),
49 serial(0),
50 name("-"),
51 altLoc('0'),
52 resName("-"),
53 chainID('0'),
54 resSeq(0),
55 iCode(' '),
56 occupancy(0.),
57 tempFactor(0.),
58 element(""),
59 charge(0)
60{
61 if (!knownDataKeys_Filled)
62 fillknownDataKeys();
63}
64
65PdbAtomInfoContainer::~PdbAtomInfoContainer()
66{}
67
68void PdbAtomInfoContainer::fillknownDataKeys()
69{
70 knownDataKeys[PdbKey::token] = "token";
71 knownDataKeys[PdbKey::serial] = "serial";
72 knownDataKeys[PdbKey::name] = "name";
73 knownDataKeys[PdbKey::altLoc] = "altLoc";
74 knownDataKeys[PdbKey::resName] = "resName";
75 knownDataKeys[PdbKey::chainID] = "chainID";
76 knownDataKeys[PdbKey::resSeq] = "resSeq";
77 knownDataKeys[PdbKey::iCode] = "iCode";
78 knownDataKeys[PdbKey::X] = "X";
79 knownDataKeys[PdbKey::Y] = "Y";
80 knownDataKeys[PdbKey::Z] = "Z";
81 knownDataKeys[PdbKey::occupancy] = "occupancy";
82 knownDataKeys[PdbKey::tempFactor] = "tempFactor";
83 knownDataKeys[PdbKey::element] = "element";
84 knownDataKeys[PdbKey::charge] = "charge";
85 knownDataKeys_Filled = true;
86}
87
88void PdbAtomInfoContainer::clearknownDataKeys()
89{
90 knownDataKeys.clear();
91 knownDataKeys_Filled = false;
92}
93
94void PdbAtomInfoContainer::set(const PdbKey::PdbDataKey key, std::string value)
95{
96 switch (key) {
97 case PdbKey::token :
98 ScanKey(token, value);
99 break;
100 case PdbKey::serial :
101 ScanKey(serial, value);
102 break;
103 case PdbKey::name :
104 ScanKey(name, value);
105 break;
106 case PdbKey::altLoc :
107 ScanKey(altLoc, value);
108 break;
109 case PdbKey::resName :
110 ScanKey(resName, value);
111 break;
112 case PdbKey::chainID :
113 ScanKey(chainID, value);
114 break;
115 case PdbKey::resSeq :
116 ScanKey(resSeq, value);
117 break;
118 case PdbKey::iCode :
119 ScanKey(iCode, value);
120 break;
121 case PdbKey::X :
122 ScanKey(XYZ[0], value);
123 break;
124 case PdbKey::Y :
125 ScanKey(XYZ[1], value);
126 break;
127 case PdbKey::Z :
128 ScanKey(XYZ[2], value);
129 break;
130 case PdbKey::occupancy :
131 ScanKey(occupancy, value);
132 break;
133 case PdbKey::tempFactor :
134 ScanKey(tempFactor, value);
135 break;
136 case PdbKey::element :
137 ScanKey(element, value);
138 break;
139 case PdbKey::charge :
140 ScanKey(charge, value);
141 break;
142 default :
143 std::cout << "Unknown key: " << key << ", value: " << value << std::endl;
144 break;
145 }
146}
147
148template <>
149std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const
150{
151 switch (key) {
152 case PdbKey::token :
153 return toString(token);
154 case PdbKey::serial :
155 return toString(serial);
156 case PdbKey::name :
157 return toString(name);
158 case PdbKey::altLoc :
159 return toString(altLoc);
160 case PdbKey::resName :
161 return toString(resName);
162 case PdbKey::chainID :
163 return toString(chainID);
164 case PdbKey::resSeq :
165 return toString(resSeq);
166 case PdbKey::iCode :
167 return toString(iCode);
168 case PdbKey::X :
169 return toString(XYZ[0]);
170 case PdbKey::Y :
171 return toString(XYZ[1]);
172 case PdbKey::Z :
173 return toString(XYZ[2]);
174 case PdbKey::occupancy :
175 return toString(occupancy);
176 case PdbKey::tempFactor :
177 return toString(tempFactor);
178 case PdbKey::element :
179 return toString(element);
180 case PdbKey::charge :
181 return toString(charge);
182 default :
183 std::cout << "Unknown key: " << key << std::endl;
184 return "";
185 }
186}
187
188template <>
189int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const
190{
191 switch (key) {
192 case PdbKey::serial :
193 return serial;
194 case PdbKey::resSeq :
195 return resSeq;
196 case PdbKey::charge :
197 return charge;
198 default :
199 std::cout << "Unknown key or not presentable as int: " << key << std::endl;
200 return 0;
201 }
202}
203
204template <>
205double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const
206{
207 switch (key) {
208 case PdbKey::X :
209 return XYZ[0];
210 case PdbKey::Y :
211 return XYZ[1];
212 case PdbKey::Z :
213 return XYZ[2];
214 case PdbKey::occupancy :
215 return occupancy;
216 case PdbKey::tempFactor :
217 return tempFactor;
218 default :
219 std::cout << "Unknown key or not presentable as double: " << key << std::endl;
220 return 0.;
221 }
222}
223
224const std::string& PdbAtomInfoContainer::getDataKey(PdbKey::PdbDataKey key) const
225{
226 knownDataKeysMap::const_iterator iter;
227 iter = knownDataKeys.find(key);
228 ASSERT(iter != knownDataKeys.end(),
229 "PdbAtomInfoContainer::getDataKey() - unknown key "
230 +toString(key)+" request, did someone add a key to PdbKey?");
231 return iter->second;
232}
233
234std::ostream& operator<<(std::ostream &ost, const PdbAtomInfoContainer& m)
235{
236 ost << m.getDataKey(PdbKey::token) << "(" << m.get<std::string>(PdbKey::token) <<") ";
237 ost << m.getDataKey(PdbKey::serial) << "(" << m.get<std::string>(PdbKey::serial) <<") ";
238 ost << m.getDataKey(PdbKey::name) << "(" << m.get<std::string>(PdbKey::name) <<") ";
239 ost << m.getDataKey(PdbKey::altLoc) << "(" << m.get<std::string>(PdbKey::altLoc) <<") ";
240 ost << m.getDataKey(PdbKey::resName) << "(" << m.get<std::string>(PdbKey::resName) <<") ";
241 ost << m.getDataKey(PdbKey::chainID) << "(" << m.get<std::string>(PdbKey::chainID) <<") ";
242 ost << m.getDataKey(PdbKey::resSeq) << "(" << m.get<std::string>(PdbKey::resSeq) <<") ";
243 ost << m.getDataKey(PdbKey::iCode) << "(" << m.get<std::string>(PdbKey::iCode) <<") ";
244 ost << m.getDataKey(PdbKey::X) << "(" << m.get<std::string>(PdbKey::X) <<") ";
245 ost << m.getDataKey(PdbKey::Y) << "(" << m.get<std::string>(PdbKey::Y) <<") ";
246 ost << m.getDataKey(PdbKey::Z) << "(" << m.get<std::string>(PdbKey::Z) <<") ";
247 ost << m.getDataKey(PdbKey::occupancy) << "(" << m.get<std::string>(PdbKey::occupancy) <<") ";
248 ost << m.getDataKey(PdbKey::tempFactor) << "(" << m.get<std::string>(PdbKey::tempFactor) <<") ";
249 ost << m.getDataKey(PdbKey::element) << "(" << m.get<std::string>(PdbKey::element) <<") ";
250 ost << m.getDataKey(PdbKey::charge) << "(" << m.get<std::string>(PdbKey::charge) <<") ";
251 return ost;
252}
Note: See TracBrowser for help on using the repository browser.