Changeset 8652a30 for src/Fragmentation/Exporters/ExportGraph_ToFiles.cpp
- Timestamp:
- Apr 8, 2013, 11:56:08 AM (12 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, 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:
- 3b0d2a
- Parents:
- 22b786
- git-author:
- Frederik Heber <heber@…> (03/03/13 08:03:22)
- git-committer:
- Frederik Heber <heber@…> (04/08/13 11:56:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Exporters/ExportGraph_ToFiles.cpp
r22b786 r8652a30 61 61 const enum HydrogenTreatment _treatment, 62 62 const enum HydrogenSaturation _saturation) : 63 ExportGraph(_graph), 64 BondFragments(World::getPointer()), 65 treatment(_treatment), 66 saturation(_saturation) 63 ExportGraph(_graph, _treatment, _saturation) 67 64 {} 68 65 … … 72 69 */ 73 70 ExportGraph_ToFiles::~ExportGraph_ToFiles() 74 { 75 // remove all create molecules again from the World including their atoms 76 for (MoleculeList::iterator iter = BondFragments.ListOfMolecules.begin(); 77 !BondFragments.ListOfMolecules.empty(); 78 iter = BondFragments.ListOfMolecules.begin()) { 79 // remove copied atoms and molecule again 80 molecule *mol = *iter; 81 mol->removeAtomsinMolecule(); 82 World::getInstance().destroyMolecule(mol); 83 BondFragments.ListOfMolecules.erase(iter); 84 } 85 } 71 {} 86 72 87 73 /** Actual implementation of the export to files function. … … 89 75 void ExportGraph_ToFiles::operator()() 90 76 { 91 if (BondFragments.ListOfMolecules.size() == 0) 92 prepareMolecule(); 77 ExportGraph::operator()(); 93 78 94 79 // ===== 9. Save fragments' configuration and keyset files et al to disk === … … 125 110 } 126 111 127 /** Internal helper to create from each keyset a molecule128 *129 */130 void ExportGraph_ToFiles::prepareMolecule()131 {132 size_t count = 0;133 for(Graph::const_iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) {134 KeySet test = (*runner).first;135 LOG(2, "DEBUG: Fragment No." << (*runner).second.first << " with TEFactor "136 << (*runner).second.second << ".");137 BondFragments.insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));138 ++count;139 }140 LOG(1, "INFO: " << count << "/" << BondFragments.ListOfMolecules.size()141 << " fragments generated from the keysets.");142 }143 112 144 /** Stores a fragment from \a KeySet into \a molecule.145 * First creates the minimal set of atoms from the KeySet, then creates the bond structure from the complete146 * molecule and adds missing hydrogen where bonds were cut.147 * \param &Leaflet pointer to KeySet structure148 * \param IsAngstroem whether we have Ansgtroem or bohrradius149 * \return pointer to constructed molecule150 */151 molecule * ExportGraph_ToFiles::StoreFragmentFromKeySet(KeySet &Leaflet, bool IsAngstroem)152 {153 Info info(__func__);154 ListOfLocalAtoms_t SonList;155 molecule *Leaf = World::getInstance().createMolecule();156 157 StoreFragmentFromKeySet_Init(Leaf, Leaflet, SonList);158 // create the bonds between all: Make it an induced subgraph and add hydrogen159 // LOG(2, "Creating bonds from father graph (i.e. induced subgraph creation).");160 CreateInducedSubgraphOfFragment(Leaf, SonList, IsAngstroem);161 162 //Leaflet->Leaf->ScanForPeriodicCorrection(out);163 return Leaf;164 }165 166 /** Initializes some value for putting fragment of \a *mol into \a *Leaf.167 * \param *Leaf fragment molecule168 * \param &Leaflet pointer to KeySet structure169 * \param SonList calloc'd list which atom of \a *Leaf is a son of which atom in \a *mol170 * \return number of atoms in fragment171 */172 int ExportGraph_ToFiles::StoreFragmentFromKeySet_Init(molecule *Leaf, KeySet &Leaflet, ListOfLocalAtoms_t &SonList)173 {174 atom *FatherOfRunner = NULL;175 176 // first create the minimal set of atoms from the KeySet177 World &world = World::getInstance();178 int size = 0;179 for(KeySet::const_iterator runner = Leaflet.begin(); runner != Leaflet.end(); runner++) {180 FatherOfRunner = world.getAtom(AtomById(*runner)); // find the id181 SonList.insert( std::make_pair(FatherOfRunner->getNr(), Leaf->AddCopyAtom(FatherOfRunner) ) );182 size++;183 }184 return size;185 }186 187 /** Creates an induced subgraph out of a fragmental key set, adding bonds and hydrogens (if treated specially).188 * \param *Leaf fragment molecule189 * \param IsAngstroem whether we have Ansgtroem or bohrradius190 * \param SonList list which atom of \a *Leaf is another atom's son191 */192 void ExportGraph_ToFiles::CreateInducedSubgraphOfFragment(molecule *Leaf, ListOfLocalAtoms_t &SonList, bool IsAngstroem)193 {194 bool LonelyFlag = false;195 atom *OtherFather = NULL;196 atom *FatherOfRunner = NULL;197 198 // we increment the iter just before skipping the hydrogen199 // as we use AddBond, we cannot have a const_iterator here200 for (molecule::iterator iter = Leaf->begin(); iter != Leaf->end();) {201 LonelyFlag = true;202 FatherOfRunner = (*iter)->father;203 ASSERT(FatherOfRunner,"Atom without father found");204 if (SonList.find(FatherOfRunner->getNr()) != SonList.end()) { // check if this, our father, is present in list205 // create all bonds206 const BondList& ListOfBonds = FatherOfRunner->getListOfBonds();207 for (BondList::const_iterator BondRunner = ListOfBonds.begin();208 BondRunner != ListOfBonds.end();209 ++BondRunner) {210 OtherFather = (*BondRunner)->GetOtherAtom(FatherOfRunner);211 if (SonList.find(OtherFather->getNr()) != SonList.end()) {212 // LOG(2, "INFO: Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->getNr()]213 // << " is bound to " << *OtherFather << ", whose son is "214 // << *SonList[OtherFather->getNr()] << ".");215 if (OtherFather->getNr() > FatherOfRunner->getNr()) { // add bond (Nr check is for adding only one of both variants: ab, ba)216 std::stringstream output;217 // output << "ACCEPT: Adding Bond: "218 output << Leaf->AddBond((*iter), SonList[OtherFather->getNr()], (*BondRunner)->BondDegree);219 // LOG(3, output.str());220 //NumBonds[(*iter)->getNr()]++;221 } else {222 // LOG(3, "REJECY: Not adding bond, labels in wrong order.");223 }224 LonelyFlag = false;225 } else {226 // LOG(2, "INFO: Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->getNr()]227 // << " is bound to " << *OtherFather << ", who has no son in this fragment molecule.");228 if (saturation == DoSaturate) {229 // LOG(3, "ACCEPT: Adding Hydrogen to " << (*iter)->Name << " and a bond in between.");230 if (!Leaf->AddHydrogenReplacementAtom((*BondRunner), (*iter), FatherOfRunner, OtherFather, IsAngstroem))231 exit(1);232 } else if ((treatment == ExcludeHydrogen) && (OtherFather->getElementNo() == (atomicNumber_t)1)) {233 // just copy the atom if it's a hydrogen234 atom * const OtherWalker = Leaf->AddCopyAtom(OtherFather);235 Leaf->AddBond((*iter), OtherWalker, (*BondRunner)->BondDegree);236 }237 //NumBonds[(*iter)->getNr()] += Binder->BondDegree;238 }239 }240 } else {241 ELOG(1, "Son " << (*iter)->getName() << " has father " << FatherOfRunner->getName() << " but its entry in SonList is " << SonList[FatherOfRunner->getNr()] << "!");242 }243 if ((LonelyFlag) && (Leaf->getAtomCount() > 1)) {244 LOG(0, **iter << "has got bonds only to hydrogens!");245 }246 ++iter;247 if (saturation == DoSaturate) {248 while ((iter != Leaf->end()) && ((*iter)->getType()->getAtomicNumber() == 1)){ // skip added hydrogen249 iter++;250 }251 }252 }253 }254
Note:
See TracChangeset
for help on using the changeset viewer.