1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * PdbAtomInfoContainer.cpp
|
---|
10 | *
|
---|
11 | * Created on: Dec 4, 2010
|
---|
12 | * Author: heber
|
---|
13 | */
|
---|
14 |
|
---|
15 | // include config.h
|
---|
16 | #ifdef HAVE_CONFIG_H
|
---|
17 | #include <config.h>
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #include "CodePatterns/MemDebug.hpp"
|
---|
21 |
|
---|
22 | //#include "CodePatterns/Assert.hpp"
|
---|
23 | //#include "CodePatterns/Log.hpp"
|
---|
24 | #include "CodePatterns/toString.hpp"
|
---|
25 | //#include "CodePatterns/Verbose.hpp"
|
---|
26 | #include "LinearAlgebra/Vector.hpp"
|
---|
27 | #include "PdbAtomInfoContainer.hpp"
|
---|
28 |
|
---|
29 |
|
---|
30 | PdbAtomInfoContainer::PdbAtomInfoContainer() :
|
---|
31 | token("ATOM"),
|
---|
32 | serial(0),
|
---|
33 | name("-"),
|
---|
34 | altLoc('0'),
|
---|
35 | resName("-"),
|
---|
36 | chainID('0'),
|
---|
37 | resSeq(0),
|
---|
38 | iCode(' '),
|
---|
39 | occupancy(0.),
|
---|
40 | tempFactor(0.),
|
---|
41 | element(""),
|
---|
42 | charge(0)
|
---|
43 | {}
|
---|
44 |
|
---|
45 | PdbAtomInfoContainer::~PdbAtomInfoContainer()
|
---|
46 | {}
|
---|
47 |
|
---|
48 | void PdbAtomInfoContainer::set(const PdbKey::PdbDataKey key, std::string value)
|
---|
49 | {
|
---|
50 | switch (key) {
|
---|
51 | case PdbKey::token :
|
---|
52 | ScanKey(token, value);
|
---|
53 | break;
|
---|
54 | case PdbKey::serial :
|
---|
55 | ScanKey(serial, value);
|
---|
56 | break;
|
---|
57 | case PdbKey::name :
|
---|
58 | ScanKey(name, value);
|
---|
59 | break;
|
---|
60 | case PdbKey::altLoc :
|
---|
61 | ScanKey(altLoc, value);
|
---|
62 | break;
|
---|
63 | case PdbKey::resName :
|
---|
64 | ScanKey(resName, value);
|
---|
65 | break;
|
---|
66 | case PdbKey::chainID :
|
---|
67 | ScanKey(chainID, value);
|
---|
68 | break;
|
---|
69 | case PdbKey::resSeq :
|
---|
70 | ScanKey(resSeq, value);
|
---|
71 | break;
|
---|
72 | case PdbKey::iCode :
|
---|
73 | ScanKey(iCode, value);
|
---|
74 | break;
|
---|
75 | case PdbKey::X :
|
---|
76 | ScanKey(XYZ[0], value);
|
---|
77 | break;
|
---|
78 | case PdbKey::Y :
|
---|
79 | ScanKey(XYZ[1], value);
|
---|
80 | break;
|
---|
81 | case PdbKey::Z :
|
---|
82 | ScanKey(XYZ[2], value);
|
---|
83 | break;
|
---|
84 | case PdbKey::occupancy :
|
---|
85 | ScanKey(occupancy, value);
|
---|
86 | break;
|
---|
87 | case PdbKey::tempFactor :
|
---|
88 | ScanKey(tempFactor, value);
|
---|
89 | break;
|
---|
90 | case PdbKey::element :
|
---|
91 | ScanKey(element, value);
|
---|
92 | break;
|
---|
93 | case PdbKey::charge :
|
---|
94 | ScanKey(charge, value);
|
---|
95 | break;
|
---|
96 | default :
|
---|
97 | std::cout << "Unknown key: " << key << ", value: " << value << std::endl;
|
---|
98 | break;
|
---|
99 | }
|
---|
100 | }
|
---|
101 |
|
---|
102 | template <>
|
---|
103 | std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const
|
---|
104 | {
|
---|
105 | switch (key) {
|
---|
106 | case PdbKey::token :
|
---|
107 | return toString(token);
|
---|
108 | case PdbKey::serial :
|
---|
109 | return toString(serial);
|
---|
110 | case PdbKey::name :
|
---|
111 | return toString(name);
|
---|
112 | case PdbKey::altLoc :
|
---|
113 | return toString(altLoc);
|
---|
114 | case PdbKey::resName :
|
---|
115 | return toString(resName);
|
---|
116 | case PdbKey::chainID :
|
---|
117 | return toString(chainID);
|
---|
118 | case PdbKey::resSeq :
|
---|
119 | return toString(resSeq);
|
---|
120 | case PdbKey::iCode :
|
---|
121 | return toString(iCode);
|
---|
122 | case PdbKey::X :
|
---|
123 | return toString(XYZ[0]);
|
---|
124 | case PdbKey::Y :
|
---|
125 | return toString(XYZ[1]);
|
---|
126 | case PdbKey::Z :
|
---|
127 | return toString(XYZ[2]);
|
---|
128 | case PdbKey::occupancy :
|
---|
129 | return toString(occupancy);
|
---|
130 | case PdbKey::tempFactor :
|
---|
131 | return toString(tempFactor);
|
---|
132 | case PdbKey::element :
|
---|
133 | return toString(element);
|
---|
134 | case PdbKey::charge :
|
---|
135 | return toString(charge);
|
---|
136 | default :
|
---|
137 | std::cout << "Unknown key: " << key << std::endl;
|
---|
138 | return "";
|
---|
139 | }
|
---|
140 | }
|
---|
141 |
|
---|
142 | template <>
|
---|
143 | int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const
|
---|
144 | {
|
---|
145 | switch (key) {
|
---|
146 | case PdbKey::serial :
|
---|
147 | return serial;
|
---|
148 | case PdbKey::resSeq :
|
---|
149 | return resSeq;
|
---|
150 | case PdbKey::charge :
|
---|
151 | return charge;
|
---|
152 | default :
|
---|
153 | std::cout << "Unknown key or not presentable as int: " << key << std::endl;
|
---|
154 | return 0;
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | template <>
|
---|
159 | double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const
|
---|
160 | {
|
---|
161 | switch (key) {
|
---|
162 | case PdbKey::X :
|
---|
163 | return XYZ[0];
|
---|
164 | case PdbKey::Y :
|
---|
165 | return XYZ[1];
|
---|
166 | case PdbKey::Z :
|
---|
167 | return XYZ[2];
|
---|
168 | case PdbKey::occupancy :
|
---|
169 | return occupancy;
|
---|
170 | case PdbKey::tempFactor :
|
---|
171 | return tempFactor;
|
---|
172 | default :
|
---|
173 | std::cout << "Unknown key or not presentable as double: " << key << std::endl;
|
---|
174 | return 0.;
|
---|
175 | }
|
---|
176 | }
|
---|