Changes in src/Parser/PdbParser.cpp [765f16:3bdb6d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/PdbParser.cpp
r765f16 r3bdb6d 28 28 #include "atom.hpp" 29 29 #include "Bond/bond.hpp" 30 #include " element.hpp"30 #include "Element/element.hpp" 31 31 #include "molecule.hpp" 32 #include " periodentafel.hpp"32 #include "Element/periodentafel.hpp" 33 33 #include "Descriptors/AtomIdDescriptor.hpp" 34 34 #include "Parser/PdbParser.hpp" … … 44 44 using namespace std; 45 45 46 // declare specialized static variables47 const std::string FormatParserTrait<pdb>::name = "pdb";48 const std::string FormatParserTrait<pdb>::suffix = "pdb";49 const ParserTypes FormatParserTrait<pdb>::type = pdb;50 51 46 /** 52 47 * Constructor. 53 48 */ 54 FormatParser< pdb >::FormatParser() : 55 FormatParser_common(NULL) 56 { 49 PdbParser::PdbParser() { 57 50 knownTokens["ATOM"] = PdbKey::Atom; 58 51 knownTokens["HETATM"] = PdbKey::Atom; … … 72 65 * Destructor. 73 66 */ 74 FormatParser< pdb >::~FormatParser() 75 { 67 PdbParser::~PdbParser() { 76 68 PdbAtomInfoContainer::clearknownDataKeys(); 77 69 additionalAtomData.clear(); … … 85 77 * @return token type 86 78 */ 87 enum PdbKey::KnownTokens FormatParser< pdb >::getToken(string &line)79 enum PdbKey::KnownTokens PdbParser::getToken(string &line) 88 80 { 89 81 // look for first space … … 113 105 * \param PDB file 114 106 */ 115 void FormatParser< pdb >::load(istream* file) {107 void PdbParser::load(istream* file) { 116 108 string line; 117 109 size_t linecount = 0; … … 156 148 // TODO: put a throw here 157 149 DoeLog(2) && (eLog() << Verbose(2) << "Unknown token: '" << line << "' for time step " << step << "." << std::endl); 158 //ASSERT(0, " FormatParser< pdb >::load() - Unknown token in line "+toString(linecount)+": "+line+".");150 //ASSERT(0, "PdbParser::load() - Unknown token in line "+toString(linecount)+": "+line+"."); 159 151 break; 160 152 } … … 178 170 * \param atoms atoms to store 179 171 */ 180 void FormatParser< pdb >::save(ostream* file, const std::vector<atom *> &AtomList)172 void PdbParser::save(ostream* file, const std::vector<atom *> &AtomList) 181 173 { 182 174 DoLog(0) && (Log() << Verbose(0) << "Saving changes to pdb." << std::endl); … … 248 240 } else { 249 241 ASSERT(MolIdMap.find(mol->getId()) != MolIdMap.end(), 250 " FormatParser< pdb >::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!");242 "PdbParser::save() - Mol id "+toString(mol->getId())+" not present despite we set it?!"); 251 243 MolNo = MolIdMap[mol->getId()]; 252 244 atomInfo.set(PdbKey::resSeq, toString(MolIdMap[mol->getId()])); … … 297 289 * @param id of atom 298 290 */ 299 void FormatParser< pdb >::AtomInserted(atomId_t id)300 { 301 //LOG(3, " FormatParser< pdb >::AtomInserted() - notified of atom " << id << "'s insertion.");291 void PdbParser::AtomInserted(atomId_t id) 292 { 293 //LOG(3, "PdbParser::AtomInserted() - notified of atom " << id << "'s insertion."); 302 294 ASSERT(!isPresentadditionalAtomData(id), 303 " FormatParser< pdb >::AtomInserted() - additionalAtomData already present for newly added atom "295 "PdbParser::AtomInserted() - additionalAtomData already present for newly added atom " 304 296 +toString(id)+"."); 305 297 // don't insert here as this is our check whether we are in the first time step … … 312 304 * @param id of atom 313 305 */ 314 void FormatParser< pdb >::AtomRemoved(atomId_t id)315 { 316 //LOG(3, " FormatParser< pdb >::AtomRemoved() - notified of atom " << id << "'s removal.");306 void PdbParser::AtomRemoved(atomId_t id) 307 { 308 //LOG(3, "PdbParser::AtomRemoved() - notified of atom " << id << "'s removal."); 317 309 std::map<size_t, PdbAtomInfoContainer>::iterator iter = additionalAtomData.find(id); 318 310 // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence 319 311 // ASSERT(iter != additionalAtomData.end(), 320 // " FormatParser< pdb >::AtomRemoved() - additionalAtomData is not present for atom "312 // "PdbParser::AtomRemoved() - additionalAtomData is not present for atom " 321 313 // +toString(id)+" to remove."); 322 314 if (iter != additionalAtomData.end()) { … … 333 325 * @return true - entry present, false - only for atom's father or no entry 334 326 */ 335 bool FormatParser< pdb >::isPresentadditionalAtomData(unsigned int _id)327 bool PdbParser::isPresentadditionalAtomData(unsigned int _id) 336 328 { 337 329 return (additionalAtomData.find(_id) != additionalAtomData.end()); … … 344 336 * @return 345 337 */ 346 PdbAtomInfoContainer& FormatParser< pdb >::getadditionalAtomData(atom *_atom)338 PdbAtomInfoContainer& PdbParser::getadditionalAtomData(atom *_atom) 347 339 { 348 340 if (additionalAtomData.find(_atom->getId()) != additionalAtomData.end()) { … … 370 362 * \param ResidueNo number of residue 371 363 */ 372 void FormatParser< pdb >::saveLine(364 void PdbParser::saveLine( 373 365 ostream* file, 374 366 const PdbAtomInfoContainer &atomInfo) … … 431 423 * \param *currentAtom to the atom of which to take the neighbor information 432 424 */ 433 void FormatParser< pdb >::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) {425 void PdbParser::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) { 434 426 int MaxNo = MaxnumberOfNeighbors; 435 427 int charsleft = 80; … … 460 452 } 461 453 462 /** Retrieves a value from FormatParser< pdb >::atomIdMap.454 /** Retrieves a value from PdbParser::atomIdMap. 463 455 * \param atomid key 464 456 * \return value 465 457 */ 466 size_t FormatParser< pdb >::getSerial(const size_t atomid) const467 { 468 ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), 469 " FormatParser< pdb >::getAtomId:atomid "+toString(atomid)+" not present in Map.");458 size_t PdbParser::getSerial(const size_t atomid) const 459 { 460 ASSERT(atomIdMap.find(atomid) != atomIdMap.end(), 461 "PdbParser::getSerial() - atomid "+toString(atomid)+" not present in Map."); 470 462 return (atomIdMap.find(atomid)->second); 471 463 } 472 464 473 /** Sets an entry in FormatParser< pdb >::atomIdMap.465 /** Sets an entry in PdbParser::atomIdMap. 474 466 * \param localatomid key 475 467 * \param atomid value 476 468 * \return true - key not present, false - value present 477 469 */ 478 void FormatParser< pdb >::setSerial(const size_t localatomid, const size_t atomid)470 void PdbParser::setSerial(const size_t localatomid, const size_t atomid) 479 471 { 480 472 pair<std::map<size_t,size_t>::iterator, bool > inserter; 481 // DoLog(1) && (Log() << Verbose(1) << " FormatParser< pdb >::setAtomId() - Inserting ("473 // DoLog(1) && (Log() << Verbose(1) << "PdbParser::setAtomId() - Inserting (" 482 474 // << localatomid << " -> " << atomid << ")." << std::endl); 483 475 inserter = atomIdMap.insert( make_pair(localatomid, atomid) ); 484 ASSERT(inserter.second, " FormatParser< pdb >::setAtomId: atomId already present in Map.");476 ASSERT(inserter.second, "PdbParser::setAtomId: atomId already present in Map."); 485 477 } 486 478 … … 490 482 * @return 491 483 */ 492 atom* FormatParser< pdb >::getAtomToParse(std::string id_string) const484 atom* PdbParser::getAtomToParse(std::string id_string) const 493 485 { 494 486 // get the local ID … … 525 517 * @param line line containing key ATOM 526 518 */ 527 void FormatParser< pdb >::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const519 void PdbParser::readPdbAtomInfoContainer(PdbAtomInfoContainer &atomInfo, std::string &line) const 528 520 { 529 521 const size_t length = line.length(); 530 522 if (length < 80) 531 ELOG(2, " FormatParser< pdb >::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!");523 ELOG(2, "PdbParser::readPdbAtomInfoContainer() - pdb is mal-formed, containing less than 80 chars!"); 532 524 if (length >= 6) { 533 525 LOG(4,"INFO: Parsing token from "+line.substr(0,6)+"."); … … 538 530 atomInfo.set(PdbKey::serial, line.substr(6,5)); 539 531 ASSERT(atomInfo.get<int>(PdbKey::serial) != 0, 540 " FormatParser< pdb >::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries).");532 "PdbParser::readPdbAtomInfoContainer() - serial 0 is invalid (filler id for conect entries)."); 541 533 } 542 534 … … 599 591 * \param newmol molecule to add parsed atoms to 600 592 */ 601 void FormatParser< pdb >::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) {593 void PdbParser::readAtomDataLine(const unsigned int _step, std::string &line, molecule *newmol = NULL) { 602 594 vector<string>::iterator it; 603 595 … … 606 598 bool FirstTimestep = isPresentadditionalAtomData(newAtom->getId()) ? false : true; 607 599 ASSERT((FirstTimestep && (_step == 0)) || (!FirstTimestep && (_step !=0)), 608 " FormatParser< pdb >::readAtomDataLine() - additionalAtomData present though atom is newly parsed.");600 "PdbParser::readAtomDataLine() - additionalAtomData present though atom is newly parsed."); 609 601 if (FirstTimestep) { 610 602 LOG(3,"INFO: Parsing new atom."); … … 654 646 SerialSet.insert(toSize_t(atomInfo.get<std::string>(PdbKey::serial))); 655 647 ASSERT(Inserter.second, 656 " FormatParser< pdb >::readAtomDataLine() - ATOM contains entry with serial "648 "PdbParser::readAtomDataLine() - ATOM contains entry with serial " 657 649 +atomInfo.get<std::string>(PdbKey::serial)+" already present!"); 658 650 setSerial(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId()); … … 675 667 ->FindElement(value); 676 668 ASSERT(elem != NULL, 677 " FormatParser< pdb >::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!");669 "PdbParser::readAtomDataLine() - element "+atomInfo.get<std::string>(PdbKey::element)+" is unknown!"); 678 670 newAtom->setType(elem); 679 671 … … 687 679 // then check additional info for consistency 688 680 ASSERT(atomInfo.get<std::string>(PdbKey::token) == consistencyInfo.get<std::string>(PdbKey::token), 689 " FormatParser< pdb >::readAtomDataLine() - difference in token on multiple time step for atom with id "681 "PdbParser::readAtomDataLine() - difference in token on multiple time step for atom with id " 690 682 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 691 683 ASSERT(atomInfo.get<std::string>(PdbKey::name) == consistencyInfo.get<std::string>(PdbKey::name), 692 " FormatParser< pdb >::readAtomDataLine() - difference in name on multiple time step for atom with id "684 "PdbParser::readAtomDataLine() - difference in name on multiple time step for atom with id " 693 685 +atomInfo.get<std::string>(PdbKey::serial)+":" 694 686 +atomInfo.get<std::string>(PdbKey::name)+"!=" 695 687 +consistencyInfo.get<std::string>(PdbKey::name)+"."); 696 688 ASSERT(atomInfo.get<std::string>(PdbKey::altLoc) == consistencyInfo.get<std::string>(PdbKey::altLoc), 697 " FormatParser< pdb >::readAtomDataLine() - difference in altLoc on multiple time step for atom with id "689 "PdbParser::readAtomDataLine() - difference in altLoc on multiple time step for atom with id " 698 690 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 699 691 ASSERT(atomInfo.get<std::string>(PdbKey::resName) == consistencyInfo.get<std::string>(PdbKey::resName), 700 " FormatParser< pdb >::readAtomDataLine() - difference in resName on multiple time step for atom with id "692 "PdbParser::readAtomDataLine() - difference in resName on multiple time step for atom with id " 701 693 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 702 694 ASSERT(atomInfo.get<std::string>(PdbKey::chainID) == consistencyInfo.get<std::string>(PdbKey::chainID), 703 " FormatParser< pdb >::readAtomDataLine() - difference in chainID on multiple time step for atom with id "695 "PdbParser::readAtomDataLine() - difference in chainID on multiple time step for atom with id " 704 696 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 705 697 ASSERT(atomInfo.get<std::string>(PdbKey::resSeq) == consistencyInfo.get<std::string>(PdbKey::resSeq), 706 " FormatParser< pdb >::readAtomDataLine() - difference in resSeq on multiple time step for atom with id "698 "PdbParser::readAtomDataLine() - difference in resSeq on multiple time step for atom with id " 707 699 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 708 700 ASSERT(atomInfo.get<std::string>(PdbKey::iCode) == consistencyInfo.get<std::string>(PdbKey::iCode), 709 " FormatParser< pdb >::readAtomDataLine() - difference in iCode on multiple time step for atom with id "701 "PdbParser::readAtomDataLine() - difference in iCode on multiple time step for atom with id " 710 702 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 711 703 ASSERT(atomInfo.get<std::string>(PdbKey::occupancy) == consistencyInfo.get<std::string>(PdbKey::occupancy), 712 " FormatParser< pdb >::readAtomDataLine() - difference in occupancy on multiple time step for atom with id "704 "PdbParser::readAtomDataLine() - difference in occupancy on multiple time step for atom with id " 713 705 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 714 706 ASSERT(atomInfo.get<std::string>(PdbKey::tempFactor) == consistencyInfo.get<std::string>(PdbKey::tempFactor), 715 " FormatParser< pdb >::readAtomDataLine() - difference in tempFactor on multiple time step for atom with id "707 "PdbParser::readAtomDataLine() - difference in tempFactor on multiple time step for atom with id " 716 708 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 717 709 ASSERT(atomInfo.get<std::string>(PdbKey::charge) == consistencyInfo.get<std::string>(PdbKey::charge), 718 " FormatParser< pdb >::readAtomDataLine() - difference in charge on multiple time step for atom with id "710 "PdbParser::readAtomDataLine() - difference in charge on multiple time step for atom with id " 719 711 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 720 712 ASSERT(atomInfo.get<std::string>(PdbKey::element) == consistencyInfo.get<std::string>(PdbKey::element), 721 " FormatParser< pdb >::readAtomDataLine() - difference in element on multiple time step for atom with id "713 "PdbParser::readAtomDataLine() - difference in element on multiple time step for atom with id " 722 714 +atomInfo.get<std::string>(PdbKey::serial)+"!"); 723 715 // and parse in trajectory … … 742 734 * 743 735 */ 744 void FormatParser< pdb >::printAtomInfo(const atom * const newAtom) const736 void PdbParser::printAtomInfo(const atom * const newAtom) const 745 737 { 746 738 const PdbAtomInfoContainer &atomInfo = additionalAtomData.at(newAtom->getId()); // operator[] const does not exist … … 770 762 * \param line to parse as an atom 771 763 */ 772 void FormatParser< pdb >::readNeighbors(const unsigned int _step, std::string &line)764 void PdbParser::readNeighbors(const unsigned int _step, std::string &line) 773 765 { 774 766 const size_t length = line.length(); … … 780 772 string output; 781 773 ASSERT(length >=16, 782 " FormatParser< pdb >::readNeighbors() - CONECT entry has not enough entries: "+line+"!");783 //output = "Split line:|";784 //output += line.substr(6,5) + "|";774 "PdbParser::readNeighbors() - CONECT entry has not enough entries: "+line+"!"); 775 output = "Split line:|"; 776 output += line.substr(6,5) + "|"; 785 777 const size_t id = toSize_t(line.substr(6,5)); 786 778 for (size_t index = 11; index <= 26; index+=5) { … … 793 785 ListOfNeighbors.push_back(otherid); 794 786 else 795 ELOG(2, " FormatParser< pdb >::readNeighbors() - discarding conect entry with id 0.");787 ELOG(2, "PdbParser::readNeighbors() - discarding conect entry with id 0."); 796 788 } else { 797 789 break; … … 821 813 * \return input string with modified atom IDs 822 814 */ 823 //string FormatParser< pdb >::adaptIdDependentDataString(string data) {815 //string PdbParser::adaptIdDependentDataString(string data) { 824 816 // // there might be no IDs 825 817 // if (data == "-") { … … 844 836 845 837 846 bool FormatParser< pdb >::operator==(const FormatParser< pdb >& b) const838 bool PdbParser::operator==(const PdbParser& b) const 847 839 { 848 840 bool status = true;
Note:
See TracChangeset
for help on using the changeset viewer.