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.
File:
1 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
Note: See TracChangeset for help on using the changeset viewer.