Changeset 56c55f3


Ignore:
Timestamp:
Aug 31, 2016, 10:54:47 AM (9 years ago)
Author:
Frederik Heber <heber@…>
Branches:
FragmentMolecule_checks_bonddegrees, Gui_Fixes
Children:
e3d0fe
Parents:
6e5ca9
git-author:
Frederik Heber <heber@…> (08/31/16 10:45:35)
git-committer:
Frederik Heber <heber@…> (08/31/16 10:54:47)
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.
Files:
5 edited

Legend:

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

    r6e5ca9 r56c55f3  
    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);
     
    144147  // we parse in the keysets from last time if present
    145148  Graph StoredGraph;
    146   StoredGraph.ParseKeySetFile(params.prefix.get());
     149  if (params.ParseStateFiles.get()) {
     150    StoredGraph.ParseKeySetFile(params.prefix.get());
     151    // check parsed graph against the set of atoms
     152    {
     153      AdaptivityMap *amap = StoredGraph.GraphToAdaptivityMap();
     154      bool status = true;
     155      for (World::AtomSelectionConstIterator iter = world.beginAtomSelection();
     156          iter != world.endAtomSelection(); ++iter) {
     157        const atomId_t atomid = iter->second->getId();
     158        // skip hydrogens in check if saturation is turned on
     159        if ((iter->second->getType()->getAtomicNumber() != 1)
     160            || (!params.DoSaturation.get())) {
     161          if (amap->count(atomid) == 0) {
     162            ELOG(1, "Atom #" << atomid << " not contained in KeySet file. ");
     163            status = false;
     164            break;
     165          }
     166        } else if (amap->count(atomid) != 0) {
     167          ELOG(1, "Atom #" << atomid << " in KeySet file is a hydrogen, but is now excluded. ");
     168          status = false;
     169          break;
     170        }
     171      }
     172      delete amap;
     173
     174      if (!status) {
     175        ELOG(1, "KeySetsFile seems to contain leftover from an old fragmentation, hence not using file.");
     176        StoredGraph.clear();
     177      }
     178    }
     179  }
    147180
    148181  start = clock();
     
    174207    {
    175208      Graph StoredLocalGraph(StoredGraph.getLocalGraph(mol));
    176       const int tempFlag = Fragmenter.FragmentMolecule(mols_atomids, params.order.get(), params.prefix.get(), StoredLocalGraph);
     209      const int tempFlag = Fragmenter.FragmentMolecule(mols_atomids, params.order.get(), params.prefix.get(), StoredLocalGraph, params.ParseStateFiles.get());
    177210      if ((ExitFlag == 2) && (tempFlag != 2))
    178211        ExitFlag = tempFlag; // if there is one molecule that needs further fragmentation, it overrides others
  • src/Actions/FragmentationAction/FragmentationAction.def

    r6e5ca9 r56c55f3  
    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
  • src/Fragmentation/Fragmentation.cpp

    r6e5ca9 r56c55f3  
    118118    int Order,
    119119    const std::string &prefix,
    120     const Graph &ParsedFragmentList)
     120    const Graph &ParsedFragmentList,
     121    const bool _ParseStateFile)
    121122{
    122123  std::fstream File;
     
    178179
    179180  // ===== 4. check globally whether there's something to do actually (first adaptivity check)
    180   FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(atomids, prefix, Global_local_bimap);
     181  if (_ParseStateFile)
     182    FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(atomids, prefix, Global_local_bimap);
    181183
    182184  // =================================== Begin of FRAGMENTATION ===============================
  • src/Fragmentation/Fragmentation.hpp

    r6e5ca9 r56c55f3  
    4646  ~Fragmentation();
    4747
    48   int FragmentMolecule(const std::vector<atomId_t> &atomids, int Order, const std::string &prefix, const Graph &ParsedFragmentList);
     48  int FragmentMolecule(const std::vector<atomId_t> &atomids, int Order, const std::string &prefix, const Graph &ParsedFragmentList, const bool _ParseStateFile);
    4949
    5050  const Graph& getGraph() const {
  • tests/Python/AllActions/options.dat

    r6e5ca9 r56c55f3  
    132132parse-particle-parameters       "water.particles"
    133133parse-potentials        "water.potentials"
     134parse-state-files       "1"
    134135parse-tremolo-potentials        "argon.potentials"
    135136parse-tremolo-potentials        "tensid.potentials"
Note: See TracChangeset for help on using the changeset viewer.