Changeset 2b7d1b for src/moleculelist.cpp
- Timestamp:
- Aug 11, 2010, 4:31:34 PM (15 years ago)
- 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, Candidate_v1.7.0, Candidate_v1.7.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)
- File:
-
- 1 edited
-
src/moleculelist.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/moleculelist.cpp
r31fb1d r2b7d1b 585 585 }; 586 586 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 debugging589 * \param *periode periodentafel590 * \param *configuration config with BondGraph591 */592 void MoleculeListClass::DissectMoleculeIntoConnectedSubgraphs(const periodentafel * const periode, config * const configuration)593 {594 // 0a. remove all present molecules595 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 atoms601 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 subgraphs610 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 subgraphs622 MoleculeLeafClass *Subgraphs = NULL; // list of subgraphs from DFS analysis623 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 in633 // 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 fill637 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 1668 }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 list674 // TODO: check whether this is really not needed anymore675 // 4e. free Leafs676 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 686 587 /** Count all atoms in each molecule. 687 588 * \return number of atoms in the MoleculeListClass.
Note:
See TracChangeset
for help on using the changeset viewer.
