Changeset 16462f for src/Parser
- Timestamp:
- Dec 16, 2010, 5:32:18 PM (14 years ago)
- Branches:
- 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
- Children:
- 1d02fe3
- Parents:
- 24f128
- git-author:
- Frederik Heber <heber@…> (12/07/10 12:54:42)
- git-committer:
- Frederik Heber <heber@…> (12/16/10 17:32:18)
- Location:
- src/Parser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/PdbAtomInfoContainer.cpp
r24f128 r16462f 24 24 #include "Helpers/toString.hpp" 25 25 //#include "Helpers/Verbose.hpp" 26 #include "LinearAlgebra/Vector.hpp" 26 27 #include "PdbAtomInfoContainer.hpp" 27 28 28 29 29 30 PdbAtomInfoContainer::PdbAtomInfoContainer() : 31 token("ATOM"), 30 32 serial(0), 31 33 name("-"), 32 alt loc('0'),34 altLoc('0'), 33 35 resName("-"), 34 36 chainID('0'), … … 37 39 occupancy(0.), 38 40 tempFactor(0.), 41 element(""), 39 42 charge(0) 40 43 {} … … 46 49 { 47 50 switch (key) { 51 case PdbKey::token : 52 ScanKey(token, value); 53 break; 48 54 case PdbKey::serial : 49 55 ScanKey(serial, value); … … 52 58 ScanKey(name, value); 53 59 break; 54 case PdbKey::alt loc :55 ScanKey(alt loc, value);60 case PdbKey::altLoc : 61 ScanKey(altLoc, value); 56 62 break; 57 63 case PdbKey::resName : … … 67 73 ScanKey(iCode, value); 68 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; 69 84 case PdbKey::occupancy : 70 85 ScanKey(occupancy, value); … … 72 87 case PdbKey::tempFactor : 73 88 ScanKey(tempFactor, value); 89 break; 90 case PdbKey::element : 91 ScanKey(element, value); 74 92 break; 75 93 case PdbKey::charge : … … 82 100 } 83 101 84 std::string PdbAtomInfoContainer::get(const PdbKey::PdbDataKey key) const 102 template <> 103 std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const 85 104 { 86 105 switch (key) { 106 case PdbKey::token : 107 return toString(token); 87 108 case PdbKey::serial : 88 109 return toString(serial); 89 110 case PdbKey::name : 90 111 return toString(name); 91 case PdbKey::alt loc :92 return toString(alt loc);112 case PdbKey::altLoc : 113 return toString(altLoc); 93 114 case PdbKey::resName : 94 115 return toString(resName); … … 99 120 case PdbKey::iCode : 100 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]); 101 128 case PdbKey::occupancy : 102 129 return toString(occupancy); 103 130 case PdbKey::tempFactor : 104 131 return toString(tempFactor); 132 case PdbKey::element : 133 return toString(element); 105 134 case PdbKey::charge : 106 135 return toString(charge); … … 111 140 } 112 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 } -
src/Parser/PdbAtomInfoContainer.hpp
r24f128 r16462f 11 11 #include "PdbKey.hpp" 12 12 13 class Vector; 14 13 15 #include <string> 16 #include <typeinfo> 14 17 15 18 /** … … 22 25 23 26 // getter and setter 24 std::string get(const PdbKey::PdbDataKey key) const; 27 template <class T> T get(const PdbKey::PdbDataKey key) const { 28 switch (key) { 29 default : 30 std::cout << "Unknown key or not representable as " << typeid(T).name() << ": " << key << std::endl; 31 break; 32 } 33 return (T)NULL; 34 } 25 35 void set(const PdbKey::PdbDataKey key, std::string value); 26 36 … … 46 56 47 57 private: 58 std::string token; 48 59 int serial; 49 60 std::string name; 50 char alt loc;61 char altLoc; 51 62 std::string resName; 52 63 char chainID; 53 64 int resSeq; 54 65 char iCode; 66 Vector XYZ; 55 67 float occupancy; 56 68 float tempFactor; 69 std::string element; 57 70 int charge; 58 71 }; 59 72 73 template <> 74 std::string PdbAtomInfoContainer::get<std::string>(const PdbKey::PdbDataKey key) const; 75 template <> 76 int PdbAtomInfoContainer::get<int>(const PdbKey::PdbDataKey key) const; 77 template <> 78 double PdbAtomInfoContainer::get<double>(const PdbKey::PdbDataKey key) const; 79 60 80 #endif /* PDBATOMINFOCONTAINER_HPP_ */ -
src/Parser/PdbKey.hpp
r24f128 r16462f 18 18 enum PdbDataKey { 19 19 noKey, 20 token, 20 21 serial, 21 22 name, 22 alt loc,23 altLoc, 23 24 resName, 24 25 chainID, 25 26 resSeq, 26 27 iCode, 28 X, 29 Y, 30 Z, 27 31 occupancy, 28 32 tempFactor, 33 element, 29 34 charge 30 35 }; -
src/Parser/PdbParser.cpp
r24f128 r16462f 46 46 PdbParser::PdbParser() { 47 47 knownTokens["ATOM"] = PdbKey::Atom; 48 knownTokens["HETATM"] = PdbKey::Atom; 48 49 knownTokens["TER"] = PdbKey::Filler; 49 50 knownTokens["END"] = PdbKey::EndOfFile; … … 51 52 knownTokens["REMARK"] = PdbKey::Remark; 52 53 knownTokens[""] = PdbKey::EndOfFile; 54 55 // argh, why can't just PdbKey::X+(size_t)i 56 PositionEnumMap[0] = PdbKey::X; 57 PositionEnumMap[1] = PdbKey::Y; 58 PositionEnumMap[2] = PdbKey::Z; 53 59 } 54 60 … … 99 105 size_t linecount = 0; 100 106 enum PdbKey::KnownTokens token; 107 108 // reset atomIdMap for this file (to correctly parse CONECT entries) 109 atomIdMap.clear(); 101 110 102 111 molecule *newmol = World::getInstance().createMolecule(); … … 157 166 } 158 167 159 // we distribute new atom numbers, hence clear map beforehand168 // we distribute serials, hence clear map beforehand 160 169 atomIdMap.clear(); 161 170 { 162 vector<atom *> AtomList = World::getInstance().getAllAtoms(); 163 164 std::vector<int> elementNo(MAX_ELEMENTS,1); 171 std::vector<atom *> AtomList = World::getInstance().getAllAtoms(); 172 std::vector<molecule *> MolList = World::getInstance().getAllMolecules(); 173 std::map<size_t,size_t> MolIdMap; 174 size_t MolNo = 1; // residue number starts at 1 in pdb 175 for (std::vector<molecule *>::const_iterator iter = MolList.begin(); 176 iter != MolList.end(); 177 ++iter) { 178 MolIdMap[(*iter)->getId()] = MolNo++; 179 } 180 const size_t MaxMol = MolNo; 181 182 // have a count per element and per molecule (0 is for all homeless atoms) 183 std::vector<int> **elementNo = new std::vector<int>*[MaxMol]; 184 for (size_t i = 0; i < MaxMol; ++i) 185 elementNo[i] = new std::vector<int>(MAX_ELEMENTS,1); 165 186 char name[MAXSTRINGSIZE]; 187 std::string ResidueName; 166 188 167 189 // write ATOMs 168 190 int AtomNo = 1; // serial number starts at 1 in pdb 169 int MolNo = 1; // residue number starts at 1 in pdb170 191 for (vector<atom *>::iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) { 192 PdbAtomInfoContainer &atomInfo = additionalAtomData[(*atomIt)->getId()]; 193 // gather info about residue 194 const molecule *mol = (*atomIt)->getMolecule(); 195 if (mol == NULL) { 196 MolNo = 0; 197 atomInfo.set(PdbKey::resSeq, "0"); 198 } else { 199 ASSERT(MolIdMap.find(mol->getId()) != MolIdMap.end(), 200 "PdbParser::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!"); 201 MolNo = MolIdMap[mol->getId()]; 202 atomInfo.set(PdbKey::resSeq, toString(MolIdMap[mol->getId()])); 203 if (atomInfo.get<std::string>(PdbKey::resName) == "-") 204 atomInfo.set(PdbKey::resName, mol->getName().substr(0,3)); 205 } 206 // get info about atom 171 207 const size_t Z = (*atomIt)->getType()->getAtomicNumber(); 172 sprintf(name, "%2s%02d",(*atomIt)->getType()->getSymbol().c_str(), elementNo[Z]); 173 elementNo[Z] = (elementNo[Z]+1) % 100; // confine to two digits 174 const molecule *mol = (*atomIt)->getMolecule(); 175 if (mol == NULL) { // for homeless atoms, MolNo = -1 is reserved 176 MolNo = -1; 177 } else { 178 MolNo = mol->getId(); 208 if (atomInfo.get<std::string>(PdbKey::name) == "-") { // if no name set, give it a new name 209 sprintf(name, "%2s%02d",(*atomIt)->getType()->getSymbol().c_str(), (*elementNo[MolNo])[Z]); 210 (*elementNo[MolNo])[Z] = ((*elementNo[MolNo])[Z]+1) % 100; // confine to two digits 211 atomInfo.set(PdbKey::name, name); 179 212 } 180 saveLine(file, *atomIt, name, AtomNo, MolNo); 181 setAtomId((*atomIt)->getId(), AtomNo); 213 // set position 214 for (size_t i=0; i<NDIM;++i) { 215 stringstream position; 216 position << setw(8) << fixed << setprecision(3) << (*atomIt)->getPosition().at(i); 217 atomInfo.set(PositionEnumMap[i], position.str()); 218 } 219 // change element and charge if changed 220 if (atomInfo.get<std::string>(PdbKey::element) != (*atomIt)->getType()->getSymbol()) 221 atomInfo.set(PdbKey::element, (*atomIt)->getType()->getSymbol()); 222 setSerial((*atomIt)->getId(), AtomNo); 223 atomInfo.set(PdbKey::serial, toString(AtomNo)); 224 225 // finally save the line 226 saveLine(file, atomInfo); 182 227 AtomNo++; 183 228 } 229 for (size_t i = 0; i < MaxMol; ++i) 230 delete elementNo[i]; 231 delete elementNo; 184 232 185 233 // write CONECTs … … 198 246 * \param stream where to write the line to 199 247 * \param *currentAtom the atom of which information should be written 248 * \param AtomNo serial number of atom 200 249 * \param *name name of atom, i.e. H01 201 * \param AtomNo serial number of atom250 * \param ResidueName Name of molecule 202 251 * \param ResidueNo number of residue 203 252 */ 204 void PdbParser::saveLine(ostream* file, const atom* currentAtom, const char *name, const int AtomNo, const int ResidueNo) { 205 *file << "ATOM "; 206 *file << setw(6) << AtomNo; /* atom serial number */ 207 *file << setw(1) << " "; 208 *file << setfill(' ') << left << setw(4) << name << right; /* atom name */ 209 *file << setw(1) << " "; 210 *file << setfill(' ') << setw(3) << ((currentAtom->getMolecule() != NULL) ? currentAtom->getMolecule()->getName().substr(0,3) : "-"); /* residue name */ 211 *file << setw(1) << " "; 212 *file << setfill(' ') << setw(1) << (char)('a'+(unsigned char)(AtomNo % 26)); /* letter for chain */ 213 *file << setw(4) << ResidueNo; /* residue sequence number */ 214 *file << setw(4) << " "; 215 for (int i=0;i<NDIM;i++) { 216 *file << setw(8) << setprecision(3) << showpoint << currentAtom->at(i); /* positional coordinate in Angstroem */ 217 } 218 *file << setw(6) << setprecision(2) << showpoint << (double)currentAtom->getType()->getValence(); /* occupancy */ 219 *file << setw(6) << setprecision(2) << showpoint << (double)currentAtom->getType()->getNoValenceOrbitals(); /* temperature factor */ 220 *file << noshowpoint; 221 *file << setw(6) << " "; 222 *file << setw(4) << "0"; 223 *file << setfill(' ') << setw(2) << currentAtom->getType()->getSymbol(); 224 *file << setw(2) << "0"; 253 void PdbParser::saveLine( 254 ostream* file, 255 const PdbAtomInfoContainer &atomInfo) 256 { 257 *file << setfill(' ') << left << setw(6) 258 << atomInfo.get<std::string>(PdbKey::token); 259 *file << setfill(' ') << right << setw(5) 260 << atomInfo.get<int>(PdbKey::serial); /* atom serial number */ 261 *file << " "; /* char 12 is empty */ 262 *file << setfill(' ') << left << setw(4) 263 << atomInfo.get<std::string>(PdbKey::name); /* atom name */ 264 *file << setfill(' ') << left << setw(1) 265 << atomInfo.get<std::string>(PdbKey::altLoc); /* alternate location/conformation */ 266 *file << setfill(' ') << left << setw(3) 267 << atomInfo.get<std::string>(PdbKey::resName); /* residue name */ 268 *file << " "; /* char 21 is empty */ 269 *file << setfill(' ') << left << setw(1) 270 << atomInfo.get<std::string>(PdbKey::chainID); /* chain identifier */ 271 *file << setfill(' ') << left << setw(4) 272 << atomInfo.get<int>(PdbKey::resSeq); /* residue sequence number */ 273 *file << setfill(' ') << left << setw(1) 274 << atomInfo.get<std::string>(PdbKey::iCode); /* iCode */ 275 *file << " "; /* char 28-30 are empty */ 276 // have the following operate on stringstreams such that format specifiers 277 // only act on these 278 for (size_t i=0;i<NDIM;++i) { 279 stringstream position; 280 position << fixed << setprecision(3) << showpoint 281 << atomInfo.get<double>(PositionEnumMap[i]); 282 *file << setfill(' ') << right << setw(8) << position.str(); 283 } 284 { 285 stringstream occupancy; 286 occupancy << fixed << setprecision(2) << showpoint 287 << atomInfo.get<double>(PdbKey::occupancy); /* occupancy */ 288 *file << setfill(' ') << right << setw(6) << occupancy.str(); 289 } 290 { 291 stringstream tempFactor; 292 tempFactor << fixed << setprecision(2) << showpoint 293 << atomInfo.get<double>(PdbKey::tempFactor); /* temperature factor */ 294 *file << setfill(' ') << right << setw(6) << tempFactor.str(); 295 } 296 *file << " "; /* char 68-76 are empty */ 297 *file << setfill(' ') << right << setw(2) << atomInfo.get<std::string>(PdbKey::element); /* element */ 298 *file << setfill(' ') << right << setw(2) << atomInfo.get<int>(PdbKey::charge); /* charge */ 225 299 226 300 *file << endl; … … 240 314 if (MaxNo >= MaxnumberOfNeighbors) { 241 315 *file << "CONECT"; 242 *file << setw(5) << get AtomId(currentAtom->getId());316 *file << setw(5) << getSerial(currentAtom->getId()); 243 317 MaxNo = 0; 244 318 } 245 *file << setw(5) << get AtomId((*currentBond)->GetOtherAtom(currentAtom)->getId());319 *file << setw(5) << getSerial((*currentBond)->GetOtherAtom(currentAtom)->getId()); 246 320 MaxNo++; 247 321 if (MaxNo == MaxnumberOfNeighbors) … … 253 327 } 254 328 255 256 329 /** Retrieves a value from PdbParser::atomIdMap. 257 330 * \param atomid key … … 259 332 */ 260 333 size_t PdbParser::getSerial(const size_t atomid) const 261 {262 ConvertTo<size_t> toSize_t;263 ASSERT(additionalAtomData.find(atomid) != additionalAtomData.end(),264 "PdbParser::getSerial: atomid "+toString(atomid)+" not present in Map.");265 const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(atomid);266 267 return toSize_t(atomInfo.get(PdbKey::serial));268 }269 270 /** Retrieves a value from PdbParser::atomIdMap.271 * \param atomid key272 * \return value273 */274 size_t PdbParser::getAtomId(const size_t atomid) const275 334 { 276 335 ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), "PdbParser::getAtomId: atomid not present in Map."); … … 283 342 * \return true - key not present, false - value present 284 343 */ 285 void PdbParser::set AtomId(const size_t localatomid, const size_t atomid)344 void PdbParser::setSerial(const size_t localatomid, const size_t atomid) 286 345 { 287 346 pair<std::map<size_t,size_t>::iterator, bool > inserter; 288 DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting ("289 << localatomid << " -> " << atomid << ")." << std::endl);347 // DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting (" 348 // << localatomid << " -> " << atomid << ")." << std::endl); 290 349 inserter = atomIdMap.insert( make_pair(localatomid, atomid) ); 291 350 ASSERT(inserter.second, "PdbParser::setAtomId: atomId already present in Map."); … … 314 373 315 374 lineStream << line; 375 atomInfo.set(PdbKey::token, line.substr(0,6)); 316 376 atomInfo.set(PdbKey::serial, line.substr(6,5)); 317 377 std::pair< std::set<size_t>::const_iterator, bool> Inserter = 318 SerialSet.insert(toSize_t(atomInfo.get (PdbKey::serial)));378 SerialSet.insert(toSize_t(atomInfo.get<std::string>(PdbKey::serial))); 319 379 ASSERT(Inserter.second, 320 380 "PdbParser::readAtomDataLine() - ATOM contains entry with serial " 321 +atomInfo.get (PdbKey::serial)+" already present!");381 +atomInfo.get<std::string>(PdbKey::serial)+" already present!"); 322 382 // assign hightest+1 instead, but then beware of CONECT entries! Another map needed! 323 383 // if (!Inserter.second) { … … 326 386 // atomInfo.set(PdbKey::serial, toString(id)); 327 387 // DoeLog(2) && (eLog() << Verbose(2) 328 // << "Serial " << atomInfo.get (PdbKey::serial) << " already present, "388 // << "Serial " << atomInfo.get<std::string>(PdbKey::serial) << " already present, " 329 389 // << "assigning " << toString(id) << " instead." << std::endl); 330 390 // } … … 348 408 // << line.substr(78,2) << std::endl); 349 409 350 set AtomId(toSize_t(atomInfo.get(PdbKey::serial)), newAtom->getId());410 setSerial(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId()); 351 411 atomInfo.set(PdbKey::name, line.substr(12,4)); 352 atomInfo.set(PdbKey::alt loc, line.substr(16,1));412 atomInfo.set(PdbKey::altLoc, line.substr(16,1)); 353 413 atomInfo.set(PdbKey::resName, line.substr(17,3)); 354 414 atomInfo.set(PdbKey::chainID, line.substr(21,1)); … … 364 424 atomInfo.set(PdbKey::tempFactor, line.substr(60,6)); 365 425 atomInfo.set(PdbKey::charge, line.substr(78,2)); 366 PdbAtomInfoContainer::ScanKey(word, line.substr(76,2)); 367 newAtom->setType(World::getInstance().getPeriode()->FindElement(word)); 426 atomInfo.set(PdbKey::element, line.substr(76,2)); 427 const element *elem = World::getInstance().getPeriode() 428 ->FindElement(atomInfo.get<std::string>(PdbKey::element)); 429 ASSERT(elem != NULL, 430 "PdbParser::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!"); 431 newAtom->setType(elem); 368 432 369 433 if (newmol != NULL) … … 381 445 382 446 DoLog(1) && (Log() << Verbose(1) << "We know about atom " << newAtom->getId() << ":" << std::endl); 383 DoLog(1) && (Log() << Verbose(1) << "\tserial is " << atomInfo.get(PdbKey::serial) << std::endl); 384 DoLog(1) && (Log() << Verbose(1) << "\tname is " << atomInfo.get(PdbKey::name) << std::endl); 385 DoLog(1) && (Log() << Verbose(1) << "\taltloc is " << atomInfo.get(PdbKey::altloc) << std::endl); 386 DoLog(1) && (Log() << Verbose(1) << "\tresName is " << atomInfo.get(PdbKey::resName) << std::endl); 387 DoLog(1) && (Log() << Verbose(1) << "\tchainID is " << atomInfo.get(PdbKey::chainID) << std::endl); 388 DoLog(1) && (Log() << Verbose(1) << "\tresSeq is " << atomInfo.get(PdbKey::resSeq) << std::endl); 389 DoLog(1) && (Log() << Verbose(1) << "\tiCode is " << atomInfo.get(PdbKey::iCode) << std::endl); 390 DoLog(1) && (Log() << Verbose(1) << "\tx is " << newAtom->getPosition() << std::endl); 391 DoLog(1) && (Log() << Verbose(1) << "\toccupancy is " << atomInfo.get(PdbKey::occupancy) << std::endl); 392 DoLog(1) && (Log() << Verbose(1) << "\ttempFactor is " << atomInfo.get(PdbKey::tempFactor) << std::endl); 447 DoLog(1) && (Log() << Verbose(1) << "\ttoken is " << atomInfo.get<std::string>(PdbKey::token) << std::endl); 448 DoLog(1) && (Log() << Verbose(1) << "\tserial is " << atomInfo.get<int>(PdbKey::serial) << std::endl); 449 DoLog(1) && (Log() << Verbose(1) << "\tname is " << atomInfo.get<std::string>(PdbKey::name) << std::endl); 450 DoLog(1) && (Log() << Verbose(1) << "\taltLoc is " << atomInfo.get<std::string>(PdbKey::altLoc) << std::endl); 451 DoLog(1) && (Log() << Verbose(1) << "\tresName is " << atomInfo.get<std::string>(PdbKey::resName) << std::endl); 452 DoLog(1) && (Log() << Verbose(1) << "\tchainID is " << atomInfo.get<std::string>(PdbKey::chainID) << std::endl); 453 DoLog(1) && (Log() << Verbose(1) << "\tresSeq is " << atomInfo.get<int>(PdbKey::resSeq) << std::endl); 454 DoLog(1) && (Log() << Verbose(1) << "\tiCode is " << atomInfo.get<std::string>(PdbKey::iCode) << std::endl); 455 DoLog(1) && (Log() << Verbose(1) << "\tX is " << atomInfo.get<double>(PdbKey::X) << std::endl); 456 DoLog(1) && (Log() << Verbose(1) << "\tY is " << atomInfo.get<double>(PdbKey::Y) << std::endl); 457 DoLog(1) && (Log() << Verbose(1) << "\tZ is " << atomInfo.get<double>(PdbKey::Z) << std::endl); 458 DoLog(1) && (Log() << Verbose(1) << "\toccupancy is " << atomInfo.get<double>(PdbKey::occupancy) << std::endl); 459 DoLog(1) && (Log() << Verbose(1) << "\ttempFactor is " << atomInfo.get<double>(PdbKey::tempFactor) << std::endl); 393 460 DoLog(1) && (Log() << Verbose(1) << "\telement is '" << *(newAtom->getType()) << "'" << std::endl); 394 DoLog(1) && (Log() << Verbose(1) << "\tcharge is " << atomInfo.get (PdbKey::charge) << std::endl);461 DoLog(1) && (Log() << Verbose(1) << "\tcharge is " << atomInfo.get<int>(PdbKey::charge) << std::endl); 395 462 } 396 463 … … 426 493 427 494 // add neighbours 428 atom *_atom = World::getInstance().getAtom(AtomById(get AtomId(id)));495 atom *_atom = World::getInstance().getAtom(AtomById(getSerial(id))); 429 496 for (std::list<size_t>::const_iterator iter = ListOfNeighbors.begin(); 430 497 iter != ListOfNeighbors.end(); 431 498 ++iter) { 432 499 // DoLog(1) && (Log() << Verbose(1) << "Adding Bond (" << getAtomId(id) << "," << getAtomId(*iter) << ")" << std::endl); 433 atom * const _Otheratom = World::getInstance().getAtom(AtomById(get AtomId(*iter)));500 atom * const _Otheratom = World::getInstance().getAtom(AtomById(getSerial(*iter))); 434 501 _atom->addBond(_Otheratom); 435 502 } … … 478 545 const PdbAtomInfoContainer &OtheratomInfo = b.additionalAtomData.at((*iter)->getId()); 479 546 480 status = status && (atomInfo.get (PdbKey::serial) == OtheratomInfo.get(PdbKey::serial));547 status = status && (atomInfo.get<std::string>(PdbKey::serial) == OtheratomInfo.get<std::string>(PdbKey::serial)); 481 548 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in serials!" << std::endl); 482 status = status && (atomInfo.get (PdbKey::name) == OtheratomInfo.get(PdbKey::name));549 status = status && (atomInfo.get<std::string>(PdbKey::name) == OtheratomInfo.get<std::string>(PdbKey::name)); 483 550 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in names!" << std::endl); 484 status = status && (atomInfo.get (PdbKey::altloc) == OtheratomInfo.get(PdbKey::altloc));485 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in alt locs!" << std::endl);486 status = status && (atomInfo.get (PdbKey::resName) == OtheratomInfo.get(PdbKey::resName));551 status = status && (atomInfo.get<std::string>(PdbKey::altLoc) == OtheratomInfo.get<std::string>(PdbKey::altLoc)); 552 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in altLocs!" << std::endl); 553 status = status && (atomInfo.get<std::string>(PdbKey::resName) == OtheratomInfo.get<std::string>(PdbKey::resName)); 487 554 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in resNames!" << std::endl); 488 status = status && (atomInfo.get (PdbKey::chainID) == OtheratomInfo.get(PdbKey::chainID));555 status = status && (atomInfo.get<std::string>(PdbKey::chainID) == OtheratomInfo.get<std::string>(PdbKey::chainID)); 489 556 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in chainIDs!" << std::endl); 490 status = status && (atomInfo.get (PdbKey::resSeq) == OtheratomInfo.get(PdbKey::resSeq));557 status = status && (atomInfo.get<std::string>(PdbKey::resSeq) == OtheratomInfo.get<std::string>(PdbKey::resSeq)); 491 558 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in resSeqs!" << std::endl); 492 status = status && (atomInfo.get (PdbKey::iCode) == OtheratomInfo.get(PdbKey::iCode));559 status = status && (atomInfo.get<std::string>(PdbKey::iCode) == OtheratomInfo.get<std::string>(PdbKey::iCode)); 493 560 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in iCodes!" << std::endl); 494 status = status && (atomInfo.get (PdbKey::occupancy) == OtheratomInfo.get(PdbKey::occupancy));561 status = status && (atomInfo.get<std::string>(PdbKey::occupancy) == OtheratomInfo.get<std::string>(PdbKey::occupancy)); 495 562 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in occupancies!" << std::endl); 496 status = status && (atomInfo.get (PdbKey::tempFactor) == OtheratomInfo.get(PdbKey::tempFactor));563 status = status && (atomInfo.get<std::string>(PdbKey::tempFactor) == OtheratomInfo.get<std::string>(PdbKey::tempFactor)); 497 564 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in tempFactors!" << std::endl); 498 status = status && (atomInfo.get (PdbKey::charge) == OtheratomInfo.get(PdbKey::charge));565 status = status && (atomInfo.get<std::string>(PdbKey::charge) == OtheratomInfo.get<std::string>(PdbKey::charge)); 499 566 if (!status) DoeLog(1) && (eLog() << Verbose(1) << "Mismatch in charges!" << std::endl); 500 567 } -
src/Parser/PdbParser.hpp
r24f128 r16462f 38 38 bool isUsedField(std::string fieldName); 39 39 void writeNeighbors(std::ostream* file, int numberOfNeighbors, atom* currentAtom); 40 void saveLine(ostream* file, const atom* currentAtom, const char *name, const int AtomNo, const int ResdueNo);40 void saveLine(ostream* file, const PdbAtomInfoContainer &atomInfo); 41 41 42 42 // internal getter and setter 43 43 size_t getSerial(const size_t atomid) const; 44 size_t getAtomId(const size_t atomid) const; 45 void setAtomId(const size_t localatomid, const size_t atomid); 44 void setSerial(const size_t localatomid, const size_t atomid); 45 46 /** 47 * argh, why can't just PdbKey::X+(size_t)i 48 */ 49 std::map<size_t, PdbKey::PdbDataKey> PositionEnumMap; 46 50 47 51 /**
Note:
See TracChangeset
for help on using the changeset viewer.