Changeset 0f5956 for src/Actions


Ignore:
Timestamp:
Sep 6, 2016, 2:36:46 PM (8 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, 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, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
Children:
c6f2c5
Parents:
d21933
git-author:
Frederik Heber <heber@…> (08/31/16 10:45:35)
git-committer:
Frederik Heber <heber@…> (09/06/16 14:36:46)
Message:

Added "parse-state-files" option to fragment-molecule which is off by default.

  • this prevents accidental parsing of stale keysets, adjacency, or orderatsite files. These hard to find errors ever and again cause failing fragmentation because e.g. some hydrogen is suddenly in the keysets although hydrogens are excluded.
Location:
src/Actions/FragmentationAction
Files:
2 edited

Legend:

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

    rd21933 r0f5956  
    4141#include "Descriptors/AtomSelectionDescriptor.hpp"
    4242#include "Descriptors/MoleculeIdDescriptor.hpp"
     43#include "Fragmentation/AdaptivityMap.hpp"
    4344#include "Fragmentation/Exporters/ExportGraph_ToAtomFragments.hpp"
    4445#include "Fragmentation/Exporters/ExportGraph_ToFiles.hpp"
     
    117118  boost::shared_ptr<AdjacencyList> FileChecker;
    118119  boost::filesystem::path filename(params.prefix.get() + std::string(ADJACENCYFILE));
    119   if (boost::filesystem::exists(filename) && boost::filesystem::is_regular_file(filename)) {
     120  if ((params.ParseStateFiles.get())
     121    && boost::filesystem::exists(filename)
     122    && boost::filesystem::is_regular_file(filename)) {
    120123    std::ifstream File;
    121124    File.open(filename.string().c_str(), ios::out);
     
    140143  // we parse in the keysets from last time if present
    141144  Graph StoredGraph;
    142   StoredGraph.ParseKeySetFile(params.prefix.get());
     145  if (params.ParseStateFiles.get()) {
     146    StoredGraph.ParseKeySetFile(params.prefix.get());
     147    // check parsed graph against the set of atoms
     148    {
     149      AdaptivityMap *amap = StoredGraph.GraphToAdaptivityMap();
     150      bool status = true;
     151      for (World::AtomSelectionConstIterator iter = world.beginAtomSelection();
     152          iter != world.endAtomSelection(); ++iter) {
     153        const atomId_t atomid = iter->second->getId();
     154        // skip hydrogens in check if saturation is turned on
     155        if ((iter->second->getType()->getAtomicNumber() != 1)
     156            || (!params.DoSaturation.get())) {
     157          if (amap->count(atomid) == 0) {
     158            ELOG(1, "Atom #" << atomid << " not contained in KeySet file. ");
     159            status = false;
     160            break;
     161          }
     162        } else if (amap->count(atomid) != 0) {
     163          ELOG(1, "Atom #" << atomid << " in KeySet file is a hydrogen, but is now excluded. ");
     164          status = false;
     165          break;
     166        }
     167      }
     168      delete amap;
     169
     170      if (!status) {
     171        ELOG(1, "KeySetsFile seems to contain leftover from an old fragmentation, hence not using file.");
     172        StoredGraph.clear();
     173      }
     174    }
     175  }
    143176
    144177  start = clock();
     
    170203    {
    171204      Graph StoredLocalGraph(StoredGraph.getLocalGraph(mol));
    172       const int tempFlag = Fragmenter.FragmentMolecule(mols_atomids, params.order.get(), params.prefix.get(), StoredLocalGraph);
     205      const int tempFlag = Fragmenter.FragmentMolecule(mols_atomids, params.order.get(), params.prefix.get(), StoredLocalGraph, params.ParseStateFiles.get());
    173206      if ((ExitFlag == 2) && (tempFlag != 2))
    174207        ExitFlag = tempFlag; // if there is one molecule that needs further fragmentation, it overrides others
  • src/Actions/FragmentationAction/FragmentationAction.def

    rd21933 r0f5956  
    2121// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    2222// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    23 #define paramtypes (std::string)(double)(int)(bool)(bool)(std::vector<std::string>)(unsigned int)(unsigned int)(bool)
    24 #define paramtokens ("fragment-molecule")("distance")("order")("DoSaturate")("ExcludeHydrogen")("output-types")("grid-level")("inter-order")("DoCyclesFull")
    25 #define paramdescriptions ("prefix of each fragment file")("distance in space up to which fragments are combined")("order of a discretization, dissection, ...")("do saturate dangling bonds with hydrogen")("whether to exclude hydrogen in the bond graph dissection or not")("type(s) of parsers that output fragment config files")("resolution of density sampling multigrid")("up to which order distinct fragments are combined")("always calculate (aromatic) rings fully, even beyond desired order")
    26 #define paramdefaults (PARAM_DEFAULT("BondFragment"))(PARAM_DEFAULT(3.))(PARAM_DEFAULT(3))(PARAM_DEFAULT(true))(PARAM_DEFAULT(true))(NOPARAM_DEFAULT)(PARAM_DEFAULT(5))(PARAM_DEFAULT(0))(PARAM_DEFAULT(false))
    27 #define paramreferences (prefix)(distance)(order)(DoSaturation)(HowtoTreatHydrogen)(types)(level)(InterOrder)(DoCyclesFull)
     23#define paramtypes (std::string)(double)(int)(bool)(bool)(std::vector<std::string>)(unsigned int)(unsigned int)(bool)(bool)
     24#define paramtokens ("fragment-molecule")("distance")("order")("DoSaturate")("ExcludeHydrogen")("output-types")("grid-level")("inter-order")("DoCyclesFull")("parse-state-files")
     25#define paramdescriptions ("prefix of each fragment file")("distance in space up to which fragments are combined")("order of a discretization, dissection, ...")("do saturate dangling bonds with hydrogen")("whether to exclude hydrogen in the bond graph dissection or not")("type(s) of parsers that output fragment config files")("resolution of density sampling multigrid")("up to which order distinct fragments are combined")("always calculate (aromatic) rings fully, even beyond desired order")("whether to parse keysets, orderatsite, adjacency from state files")
     26#define paramdefaults (PARAM_DEFAULT("BondFragment"))(PARAM_DEFAULT(3.))(PARAM_DEFAULT(3))(PARAM_DEFAULT(true))(PARAM_DEFAULT(true))(NOPARAM_DEFAULT)(PARAM_DEFAULT(5))(PARAM_DEFAULT(0))(PARAM_DEFAULT(false))(PARAM_DEFAULT(false))
     27#define paramreferences (prefix)(distance)(order)(DoSaturation)(HowtoTreatHydrogen)(types)(level)(InterOrder)(DoCyclesFull)(ParseStateFiles)
    2828#define paramvalids \
    2929(DummyValidator< std::string >()) \
     
    3535(RangeValidator< unsigned int >(1, 10)) \
    3636(DummyValidator< unsigned int >()) \
     37(DummyValidator< bool >()) \
    3738(DummyValidator< bool >())
    3839
Note: See TracChangeset for help on using the changeset viewer.