Changeset 2b7d1b


Ignore:
Timestamp:
Aug 11, 2010, 4:31:34 PM (15 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:
701ad6, fa7989
Parents:
31fb1d
git-author:
Frederik Heber <heber@…> (07/29/10 12:07:40)
git-committer:
Frederik Heber <heber@…> (08/11/10 16:31:34)
Message:

Merged MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs() into FragmenationSubgraphDissectionAction.

  • also rewrote the function a bit:
    • no more copying of atoms
    • we just take the molecule out of the MoleculeLeafs
    • molecule that contains all atoms is destroyed including all original atoms (they are copied by DFS).
Location:
src
Files:
5 edited

Legend:

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

    r31fb1d r2b7d1b  
    2424#include "molecule.hpp"
    2525#include "stackclass.hpp"
     26#include "verbose.hpp"
    2627#include "World.hpp"
    2728
     
    4445{}
    4546
     47/** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this.
     48 */
    4649void FragmentationSubgraphDissection() {
    4750  ActionRegistry::getInstance().getActionByName(FragmentationSubgraphDissectionAction::NAME)->call(Action::NonInteractive);
     
    5962Action::state_ptr FragmentationSubgraphDissectionAction::performCall() {
    6063  DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl);
    61   // @TODO rather do the dissection afterwards
     64
    6265  MoleculeListClass *molecules = World::getInstance().getMolecules();
    6366  config * const configuration = World::getInstance().getConfig();
     
    101104    return Action::failure;
    102105  }
     106<<<<<<< HEAD
    103107
    104108  // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
     
    143147  // TODO: When DepthFirstSearchAnalysis does not use AddCopyAtom() anymore, we don't need to delete all original atoms.
    144148  // 4d. destroy the original molecule
     149=======
     150  int FragmentCounter = Subgraphs->Count();
     151
     152  // TODO: When DepthFirstSearchAnalysis does not use AddCopyAtom() anymore, we don't need to delete all original atoms
     153  // 3. destroy the original molecule
     154>>>>>>> Merged MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs() into FragmenationSubgraphDissectionAction.
    145155  for (molecule::iterator AtomRunner = mol->begin(); !mol->empty(); AtomRunner = mol->begin())
    146156    World::getInstance().destroyAtom(*AtomRunner);
    147157  World::getInstance().destroyMolecule(mol);
    148158
     159<<<<<<< HEAD
    149160  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    150161  // TODO: check whether this is really not needed anymore
    151162  // 4e. free Leafs
    152163  MolecularWalker = Subgraphs;
     164=======
     165  // 4. free Leafs
     166  MoleculeLeafClass *MolecularWalker = Subgraphs;
     167>>>>>>> Merged MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs() into FragmenationSubgraphDissectionAction.
    153168  while (MolecularWalker->next != NULL) {
    154169    MolecularWalker = MolecularWalker->next;
     
    156171  }
    157172  delete(MolecularWalker);
     173<<<<<<< HEAD
    158174  delete[](moleculelist);
     175=======
     176>>>>>>> Merged MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs() into FragmenationSubgraphDissectionAction.
    159177  DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    160178
  • src/Parser/PcpParser.cpp

    r31fb1d r2b7d1b  
    1616#include <iomanip>
    1717
     18//#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
    1819#include "atom.hpp"
    1920#include "config.hpp"
     
    356357  // 4. dissect the molecule into connected subgraphs
    357358  // don't do this here ...
    358   //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
     359  //FragmentationSubgraphDissection();
    359360  //delete(mol);
    360361
  • src/config.cpp

    r31fb1d r2b7d1b  
    1515#include <cstring>
    1616
     17//#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
    1718#include "atom.hpp"
    1819#include "bond.hpp"
     
    856857  // 4. dissect the molecule into connected subgraphs
    857858  // don't do this here ...
    858   //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
     859  //FragmentationSubgraphDissection();
    859860  //delete(mol);
    860861
  • src/molecule.hpp

    r31fb1d r2b7d1b  
    367367  void Enumerate(ostream *out);
    368368  void Output(ofstream *out);
    369   void DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration);
    370369  int CountAllAtoms() const;
    371370
  • src/moleculelist.cpp

    r31fb1d r2b7d1b  
    585585};
    586586
    587 /** Dissects given \a *mol into connected subgraphs and inserts them as new molecules but with old atoms into \a this.
    588  * \param *out output stream for debugging
    589  * \param *periode periodentafel
    590  * \param *configuration config with BondGraph
    591  */
    592 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)
    593 {
    594   // 0a. remove all present molecules
    595   vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
    596   for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
    597     erase(*MolRunner);
    598     World::getInstance().destroyMolecule(*MolRunner);
    599   }
    600   // 0b. remove all bonds and construct a molecule with all atoms
    601   molecule *mol = World::getInstance().createMolecule();
    602   vector <atom *> allatoms = World::getInstance().getAllAtoms();
    603   for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
    604     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
    605       delete(*BondRunner);
    606     mol->AddAtom(*AtomRunner);
    607   }
    608 
    609   // 1. dissect the molecule into connected subgraphs
    610   if (configuration->BG != NULL) {
    611     if (!configuration->BG->ConstructBondGraph(mol)) {
    612       World::getInstance().destroyMolecule(mol);
    613       DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl);
    614       return;
    615     }
    616   } else {
    617     DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl);
    618     return;
    619   }
    620 
    621   // 2. scan for connected subgraphs
    622   MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
    623   class StackClass<bond *> *BackEdgeStack = NULL;
    624   Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    625   delete(BackEdgeStack);
    626   if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
    627     World::getInstance().destroyMolecule(mol);
    628     DoeLog(1) && (eLog()<< Verbose(1) << "There are no atoms." << endl);
    629     return;
    630   }
    631 
    632   // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
    633   // the original one as parsed in)
    634   // TODO: Optimize this, when molecules just contain pointer list of global atoms!
    635 
    636   // 4a. create array of molecules to fill
    637   const int MolCount = Subgraphs->next->Count();
    638   char number[MAXSTRINGSIZE];
    639   molecule **molecules = new molecule *[MolCount];
    640   MoleculeLeafClass *MolecularWalker = Subgraphs;
    641   for (int i=0;i<MolCount;i++) {
    642     MolecularWalker = MolecularWalker->next;
    643     molecules[i] = World::getInstance().createMolecule();
    644     molecules[i]->ActiveFlag = true;
    645     strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
    646     if (MolCount > 1) {
    647       sprintf(number, "-%d", i+1);
    648       strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
    649     }
    650     DoLog(1) && (Log() << Verbose(1) << "MolName is " << molecules[i]->name << ", id is " << molecules[i]->getId() << endl);
    651     for (molecule::iterator iter = MolecularWalker->Leaf->begin(); iter != MolecularWalker->Leaf->end(); ++iter) {
    652       DoLog(1) && (Log() << Verbose(1) << **iter << endl);
    653     }
    654     insert(molecules[i]);
    655   }
    656 
    657   // 4b. create and fill map of which atom is associated to which connected molecule (note, counting starts at 1)
    658   int FragmentCounter = 0;
    659   map<int, atom *> AtomToFragmentMap;
    660   MolecularWalker = Subgraphs;
    661   while (MolecularWalker->next != NULL) {
    662     MolecularWalker = MolecularWalker->next;
    663     for (molecule::iterator iter = MolecularWalker->Leaf->begin(); !MolecularWalker->Leaf->empty(); iter = MolecularWalker->Leaf->begin()) {
    664       atom * Walker = *iter;
    665       DoLog(1) && (Log() << Verbose(1) << "Re-linking " << Walker << "..." << endl);
    666       MolecularWalker->Leaf->erase(iter);
    667       molecules[FragmentCounter]->AddAtom(Walker);    // counting starts at 1
    668     }
    669     FragmentCounter++;
    670   }
    671   World::getInstance().destroyMolecule(mol);
    672 
    673   // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    674   // TODO: check whether this is really not needed anymore
    675   // 4e. free Leafs
    676   MolecularWalker = Subgraphs;
    677   while (MolecularWalker->next != NULL) {
    678     MolecularWalker = MolecularWalker->next;
    679     delete(MolecularWalker->previous);
    680   }
    681   delete(MolecularWalker);
    682   delete[](molecules);
    683   DoLog(1) && (Log() << Verbose(1) << "I scanned " << FragmentCounter << " molecules." << endl);
    684 };
    685 
    686587/** Count all atoms in each molecule.
    687588 * \return number of atoms in the MoleculeListClass.
Note: See TracChangeset for help on using the changeset viewer.