Changeset d449a9


Ignore:
Timestamp:
Aug 9, 2013, 2:20:35 PM (12 years ago)
Author:
Frederik Heber <heber@…>
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)
Message:

Split off parsing and saving of homologies into new Actions.

Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp

    r1e1098 rd449a9  
    220220}
    221221
    222 void parseHomologiesFromFile(
    223     const boost::filesystem::path &homology_file
    224     )
    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 
    242222void appendToHomologies(
    243223    const FragmentationShortRangeResults &shortrangeresults,
     
    306286    }
    307287  }
    308 }
    309 
    310 bool writeHomologiesToFile(
    311     const boost::filesystem::path &homology_file
    312     )
    313 {
    314   /// store homology container again
    315   HomologyContainer &homology_container = World::getInstance().getHomologies();
    316   std::ofstream outputstream(homology_file.string().c_str());
    317   if (outputstream.good()) { // check if opened
    318     boost::archive::text_oarchive oa(outputstream);
    319     oa << homology_container;
    320     if (outputstream.fail()) { // check if correctly written
    321       LOG(1, "Failed to write to file " << homology_file.string() << ".");
    322       return false;
    323     } else
    324       outputstream.close();
    325   } else {
    326     LOG(1, "Failed to open file " << homology_file.string()
    327         << " for writing.");
    328     return false;
    329   }
    330   return true;
    331288}
    332289
     
    427384    // append all keysets to homology file
    428385    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     }
    439386  }
    440387#else
  • src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.def

    r1e1098 rd449a9  
    1010
    1111#include "Parameters/Validators/DummyValidator.hpp"
    12 #include "Parameters/Validators/Specific/FilePresentValidator.hpp"
    1312
    1413// i.e. there is an integer with variable name Z that can be found in
    1514// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1615// "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 ("path 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)
    2221#define paramvalids \
    23 (DummyValidator< boost::filesystem::path >()) \
    2422(DummyValidator< boost::filesystem::path >())
    2523
  • src/Actions/FragmentationAction/FitPotentialAction.cpp

    r1e1098 rd449a9  
    152152    LOG(0, "STATUS: I'm training now a set of potentials parsed from "
    153153        << 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.");
    155155
    156156  } else {
     
    168168
    169169      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.");
    172171
    173172      // register desired potential and an additional constant one
     
    186185
    187186  // 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();
    203188
    204189  // first we try to look into the HomologyContainer
  • src/Actions/FragmentationAction/FitPotentialAction.def

    r1e1098 rd449a9  
    2323// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    2424// "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)
    3030#define paramvalids \
    31 (FilePresentValidator()) \
    3231(DummyValidator<boost::filesystem::path>()) \
    3332(EmptyStringValidator() || PotentialTypeValidator()) \
  • src/Actions/GlobalListOfActions.hpp

    r1e1098 rd449a9  
    124124  (FragmentationAnalyseFragmentationResults) \
    125125  (FragmentationFragmentation) \
     126  (FragmentationParseHomologies) \
     127  (FragmentationSaveHomologies) \
    126128  (FragmentationStoreSaturatedFragment) \
    127129  (FillRegularGrid) \
  • src/Actions/Makefile.am

    r1e1098 rd449a9  
    213213
    214214FRAGMENTATIONACTIONSOURCE = \
     215  Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp \
    215216  Actions/FragmentationAction/FragmentationAction.cpp \
    216   Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp \
     217  Actions/FragmentationAction/ParseHomologiesAction.cpp \
     218  Actions/FragmentationAction/SaveHomologiesAction.cpp \
    217219  Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp
    218220FRAGMENTATIONACTIONHEADER = \
     221  Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp \
    219222  Actions/FragmentationAction/FragmentationAction.hpp \
    220   Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp \
     223  Actions/FragmentationAction/ParseHomologiesAction.hpp \
     224  Actions/FragmentationAction/SaveHomologiesAction.hpp \
    221225  Actions/FragmentationAction/StoreSaturatedFragmentAction.hpp
    222226FRAGMENTATIONACTIONDEFS = \
     227  Actions/FragmentationAction/AnalyseFragmentationResultsAction.def \
    223228  Actions/FragmentationAction/FragmentationAction.def \
    224   Actions/FragmentationAction/AnalyseFragmentationResultsAction.def \
     229  Actions/FragmentationAction/ParseHomologiesAction.def \
     230  Actions/FragmentationAction/SaveHomologiesAction.def \
    225231  Actions/FragmentationAction/StoreSaturatedFragmentAction.def
    226232
  • tests/Python/AllActions/options.dat

    r1e1098 rd449a9  
    8383fragment-resultfile     "results.dat"
    8484grid-level      "5"
    85 homology-file   "homology.dat"
    8685id-mapping      "1"
    8786input   "test.data"
     
    118117output-types    "xyz"
    119118output-types    "xyz mpqc"
     119parse-homologies        "homology.dat"
    120120parse-tremolo-potentials        "argon.potentials"
    121121parse-tremolo-potentials        "tensid.potentials"
     
    154154save-adjacency  "test.adj"
    155155save-bonds      "test.bond"
     156save-homologies "homology.dat"
    156157save-selected-atoms     "testsave.xyz"
    157158save-selected-atoms-as-exttypes "test.exttypes"
  • tests/regression/Fragmentation/FitPotential/testsuite-fragmentation-fit-potential.at

    r1e1098 rd449a9  
    2020
    2121AT_SETUP([Fragmentation - Fit morse potential to water])
    22 AT_KEYWORDS([fragmentation fit-potential morse])
     22AT_KEYWORDS([fragmentation parse-homologies fit-potential morse])
    2323AT_SKIP_IF([../../molecuilder --help --actionname fit-potential; if test $? -eq 5; then /bin/true; else /bin/false; fi])
    2424
     
    2626AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Fragmentation/FitPotential/pre/$file $file], 0)
    2727AT_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])
     28AT_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])
    2929# check that L_2 error is below 1e-6
    3030AT_CHECK([grep "Best parameters with L2 error" stdout | awk '{if ($8 > 1e-6) exit 1}'], 0, [ignore], [ignore])
     
    3535
    3636AT_SETUP([Fragmentation - Fit harmonic_angle potential to water])
    37 AT_KEYWORDS([fragmentation fit-potential harmonic_angle])
     37AT_KEYWORDS([fragmentation parse-homologies fit-potential harmonic_angle])
    3838AT_SKIP_IF([../../molecuilder --help --actionname fit-potential; if test $? -eq 5; then /bin/true; else /bin/false; fi])
    3939
     
    4141AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Fragmentation/FitPotential/pre/$file $file], 0)
    4242AT_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])
     43AT_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])
    4444# check that L_2 error is below 1e-6
    4545AT_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.