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