Changeset c0e28c for src/Parser/PdbParser.cpp
- Timestamp:
- Jan 6, 2012, 2:02:08 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:
- d08ab3
- Parents:
- fbbcde
- git-author:
- Frederik Heber <heber@…> (01/04/12 18:34:22)
- git-committer:
- Frederik Heber <heber@…> (01/06/12 14:02:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/PdbParser.cpp
rfbbcde rc0e28c 76 76 PdbAtomInfoContainer::clearknownDataKeys(); 77 77 additionalAtomData.clear(); 78 atomIdMap.clear();79 78 } 80 79 … … 118 117 enum PdbKey::KnownTokens token; 119 118 120 // reset atomIdMapfor this file (to correctly parse CONECT entries)121 atomIdMap.clear();119 // reset id maps for this file (to correctly parse CONECT entries) 120 resetIdAssociations(); 122 121 123 122 bool NotEndOfFile = true; … … 192 191 193 192 // re-distribute serials 193 resetIdAssociations(); 194 194 // (new atoms might have been added) 195 // (serials must be consistent over time steps)196 atomIdMap.clear();197 195 int AtomNo = 1; // serial number starts at 1 in pdb 198 196 for (vector<atom *>::const_iterator atomIt = AtomList.begin(); atomIt != AtomList.end(); atomIt++) { 199 197 PdbAtomInfoContainer &atomInfo = getadditionalAtomData(*atomIt); 200 setSerial((*atomIt)->getId(), AtomNo);198 associateLocaltoGlobalId(AtomNo, (*atomIt)->getId()); 201 199 atomInfo.set(PdbKey::serial, toString(AtomNo)); 202 AtomNo++;200 ++AtomNo; 203 201 } 204 202 … … 305 303 // don't insert here as this is our check whether we are in the first time step 306 304 //additionalAtomData.insert( std::make_pair(id, defaultAdditionalData) ); 307 //SerialSet.insert(id);308 305 } 309 306 … … 321 318 // +toString(id)+" to remove."); 322 319 if (iter != additionalAtomData.end()) { 323 ConvertTo<size_t> toSize_t;324 SerialSet.erase(toSize_t((iter->second).get<std::string>(PdbKey::serial)));325 320 additionalAtomData.erase(iter); 326 321 } … … 439 434 if (MaxNo >= MaxnumberOfNeighbors) { 440 435 *file << "CONECT"; 441 *file << setw(5) << get Serial(currentAtom->getId());436 *file << setw(5) << getLocalId(currentAtom->getId()); 442 437 charsleft = 80-6-5; 443 438 MaxNo = 0; 444 439 } 445 *file << setw(5) << get Serial((*currentBond)->GetOtherAtom(currentAtom)->getId());440 *file << setw(5) << getLocalId((*currentBond)->GetOtherAtom(currentAtom)->getId()); 446 441 charsleft -= 5; 447 442 MaxNo++; … … 460 455 } 461 456 462 /** Retrieves a value from FormatParser< pdb >::atomIdMap.463 * \param atomid key464 * \return value465 */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.");470 return (atomIdMap.find(atomid)->second);471 }472 473 /** Sets an entry in FormatParser< pdb >::atomIdMap.474 * \param localatomid key475 * \param atomid value476 * \return true - key not present, false - value present477 */478 void FormatParser< pdb >::setSerial(const size_t localatomid, const size_t atomid)479 {480 pair<std::map<size_t,size_t>::iterator, bool > inserter;481 // LOG(1, "FormatParser< pdb >::setAtomId() - Inserting (" << localatomid << " -> " << atomid << ").");482 inserter = atomIdMap.insert( make_pair(localatomid, atomid) );483 ASSERT(inserter.second, "FormatParser< pdb >::setAtomId: atomId already present in Map.");484 }485 486 457 /** Either returns present atom with given id or a newly created one. 487 458 * … … 489 460 * @return 490 461 */ 491 atom* FormatParser< pdb >::getAtomToParse(std::string id_string) const462 atom* FormatParser< pdb >::getAtomToParse(std::string id_string) 492 463 { 493 464 // get the local ID 494 465 ConvertTo<int> toInt; 495 unsigned int AtomID= toInt(id_string);496 LOG(4, "INFO: Local id is "+toString(AtomID )+".");466 const unsigned int AtomID_local = toInt(id_string); 467 LOG(4, "INFO: Local id is "+toString(AtomID_local)+"."); 497 468 // get the atomic ID if present 498 469 atom* newAtom = NULL; 499 if (atomIdMap.count((size_t)AtomID)) { 500 std::map<size_t, size_t>::const_iterator iter = atomIdMap.find(AtomID); 501 AtomID = iter->second; 502 LOG(4, "INFO: Global id present as " << AtomID << "."); 470 if (getGlobalId(AtomID_local) != -1) { 471 const unsigned int AtomID_global = getGlobalId(AtomID_local); 472 LOG(4, "INFO: Global id present as " << AtomID_global << "."); 503 473 // check if atom exists 504 newAtom = World::getInstance().getAtom(AtomById(AtomID ));474 newAtom = World::getInstance().getAtom(AtomById(AtomID_global)); 505 475 LOG(5, "INFO: Listing all present atoms with id."); 506 476 BOOST_FOREACH(atom *_atom, World::getInstance().getAllAtoms()) … … 510 480 if (newAtom == NULL) { 511 481 newAtom = World::getInstance().createAtom(); 482 const unsigned int AtomID_global = newAtom->getId(); 512 483 LOG(4, "INFO: No association to global id present, creating atom."); 513 484 } else { … … 607 578 "FormatParser< pdb >::readAtomDataLine() - additionalAtomData present though atom is newly parsed."); 608 579 if (FirstTimestep) { 609 LOG(3,"INFO: Parsing new atom .");580 LOG(3,"INFO: Parsing new atom "+toString(*newAtom)+" "+toString(newAtom->getId())+"."); 610 581 } else { 611 582 LOG(3,"INFO: Parsing present atom "+toString(*newAtom)+"."); … … 616 587 string word; 617 588 ConvertTo<size_t> toSize_t; 618 619 // assign highest+1 instead, but then beware of CONECT entries! Another map needed!620 // if (!Inserter.second) {621 // const size_t id = (*SerialSet.rbegin())+1;622 // SerialSet.insert(id);623 // atomInfo.set(PdbKey::serial, toString(id));624 // ELOG(2, "Serial " << atomInfo.get<std::string>(PdbKey::serial) << " already present, "625 // << "assigning " << toString(id) << " instead.");626 // }627 589 628 590 // check whether serial exists, if so, assign next available … … 648 610 // then fill info container 649 611 readPdbAtomInfoContainer(atomInfo, line); 650 // set the serial 651 std::pair< std::set<size_t>::const_iterator, bool> Inserter = 652 SerialSet.insert(toSize_t(atomInfo.get<std::string>(PdbKey::serial))); 653 ASSERT(Inserter.second, 654 "FormatParser< pdb >::readAtomDataLine() - ATOM contains entry with serial " 655 +atomInfo.get<std::string>(PdbKey::serial)+" already present!"); 656 setSerial(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId()); 612 // associate local with global id 613 associateLocaltoGlobalId(toSize_t(atomInfo.get<std::string>(PdbKey::serial)), newAtom->getId()); 657 614 // set position 658 615 Vector tempVector; … … 791 748 ListOfNeighbors.push_back(otherid); 792 749 else 793 ELOG(2, "FormatParser< pdb >::readNeighbors() - discarding conectentry with id 0.");750 ELOG(2, "FormatParser< pdb >::readNeighbors() - discarding CONECT entry with id 0."); 794 751 } else { 795 752 break; … … 799 756 800 757 // add neighbours 801 atom *_atom = World::getInstance().getAtom(AtomById(get Serial(id)));758 atom *_atom = World::getInstance().getAtom(AtomById(getGlobalId(id))); 802 759 LOG(2, "STATUS: Atom " << _atom->getId() << " gets " << ListOfNeighbors.size() << " more neighbours."); 803 760 for (std::list<size_t>::const_iterator iter = ListOfNeighbors.begin(); 804 761 iter != ListOfNeighbors.end(); 805 762 ++iter) { 806 atom * const _Otheratom = World::getInstance().getAtom(AtomById(get Serial(*iter)));763 atom * const _Otheratom = World::getInstance().getAtom(AtomById(getGlobalId(*iter))); 807 764 LOG(3, "INFO: Adding Bond (" << *_atom << "," << *_Otheratom << ")"); 808 765 _atom->addBond(_step, _Otheratom); 809 766 } 810 767 } 811 812 /**813 * Replaces atom IDs read from the file by the corresponding world IDs. All IDs814 * IDs of the input string will be replaced; expected separating characters are815 * "-" and ",".816 *817 * \param string in which atom IDs should be adapted818 *819 * \return input string with modified atom IDs820 */821 //string FormatParser< pdb >::adaptIdDependentDataString(string data) {822 // // there might be no IDs823 // if (data == "-") {824 // return "-";825 // }826 //827 // char separator;828 // int id;829 // stringstream line, result;830 // line << data;831 //832 // line >> id;833 // result << atomIdMap[id];834 // while (line.good()) {835 // line >> separator >> id;836 // result << separator << atomIdMap[id];837 // }838 //839 // return result.str();840 // return "";841 //}842 843 768 844 769 bool FormatParser< pdb >::operator==(const FormatParser< pdb >& b) const
Note:
See TracChangeset
for help on using the changeset viewer.