Changeset 765f16 for src/Parser/TremoloParser.cpp
- Timestamp:
- Oct 14, 2011, 3:15:30 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:
- 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/TremoloParser.cpp
r9a6b76e r765f16 42 42 using namespace std; 43 43 44 // declare specialized static variables 45 const std::string FormatParserTrait<tremolo>::name = "tremolo"; 46 const std::string FormatParserTrait<tremolo>::suffix = "data"; 47 const ParserTypes FormatParserTrait<tremolo>::type = tremolo; 48 44 49 /** 45 50 * Constructor. 46 51 */ 47 TremoloParser::TremoloParser() { 52 FormatParser< tremolo >::FormatParser() : 53 FormatParser_common(NULL) 54 { 48 55 knownKeys["x"] = TremoloKey::x; 49 56 knownKeys["u"] = TremoloKey::u; … … 87 94 * Destructor. 88 95 */ 89 TremoloParser::~TremoloParser() { 90 std::cerr << "Clearing usedFields." << std::endl; 96 FormatParser< tremolo >::~FormatParser() 97 { 98 std::cerr << "Clearing usedFields." << std::endl; 91 99 usedFields.clear(); 92 100 additionalAtomData.clear(); … … 100 108 * \param tremolo file 101 109 */ 102 void TremoloParser::load(istream* file) {110 void FormatParser< tremolo >::load(istream* file) { 103 111 string line; 104 112 string::size_type location; … … 141 149 * \param atoms atoms to store 142 150 */ 143 void TremoloParser::save(ostream* file, const std::vector<atom *> &AtomList) {151 void FormatParser< tremolo >::save(ostream* file, const std::vector<atom *> &AtomList) { 144 152 DoLog(0) && (Log() << Verbose(0) << "Saving changes to tremolo." << std::endl); 145 153 … … 169 177 * @param id of atom 170 178 */ 171 void TremoloParser::AtomInserted(atomId_t id)179 void FormatParser< tremolo >::AtomInserted(atomId_t id) 172 180 { 173 181 std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id); 174 182 ASSERT(iter == additionalAtomData.end(), 175 " TremoloParser::AtomInserted() - additionalAtomData already present for newly added atom "183 "FormatParser< tremolo >::AtomInserted() - additionalAtomData already present for newly added atom " 176 184 +toString(id)+"."); 177 185 // don't add entry, as this gives a default resSeq of 0 not the molecule id … … 183 191 * @param id of atom 184 192 */ 185 void TremoloParser::AtomRemoved(atomId_t id)193 void FormatParser< tremolo >::AtomRemoved(atomId_t id) 186 194 { 187 195 std::map<int, TremoloAtomInfoContainer>::iterator iter = additionalAtomData.find(id); 188 196 // as we do not insert AtomData on AtomInserted, we cannot be assured of its presence 189 197 // ASSERT(iter != additionalAtomData.end(), 190 // " TremoloParser::AtomRemoved() - additionalAtomData is not present for atom "198 // "FormatParser< tremolo >::AtomRemoved() - additionalAtomData is not present for atom " 191 199 // +toString(id)+" to remove."); 192 200 if (iter != additionalAtomData.end()) … … 201 209 * but without the prexix "ATOMDATA" 202 210 */ 203 void TremoloParser::setFieldsForSave(std::string atomDataLine) {211 void FormatParser< tremolo >::setFieldsForSave(std::string atomDataLine) { 204 212 parseAtomDataKeysLine(atomDataLine, 0); 205 213 } … … 212 220 * \param reference to the atom of which information should be written 213 221 */ 214 void TremoloParser::saveLine(ostream* file, atom* currentAtom) { 215 /* vector<string>::iterator it;*/ 216 vector<string>::iterator it = unique(usedFields.begin(), usedFields.end()); // skips all duplicates in the vector 222 void FormatParser< tremolo >::saveLine(ostream* file, atom* currentAtom) { 223 //vector<string>::iterator it; 224 // TODO: Is unique for FormatParser< tremolo >::usedFields still required? 225 vector<string>::iterator it = unique(usedFields.begin(), usedFields.end()); // skips all duplicates in the vector 217 226 218 227 TremoloKey::atomDataKey currentField; … … 308 317 * \param reference to the atom of which to take the neighbor information 309 318 */ 310 void TremoloParser::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {319 void FormatParser< tremolo >::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) { 311 320 const BondList& ListOfBonds = currentAtom->getListOfBonds(); 312 321 // sort bonded indices … … 331 340 * \param with which offset the keys begin within the line 332 341 */ 333 void TremoloParser::parseAtomDataKeysLine(string line, int offset) {342 void FormatParser< tremolo >::parseAtomDataKeysLine(string line, int offset) { 334 343 string keyword; 335 344 stringstream lineStream; … … 353 362 * \a atomdata_string. 354 363 * 355 * We just call \sa TremoloParser::parseAtomDataKeysLine() which is left364 * We just call \sa FormatParser< tremolo >::parseAtomDataKeysLine() which is left 356 365 * private., 357 366 * 358 367 * @param atomdata_string line to parse with space-separated values 359 368 */ 360 void TremoloParser::setAtomData(const std::string &atomdata_string)369 void FormatParser< tremolo >::setAtomData(const std::string &atomdata_string) 361 370 { 362 371 parseAtomDataKeysLine(atomdata_string, 0); … … 371 380 * \param *newmol molecule to add atom to 372 381 */ 373 void TremoloParser::readAtomDataLine(string line, molecule *newmol = NULL) {382 void FormatParser< tremolo >::readAtomDataLine(string line, molecule *newmol = NULL) { 374 383 vector<string>::iterator it; 375 384 stringstream lineStream; … … 389 398 tokenizer tokens(line, whitespacesep); 390 399 ASSERT(tokens.begin() != tokens.end(), 391 " TremoloParser::readAtomDataLine - empty string, need at least ' '!");400 "FormatParser< tremolo >::readAtomDataLine - empty string, need at least ' '!"); 392 401 tokenizer::iterator tok_iter = tokens.begin(); 393 402 // then associate each token to each file … … 401 410 // for the moment, assume there are always three dimensions 402 411 for (int i=0;i<NDIM;i++) { 403 ASSERT(tok_iter != tokens.end(), " TremoloParser::readAtomDataLine() - no value for x["+toString(i)+"]!");412 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for x["+toString(i)+"]!"); 404 413 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 405 414 newAtom->set(i, toDouble(*tok_iter)); … … 410 419 // for the moment, assume there are always three dimensions 411 420 for (int i=0;i<NDIM;i++) { 412 ASSERT(tok_iter != tokens.end(), " TremoloParser::readAtomDataLine() - no value for u["+toString(i)+"]!");421 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for u["+toString(i)+"]!"); 413 422 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 414 423 tempVector[i] = toDouble(*tok_iter); … … 419 428 case TremoloKey::type : 420 429 { 421 ASSERT(tok_iter != tokens.end(), " TremoloParser::readAtomDataLine() - no value for "+keyName+"!");430 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!"); 422 431 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 423 432 std::string element(knownTypes[(*tok_iter)]); … … 431 440 } 432 441 case TremoloKey::Id : 433 ASSERT(tok_iter != tokens.end(), " TremoloParser::readAtomDataLine() - no value for "+keyName+"!");442 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!"); 434 443 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 435 444 atomIdMap[toInt(*tok_iter)] = newAtom->getId(); … … 438 447 case TremoloKey::neighbors : 439 448 for (int i=0;i<atoi(it->substr(it->find("=") + 1, 1).c_str());i++) { 440 ASSERT(tok_iter != tokens.end(), " TremoloParser::readAtomDataLine() - no value for "+keyName+"!");449 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!"); 441 450 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 442 451 lineStream << *tok_iter << "\t"; … … 447 456 break; 448 457 default : 449 ASSERT(tok_iter != tokens.end(), " TremoloParser::readAtomDataLine() - no value for "+keyName+"!");458 ASSERT(tok_iter != tokens.end(), "FormatParser< tremolo >::readAtomDataLine() - no value for "+keyName+"!"); 450 459 DoLog(4) && (Log() << Verbose(4) << "INFO: Parsing key " << keyName << " with next token " << *tok_iter << std::endl); 451 460 atomInfo->set(currentField, *tok_iter); … … 467 476 * \param atomid world id of the atom the information belongs to 468 477 */ 469 void TremoloParser::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) {478 void FormatParser< tremolo >::readNeighbors(stringstream* line, int numberOfNeighbors, int atomId) { 470 479 int neighborId = 0; 471 480 for (int i = 0; i < numberOfNeighbors; i++) { … … 489 498 * \return true if the field name is used 490 499 */ 491 bool TremoloParser::isUsedField(string fieldName) {500 bool FormatParser< tremolo >::isUsedField(string fieldName) { 492 501 bool fieldNameExists = false; 493 502 for (vector<string>::iterator usedField = usedFields.begin(); usedField != usedFields.end(); usedField++) { … … 505 514 * Id found in the parsed file. 506 515 */ 507 void TremoloParser::processNeighborInformation() {516 void FormatParser< tremolo >::processNeighborInformation() { 508 517 if (!isUsedField("neighbors")) { 509 518 return; … … 538 547 * \return input string with modified atom IDs 539 548 */ 540 st ring TremoloParser::adaptIdDependentDataString(string data) {549 std::string FormatParser< tremolo >::adaptIdDependentDataString(string data) { 541 550 // there might be no IDs 542 551 if (data == "-") { … … 563 572 * as they might differ from the originally read IDs. 564 573 */ 565 void TremoloParser::adaptImprData() {574 void FormatParser< tremolo >::adaptImprData() { 566 575 if (!isUsedField("imprData")) { 567 576 return; … … 579 588 * as they might differ from the originally read IDs. 580 589 */ 581 void TremoloParser::adaptTorsion() {590 void FormatParser< tremolo >::adaptTorsion() { 582 591 if (!isUsedField("torsion")) { 583 592 return; … … 594 603 * 595 604 */ 596 void TremoloParser::createKnownTypesByIdentity()605 void FormatParser< tremolo >::createKnownTypesByIdentity() 597 606 { 598 607 // remove old mapping … … 611 620 * @param file input stream of .potentials file 612 621 */ 613 void TremoloParser::parseKnownTypes(std::istream &file)622 void FormatParser< tremolo >::parseKnownTypes(std::istream &file) 614 623 { 615 624 const periodentafel *periode = World::getInstance().getPeriode(); … … 632 641 tokenizer tokens(line, tokensep); 633 642 ASSERT(tokens.begin() != tokens.end(), 634 " TremoloParser::parseKnownTypes() - line with 'particle:' but no particles separated by comma.");643 "FormatParser< tremolo >::parseKnownTypes() - line with 'particle:' but no particles separated by comma."); 635 644 // look for particle_type 636 645 std::string particle_type("NULL"); … … 643 652 tokenizer token((*tok_iter), equalitysep); 644 653 ASSERT(token.begin() != token.end(), 645 " TremoloParser::parseKnownTypes() - could not split particle_type by equality sign");654 "FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign"); 646 655 tokenizer::iterator particle_iter = token.begin(); 647 656 particle_iter++; … … 652 661 tokenizer token((*tok_iter), equalitysep); 653 662 ASSERT(token.begin() != token.end(), 654 " TremoloParser::parseKnownTypes() - could not split particle_type by equality sign");663 "FormatParser< tremolo >::parseKnownTypes() - could not split particle_type by equality sign"); 655 664 tokenizer::iterator element_iter = token.begin(); 656 665 element_iter++;
Note:
See TracChangeset
for help on using the changeset viewer.