- Timestamp:
- Dec 14, 2012, 1:02:50 PM (12 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:
- fc41df
- Parents:
- 67ab71
- git-author:
- Frederik Heber <heber@…> (10/25/12 08:29:25)
- git-committer:
- Frederik Heber <heber@…> (12/14/12 13:02:50)
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TremoloParser.cpp
r67ab71 r05e2ed 56 56 57 57 #include <algorithm> 58 #include <boost/bind.hpp> 58 59 #include <boost/lambda/lambda.hpp> 59 60 #include <boost/lexical_cast.hpp> … … 103 104 */ 104 105 FormatParser< tremolo >::FormatParser() : 105 FormatParser_common(NULL) 106 FormatParser_common(NULL), 107 idglobalizer(boost::bind(&FormatParser< tremolo >::getGlobalId, this, _1)), 108 idlocalizer(boost::bind(&FormatParser< tremolo >::getLocalId, this, _1)) 106 109 { 107 110 createKnownTypesByIdentity(); … … 160 163 boost::bind(&atom::getId, _1)); 161 164 processNeighborInformation(atoms); 162 adaptImprData( );163 adaptTorsion( );165 adaptImprData(atoms); 166 adaptTorsion(atoms); 164 167 165 168 // append usedFields to global usedFields, is made unique on save, clear after use … … 424 427 writeNeighbors(file, atoi(it->substr(it->find("=") + 1, 1).c_str()), currentAtom); 425 428 break; 429 case TremoloKey::imprData : 430 case TremoloKey::torsion : 431 LOG(3, "Writing type " << knownKeyNames[currentField]); 432 *file << adaptIdDependentDataString( 433 additionalAtomData[currentAtom->getId()].get(currentField), 434 idlocalizer) 435 << "\t"; 436 break; 426 437 case TremoloKey::resSeq : 427 438 if (additionalAtomData.count(currentAtom->getId())) { … … 810 821 * 811 822 * \param string in which atom IDs should be adapted 823 * \param idgetter function pointer to change the id 812 824 * 813 825 * \return input string with modified atom IDs 814 826 */ 815 std::string FormatParser< tremolo >::adaptIdDependentDataString(std::string data) { 827 std::string FormatParser< tremolo >::adaptIdDependentDataString( 828 const std::string &data, 829 const boost::function<int (const int)> &idgetter 830 ) { 816 831 // there might be no IDs 817 832 if (data == "-") { … … 825 840 826 841 line >> id; 827 result << getGlobalId(id);842 result << idgetter(id); 828 843 while (line.good()) { 829 844 line >> separator >> id; 830 result << separator << getGlobalId(id);845 result << separator << idgetter(id); 831 846 } 832 847 … … 834 849 } 835 850 836 /** 837 * Corrects the atom IDs in each imprData entry to the corresponding world IDs 851 /** Corrects the atom IDs in each imprData entry to the corresponding world IDs 838 852 * as they might differ from the originally read IDs. 839 */ 840 void FormatParser< tremolo >::adaptImprData() { 853 * 854 * \param atoms currently parsed in atoms 855 */ 856 void FormatParser< tremolo >::adaptImprData(const std::vector<atomId_t> &atoms) { 841 857 if (!isUsedField(usedFields_load, "imprData")) { 842 858 return; 843 859 } 844 860 845 for(std::map<const atomId_t, TremoloAtomInfoContainer>::iterator currentInfo = additionalAtomData.begin(); 846 currentInfo != additionalAtomData.end(); currentInfo++ 847 ) { 848 currentInfo->second.imprData = adaptIdDependentDataString(currentInfo->second.imprData); 849 } 850 } 851 852 /** 853 * Corrects the atom IDs in each torsion entry to the corresponding world IDs 861 for (std::vector<atomId_t>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 862 ASSERT(additionalAtomData.count(*iter) != 0, 863 "FormatParser< tremolo >::processNeighborInformation() - global id " 864 +toString(*iter)+" unknown in additionalAtomData."); 865 TremoloAtomInfoContainer ¤tInfo = additionalAtomData[*iter]; 866 currentInfo.imprData = adaptIdDependentDataString(currentInfo.imprData, idglobalizer); 867 } 868 } 869 870 /** Corrects the atom IDs in each torsion entry to the corresponding world IDs 854 871 * as they might differ from the originally read IDs. 855 */ 856 void FormatParser< tremolo >::adaptTorsion() { 872 * 873 * \param atoms currently parsed in atoms 874 */ 875 void FormatParser< tremolo >::adaptTorsion(const std::vector<atomId_t> &atoms) { 857 876 if (!isUsedField(usedFields_load, "torsion")) { 858 877 return; 859 878 } 860 879 861 for(std::map<const atomId_t, TremoloAtomInfoContainer>::iterator currentInfo = additionalAtomData.begin(); 862 currentInfo != additionalAtomData.end(); currentInfo++ 863 ) { 864 currentInfo->second.torsion = adaptIdDependentDataString(currentInfo->second.torsion); 865 } 866 } 867 880 for (std::vector<atomId_t>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) { 881 ASSERT(additionalAtomData.count(*iter) != 0, 882 "FormatParser< tremolo >::processNeighborInformation() - global id " 883 +toString(*iter)+" unknown in additionalAtomData."); 884 TremoloAtomInfoContainer ¤tInfo = additionalAtomData[*iter]; 885 currentInfo.torsion = adaptIdDependentDataString(currentInfo.torsion, idglobalizer); 886 } 887 } 888 -
src/Parser/TremoloParser.hpp
r67ab71 r05e2ed 14 14 #endif 15 15 16 #include <boost/function.hpp> 16 17 #include <string> 17 18 … … 99 100 void readNeighbors(std::stringstream* line, const int numberOfNeighbors, const int atomId); 100 101 void processNeighborInformation(const std::vector<atomId_t> &atoms); 101 void adaptImprData( );102 void adaptTorsion( );103 std::string adaptIdDependentDataString( std::string data);102 void adaptImprData(const std::vector<atomId_t> &atoms); 103 void adaptTorsion(const std::vector<atomId_t> &atoms); 104 std::string adaptIdDependentDataString(const std::string &data, const boost::function<int (const int)> &idgetter); 104 105 bool isUsedField(const usedFields_t &fields, const std::string &fieldName) const; 105 106 void writeNeighbors(std::ostream* file, const int numberOfNeighbors, const atom* currentAtom); … … 140 141 */ 141 142 TremoloAtomInfoContainer defaultAdditionalData; 143 144 //!> bound function to convert id to global id, stored to avoid creation many times 145 const boost::function<int (const int)> idglobalizer; 146 147 //!> bound function to convert id to local id, stored to avoid creation many times 148 const boost::function<int (const int)> idlocalizer; 142 149 }; 143 150 -
src/Parser/unittests/ParserTremoloUnitTest.cpp
r67ab71 r05e2ed 108 108 World::getInstance(); 109 109 110 setVerbosity( 5);110 setVerbosity(2); 111 111 112 112 parser = new FormatParser<tremolo>(); … … 128 128 129 129 void ParserTremoloUnitTest::readTremoloPreliminaryCommentsTest() { 130 cout << "Testing the tremolo parser." << endl;130 // cout << "Testing the tremolo parser." << endl; 131 131 stringstream input, output; 132 132 … … 150 150 std::vector<atom *> atoms = World::getInstance().getAllAtoms(); 151 151 parser->save(&output, atoms); 152 std::cout << output.str() << std::endl;152 // std::cout << output.str() << std::endl; 153 153 CPPUNIT_ASSERT(output.str().find("hydrogen") != string::npos); 154 154 input.clear(); … … 229 229 parser->save(&output, atoms); 230 230 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 231 std::cout << output.str() << std::endl;232 CPPUNIT_ASSERT(output.str().find(" 2-0,0-2") != string::npos);231 // std::cout << output.str() << std::endl; 232 CPPUNIT_ASSERT(output.str().find("3-1,1-3") != string::npos); 233 233 input.clear(); 234 234 output.clear(); … … 246 246 parser->save(&output, atoms); 247 247 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms()); 248 std::cout << output.str() << std::endl;249 CPPUNIT_ASSERT(output.str().find(" 2-0,0-2") != string::npos);248 // std::cout << output.str() << std::endl; 249 CPPUNIT_ASSERT(output.str().find("3-1,1-3") != string::npos); 250 250 input.clear(); 251 251 output.clear(); … … 268 268 } 269 269 270 cout << "testing the tremolo parser is done" << endl;271 } 272 270 // cout << "testing the tremolo parser is done" << endl; 271 } 272
Note:
See TracChangeset
for help on using the changeset viewer.