Changeset d449a9
- Timestamp:
- Aug 9, 2013, 2:20:35 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:
- f0025d
- Parents:
- 1e1098
- git-author:
- Frederik Heber <heber@…> (06/24/13 09:08:12)
- git-committer:
- Frederik Heber <heber@…> (08/09/13 14:20:35)
- Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp
r1e1098 rd449a9 220 220 } 221 221 222 void parseHomologiesFromFile(223 const boost::filesystem::path &homology_file224 )225 {226 HomologyContainer &homology_container = World::getInstance().getHomologies();227 if (boost::filesystem::exists(homology_file)) {228 std::ifstream returnstream(homology_file.string().c_str());229 if (returnstream.good()) {230 boost::archive::text_iarchive ia(returnstream);231 ia >> homology_container;232 } else {233 ELOG(2, "Failed to parse from " << homology_file.string() << ".");234 }235 returnstream.close();236 } else {237 LOG(2, "Could not open " << homology_file.string()238 << ", creating empty container.");239 }240 }241 242 222 void appendToHomologies( 243 223 const FragmentationShortRangeResults &shortrangeresults, … … 306 286 } 307 287 } 308 }309 310 bool writeHomologiesToFile(311 const boost::filesystem::path &homology_file312 )313 {314 /// store homology container again315 HomologyContainer &homology_container = World::getInstance().getHomologies();316 std::ofstream outputstream(homology_file.string().c_str());317 if (outputstream.good()) { // check if opened318 boost::archive::text_oarchive oa(outputstream);319 oa << homology_container;320 if (outputstream.fail()) { // check if correctly written321 LOG(1, "Failed to write to file " << homology_file.string() << ".");322 return false;323 } else324 outputstream.close();325 } else {326 LOG(1, "Failed to open file " << homology_file.string()327 << " for writing.");328 return false;329 }330 return true;331 288 } 332 289 … … 427 384 // append all keysets to homology file 428 385 appendToHomologies(shortrangeresults, longrangeresults); 429 if (!params.homology_file.get().empty()) {430 const boost::filesystem::path &homology_file = params.homology_file.get();431 if (homology_file.string() != "") {432 LOG(1, "INFO: Parsing HomologyGraphs from file " << homology_file.string() << ".");433 parseHomologiesFromFile(homology_file);434 LOG(1, "INFO: Appending HomologyGraphs to file " << homology_file.string() << ".");435 if (!writeHomologiesToFile(homology_file))436 return Action::failure;437 }438 }439 386 } 440 387 #else -
src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.def
r1e1098 rd449a9 10 10 11 11 #include "Parameters/Validators/DummyValidator.hpp" 12 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"13 12 14 13 // i.e. there is an integer with variable name Z that can be found in 15 14 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 16 15 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 17 #define paramtypes (boost::filesystem::path) (boost::filesystem::path)18 #define paramtokens (" homology-file")("fragment-resultfile")19 #define paramdescriptions ("pa th to file containing homology container to append to")("parse fragment results from the given file")20 #define paramdefaults (PARAM_DEFAULT("")) (PARAM_DEFAULT(""))21 #define paramreferences ( homology_file)(resultsfile)16 #define paramtypes (boost::filesystem::path) 17 #define paramtokens ("fragment-resultfile") 18 #define paramdescriptions ("parse fragment results from the given file") 19 #define paramdefaults (PARAM_DEFAULT("")) 20 #define paramreferences (resultsfile) 22 21 #define paramvalids \ 23 (DummyValidator< boost::filesystem::path >()) \24 22 (DummyValidator< boost::filesystem::path >()) 25 23 -
src/Actions/FragmentationAction/FitPotentialAction.cpp
r1e1098 rd449a9 152 152 LOG(0, "STATUS: I'm training now a set of potentials parsed from " 153 153 << params.potential_file.get().string() << " on a fragment " 154 << fragmentnumbers << " on data from " << params.homology_file.get() << ".");154 << fragmentnumbers << " on data from World's homologies."); 155 155 156 156 } else { … … 168 168 169 169 LOG(0, "STATUS: I'm training now a " << params.potentialtype.get() 170 << " potential on charges " << chargenumbers << " on data from " 171 << params.homology_file.get() << "."); 170 << " potential on charges " << chargenumbers << " on data from World's homologies."); 172 171 173 172 // register desired potential and an additional constant one … … 186 185 187 186 // parse homologies into container 188 HomologyContainer homologies; 189 if (boost::filesystem::exists(params.homology_file.get())) { 190 std::ifstream returnstream(params.homology_file.get().string().c_str()); 191 if (returnstream.good()) { 192 boost::archive::text_iarchive ia(returnstream); 193 ia >> homologies; 194 } else { 195 ELOG(0, "Failed to parse from " << params.homology_file.get().string() << "."); 196 return Action::failure; 197 } 198 returnstream.close(); 199 } else { 200 ELOG(0, params.homology_file.get() << " does not exist."); 201 return Action::failure; 202 } 187 HomologyContainer &homologies = World::getInstance().getHomologies(); 203 188 204 189 // first we try to look into the HomologyContainer -
src/Actions/FragmentationAction/FitPotentialAction.def
r1e1098 rd449a9 23 23 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 24 24 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 25 #define paramtypes (boost::filesystem::path)( boost::filesystem::path)(std::string)(boost::filesystem::path)(std::vector<const element *>)(std::vector<const element *>)(unsigned int)26 #define paramtokens (" homology-file")("training-file")("potential-type")("potential-file")("potential-charges")("fragment-charges")("take-best-of")27 #define paramdescriptions (" homology file to parse")("optional file to write training data to")("potential type to fit")("potential file specifying multiple potentials to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations")28 #define paramdefaults ( NOPARAM_DEFAULT)(PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3))29 #define paramreferences ( homology_file)(training_file)(potentialtype)(potential_file)(charges)(fragment)(best_of_howmany)25 #define paramtypes (boost::filesystem::path)(std::string)(boost::filesystem::path)(std::vector<const element *>)(std::vector<const element *>)(unsigned int) 26 #define paramtokens ("training-file")("potential-type")("potential-file")("potential-charges")("fragment-charges")("take-best-of") 27 #define paramdescriptions ("optional file to write training data to")("potential type to fit")("potential file specifying multiple potentials to fit")("charges specifying the potential")("charges specifying the fragment")("take the best among this many approximations") 28 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(NOPARAM_DEFAULT)(PARAM_DEFAULT(3)) 29 #define paramreferences (training_file)(potentialtype)(potential_file)(charges)(fragment)(best_of_howmany) 30 30 #define paramvalids \ 31 (FilePresentValidator()) \32 31 (DummyValidator<boost::filesystem::path>()) \ 33 32 (EmptyStringValidator() || PotentialTypeValidator()) \ -
src/Actions/GlobalListOfActions.hpp
r1e1098 rd449a9 124 124 (FragmentationAnalyseFragmentationResults) \ 125 125 (FragmentationFragmentation) \ 126 (FragmentationParseHomologies) \ 127 (FragmentationSaveHomologies) \ 126 128 (FragmentationStoreSaturatedFragment) \ 127 129 (FillRegularGrid) \ -
src/Actions/Makefile.am
r1e1098 rd449a9 213 213 214 214 FRAGMENTATIONACTIONSOURCE = \ 215 Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp \ 215 216 Actions/FragmentationAction/FragmentationAction.cpp \ 216 Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp \ 217 Actions/FragmentationAction/ParseHomologiesAction.cpp \ 218 Actions/FragmentationAction/SaveHomologiesAction.cpp \ 217 219 Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp 218 220 FRAGMENTATIONACTIONHEADER = \ 221 Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp \ 219 222 Actions/FragmentationAction/FragmentationAction.hpp \ 220 Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp \ 223 Actions/FragmentationAction/ParseHomologiesAction.hpp \ 224 Actions/FragmentationAction/SaveHomologiesAction.hpp \ 221 225 Actions/FragmentationAction/StoreSaturatedFragmentAction.hpp 222 226 FRAGMENTATIONACTIONDEFS = \ 227 Actions/FragmentationAction/AnalyseFragmentationResultsAction.def \ 223 228 Actions/FragmentationAction/FragmentationAction.def \ 224 Actions/FragmentationAction/AnalyseFragmentationResultsAction.def \ 229 Actions/FragmentationAction/ParseHomologiesAction.def \ 230 Actions/FragmentationAction/SaveHomologiesAction.def \ 225 231 Actions/FragmentationAction/StoreSaturatedFragmentAction.def 226 232 -
tests/Python/AllActions/options.dat
r1e1098 rd449a9 83 83 fragment-resultfile "results.dat" 84 84 grid-level "5" 85 homology-file "homology.dat"86 85 id-mapping "1" 87 86 input "test.data" … … 118 117 output-types "xyz" 119 118 output-types "xyz mpqc" 119 parse-homologies "homology.dat" 120 120 parse-tremolo-potentials "argon.potentials" 121 121 parse-tremolo-potentials "tensid.potentials" … … 154 154 save-adjacency "test.adj" 155 155 save-bonds "test.bond" 156 save-homologies "homology.dat" 156 157 save-selected-atoms "testsave.xyz" 157 158 save-selected-atoms-as-exttypes "test.exttypes" -
tests/regression/Fragmentation/FitPotential/testsuite-fragmentation-fit-potential.at
r1e1098 rd449a9 20 20 21 21 AT_SETUP([Fragmentation - Fit morse potential to water]) 22 AT_KEYWORDS([fragmentation fit-potential morse])22 AT_KEYWORDS([fragmentation parse-homologies fit-potential morse]) 23 23 AT_SKIP_IF([../../molecuilder --help --actionname fit-potential; if test $? -eq 5; then /bin/true; else /bin/false; fi]) 24 24 … … 26 26 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Fragmentation/FitPotential/pre/$file $file], 0) 27 27 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 28 AT_CHECK([../../molecuilder -- fit-potential --potential-type "morse" --homology-file $file--potential-charges 8 1 --fragment-charges 1 8 1 --take-best-of 5], 0, [stdout], [ignore])28 AT_CHECK([../../molecuilder --parse-homologies $file --fit-potential --potential-type "morse" --potential-charges 8 1 --fragment-charges 1 8 1 --take-best-of 5], 0, [stdout], [ignore]) 29 29 # check that L_2 error is below 1e-6 30 30 AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore]) … … 35 35 36 36 AT_SETUP([Fragmentation - Fit harmonic_angle potential to water]) 37 AT_KEYWORDS([fragmentation fit-potential harmonic_angle])37 AT_KEYWORDS([fragmentation parse-homologies fit-potential harmonic_angle]) 38 38 AT_SKIP_IF([../../molecuilder --help --actionname fit-potential; if test $? -eq 5; then /bin/true; else /bin/false; fi]) 39 39 … … 41 41 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Fragmentation/FitPotential/pre/$file $file], 0) 42 42 AT_CHECK([chmod u+w $file], 0, [ignore], [ignore]) 43 AT_CHECK([../../molecuilder -- fit-potential --potential-type "harmonic_angle" --homology-file $file--potential-charges 1 8 1 --fragment-charges 1 8 1 --take-best-of 5], 0, [stdout], [ignore])43 AT_CHECK([../../molecuilder --parse-homologies $file --fit-potential --potential-type "harmonic_angle" --potential-charges 1 8 1 --fragment-charges 1 8 1 --take-best-of 5], 0, [stdout], [ignore]) 44 44 # check that L_2 error is below 1e-6 45 45 AT_CHECK([grep "||e||_2:" stdout | awk '{if ($7 > 1e-6) exit 1}'], 0, [ignore], [ignore])
Note:
See TracChangeset
for help on using the changeset viewer.