source: src/Parser/PdbAtomInfoContainer.cpp@ 47d041

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 47d041 was 3e383d, checked in by Frederik Heber <heber@…>, 14 years ago

Removed PdbKey::timestep from PdbAtomInfoContainer as readNeighbors,readAtomDataLine are with step now.

  • Property mode set to 100644
File size: 6.7 KB
Line 
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
29PdbAtomInfoContainer::knownDataKeysMap PdbAtomInfoContainer::knownDataKeys;
30bool PdbAtomInfoContainer::knownDataKeys_Filled = false;
31
32PdbAtomInfoContainer::PdbAtomInfoContainer() :
33 token("ATOM"),
34 serial(0),
35 name("-"),
36 altLoc('0'),
37 resName("-"),
38 chainID('0'),
39 resSeq(0),
40 iCode(' '),
41 occupancy(0.),
42 tempFactor(0.),
43 element(""),
44 charge(0)
45{
46 if (!knownDataKeys_Filled)
47 fillknownDataKeys();
48}
49
50PdbAtomInfoContainer::~PdbAtomInfoContainer()
51{}
52
53void PdbAtomInfoContainer::fillknownDataKeys()
54{
55 knownDataKeys[PdbKey::token] = "token";
56 knownDataKeys[PdbKey::serial] = "serial";
57 knownDataKeys[PdbKey::name] = "name";
58 knownDataKeys[PdbKey::altLoc] = "altLoc";
59 knownDataKeys[PdbKey::resName] = "resName";
60 knownDataKeys[PdbKey::chainID] = "chainID";
61 knownDataKeys[PdbKey::resSeq] = "resSeq";
62 knownDataKeys[PdbKey::iCode] = "iCode";
63 knownDataKeys[PdbKey::X] = "X";
64 knownDataKeys[PdbKey::Y] = "Y";
65 knownDataKeys[PdbKey::Z] = "Z";
66 knownDataKeys[PdbKey::occupancy] = "occupancy";
67 knownDataKeys[PdbKey::tempFactor] = "tempFactor";
68 knownDataKeys[PdbKey::element] = "element";
69 knownDataKeys[PdbKey::charge] = "charge";
70 knownDataKeys_Filled = true;
71}
72
73void PdbAtomInfoContainer::clearknownDataKeys()
74{
75 knownDataKeys.clear();
76 knownDataKeys_Filled = false;
77}
78
79void PdbAtomInfoContainer::set(const PdbKey::PdbDataKey key, std::string value)
80{
81 switch (key) {
82 case PdbKey::token :
83 ScanKey(token, value);
84 break;
85 case PdbKey::serial :
86 ScanKey(serial, value);
87 break;
88 case PdbKey::name :
89 ScanKey(name, value);
90 break;
91 case PdbKey::altLoc :
92 ScanKey(altLoc, value);
93 break;
94 case PdbKey::resName :
95 ScanKey(resName, value);
96 break;
97 case PdbKey::chainID :
98 ScanKey(chainID, value);
99 break;
100 case PdbKey::resSeq :
101 ScanKey(resSeq, value);
102 break;
103 case PdbKey::iCode :
104 ScanKey(iCode, value);
105 break;
106 case PdbKey::X :
107 ScanKey(XYZ[0], value);
108 break;
109 case PdbKey::Y :
110 ScanKey(XYZ[1], value);
111 break;
112 case PdbKey::Z :
113 ScanKey(XYZ[2], value);
114 break;
115 case PdbKey::occupancy :
116 ScanKey(occupancy, value);
117 break;
118 case PdbKey::tempFactor :
119 ScanKey(tempFactor, value);
120 break;
121 case PdbKey::element :
122 ScanKey(element, value);
123 break;
124 case PdbKey::charge :
125 ScanKey(charge, value);
126 break;
127 default :
128 std::cout << "Unknown key: " << key << ", value: " << value << std::endl;
129 break;
130 }
131}
132
133template <>
134std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const
135{
136 switch (key) {
137 case PdbKey::token :
138 return toString(token);
139 case PdbKey::serial :
140 return toString(serial);
141 case PdbKey::name :
142 return toString(name);
143 case PdbKey::altLoc :
144 return toString(altLoc);
145 case PdbKey::resName :
146 return toString(resName);
147 case PdbKey::chainID :
148 return toString(chainID);
149 case PdbKey::resSeq :
150 return toString(resSeq);
151 case PdbKey::iCode :
152 return toString(iCode);
153 case PdbKey::X :
154 return toString(XYZ[0]);
155 case PdbKey::Y :
156 return toString(XYZ[1]);
157 case PdbKey::Z :
158 return toString(XYZ[2]);
159 case PdbKey::occupancy :
160 return toString(occupancy);
161 case PdbKey::tempFactor :
162 return toString(tempFactor);
163 case PdbKey::element :
164 return toString(element);
165 case PdbKey::charge :
166 return toString(charge);
167 default :
168 std::cout << "Unknown key: " << key << std::endl;
169 return "";
170 }
171}
172
173template <>
174int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const
175{
176 switch (key) {
177 case PdbKey::serial :
178 return serial;
179 case PdbKey::resSeq :
180 return resSeq;
181 case PdbKey::charge :
182 return charge;
183 default :
184 std::cout << "Unknown key or not presentable as int: " << key << std::endl;
185 return 0;
186 }
187}
188
189template <>
190double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const
191{
192 switch (key) {
193 case PdbKey::X :
194 return XYZ[0];
195 case PdbKey::Y :
196 return XYZ[1];
197 case PdbKey::Z :
198 return XYZ[2];
199 case PdbKey::occupancy :
200 return occupancy;
201 case PdbKey::tempFactor :
202 return tempFactor;
203 default :
204 std::cout << "Unknown key or not presentable as double: " << key << std::endl;
205 return 0.;
206 }
207}
208
209const std::string& PdbAtomInfoContainer::getDataKey(PdbKey::PdbDataKey key) const
210{
211 knownDataKeysMap::const_iterator iter;
212 iter = knownDataKeys.find(key);
213 ASSERT(iter != knownDataKeys.end(),
214 "PdbAtomInfoContainer::getDataKey() - unknown key "
215 +toString(key)+" request, did someone add a key to PdbKey?");
216 return iter->second;
217}
218
219std::ostream& operator<<(std::ostream &ost, const PdbAtomInfoContainer& m)
220{
221 ost << m.getDataKey(PdbKey::token) << "(" << m.get<std::string>(PdbKey::token) <<") ";
222 ost << m.getDataKey(PdbKey::serial) << "(" << m.get<std::string>(PdbKey::serial) <<") ";
223 ost << m.getDataKey(PdbKey::name) << "(" << m.get<std::string>(PdbKey::name) <<") ";
224 ost << m.getDataKey(PdbKey::altLoc) << "(" << m.get<std::string>(PdbKey::altLoc) <<") ";
225 ost << m.getDataKey(PdbKey::resName) << "(" << m.get<std::string>(PdbKey::resName) <<") ";
226 ost << m.getDataKey(PdbKey::chainID) << "(" << m.get<std::string>(PdbKey::chainID) <<") ";
227 ost << m.getDataKey(PdbKey::resSeq) << "(" << m.get<std::string>(PdbKey::resSeq) <<") ";
228 ost << m.getDataKey(PdbKey::iCode) << "(" << m.get<std::string>(PdbKey::iCode) <<") ";
229 ost << m.getDataKey(PdbKey::X) << "(" << m.get<std::string>(PdbKey::X) <<") ";
230 ost << m.getDataKey(PdbKey::Y) << "(" << m.get<std::string>(PdbKey::Y) <<") ";
231 ost << m.getDataKey(PdbKey::Z) << "(" << m.get<std::string>(PdbKey::Z) <<") ";
232 ost << m.getDataKey(PdbKey::occupancy) << "(" << m.get<std::string>(PdbKey::occupancy) <<") ";
233 ost << m.getDataKey(PdbKey::tempFactor) << "(" << m.get<std::string>(PdbKey::tempFactor) <<") ";
234 ost << m.getDataKey(PdbKey::element) << "(" << m.get<std::string>(PdbKey::element) <<") ";
235 ost << m.getDataKey(PdbKey::charge) << "(" << m.get<std::string>(PdbKey::charge) <<") ";
236 return ost;
237}
Note: See TracBrowser for help on using the repository browser.