Changeset 13a953
- Timestamp:
- Mar 11, 2011, 12:38:30 PM (14 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:
- 61775a
- Parents:
- 2d4334
- git-author:
- Frederik Heber <heber@…> (03/03/11 01:28:42)
- git-committer:
- Frederik Heber <heber@…> (03/11/11 12:38:30)
- Location:
- src
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Graph/Makefile.am
r2d4334 r13a953 10 10 BreadthFirstSearchAdd.cpp \ 11 11 BuildInducedSubgraph.cpp \ 12 CheckAgainstAdjacencyFile.cpp \ 12 13 ConnectedSubgraph.cpp \ 13 14 CyclicStructureAnalysis.cpp \ … … 17 18 BreadthFirstSearchAdd.hpp \ 18 19 BuildInducedSubgraph.hpp \ 20 CheckAgainstAdjacencyFile.hpp \ 19 21 ConnectedSubgraph.hpp \ 20 22 CyclicStructureAnalysis.hpp \ -
src/molecule.hpp
r2d4334 r13a953 216 216 bool StoreBondsToFile(std::string filename, std::string path = ""); 217 217 bool StoreAdjacencyToFile(std::string filename, std::string path = ""); 218 bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);219 218 bool ParseOrderAtSiteFromFile(std::string &path); 220 219 bool StoreOrderAtSiteFile(std::string &path); -
src/molecule_fragmentation.cpp
r2d4334 r13a953 30 30 #include "element.hpp" 31 31 #include "Graph/BondGraph.hpp" 32 #include "Graph/CheckAgainstAdjacencyFile.hpp" 32 33 #include "Graph/CyclicStructureAnalysis.hpp" 33 34 #include "Graph/DepthFirstSearchAnalysis.hpp" … … 609 610 }; 610 611 612 611 613 /** Performs a many-body bond order analysis for a given bond order. 612 614 * -# parses adjacency, keysets and orderatsite files … … 640 642 Graph TotalGraph; // graph with all keysets however local numbers 641 643 int TotalNumberOfKeySets = 0; 642 atom **ListOfAtoms = NULL;643 644 atom ***ListOfLocalAtoms = NULL; 644 645 bool *AtomMask = NULL; … … 655 656 // ===== 1. Check whether bond structure is same as stored in files ==== 656 657 657 // create lookup table for Atom::Nr658 FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());659 660 658 // === compare it with adjacency file === 661 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(prefix, ListOfAtoms); 662 delete[](ListOfAtoms); 659 { 660 std::ifstream File; 661 string filename; 662 filename = prefix + ADJACENCYFILE; 663 File.open(filename.c_str(), ios::out); 664 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl); 665 std::map<int, atom*> ListOfAtoms; 666 std::pair<std::map<int, atom*>::iterator, bool> inserter; 667 for (const_iterator iter = begin(); 668 iter != end(); 669 ++iter) { 670 atom *Walker = *iter; 671 inserter = ListOfAtoms.insert( make_pair( Walker->GetTrueFather()->getNr(), Walker) ); 672 FragmentationToDo = FragmentationToDo && inserter.second; 673 } 674 CheckAgainstAdjacencyFile FileChecker; 675 FragmentationToDo = FragmentationToDo && FileChecker(File, ListOfAtoms); 676 } 663 677 664 678 // === reset bond degree and perform CorrectBondDegree === -
src/molecule_graph.cpp
r2d4334 r13a953 43 43 #include "WorldTime.hpp" 44 44 45 #define MAXBONDS 846 47 45 48 46 /** Fills the bond structure of this chain list subgraphs that are derived from a complete \a *reference molecule. … … 198 196 ; 199 197 200 bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds)201 {202 string filename;203 filename = path + ADJACENCYFILE;204 File.open(filename.c_str(), ios::out);205 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);206 if (File.fail())207 return false;208 209 // allocate storage structure210 CurrentBonds = new int[MAXBONDS]; // contains parsed bonds of current atom211 for(int i=0;i<MAXBONDS;i++)212 CurrentBonds[i] = 0;213 return true;214 }215 ;216 217 void CheckAdjacencyFileAgainstMolecule_Finalize(ifstream &File, int *&CurrentBonds)218 {219 File.close();220 File.clear();221 delete[](CurrentBonds);222 }223 ;224 225 void CheckAdjacencyFileAgainstMolecule_CompareBonds(bool &status, int &NonMatchNumber, atom *&Walker, size_t &CurrentBondsOfAtom, int AtomNr, int *&CurrentBonds, atom **ListOfAtoms)226 {227 size_t j = 0;228 int id = -1;229 230 //Log() << Verbose(2) << "Walker is " << *Walker << ", bond partners: ";231 const BondList& ListOfBonds = Walker->getListOfBonds();232 if (CurrentBondsOfAtom == ListOfBonds.size()) {233 for (BondList::const_iterator Runner = ListOfBonds.begin();234 Runner != ListOfBonds.end();235 ++Runner) {236 id = (*Runner)->GetOtherAtom(Walker)->getNr();237 j = 0;238 for (; (j < CurrentBondsOfAtom) && (CurrentBonds[j++] != id);)239 ; // check against all parsed bonds240 if (CurrentBonds[j - 1] != id) { // no match ? Then mark in ListOfAtoms241 ListOfAtoms[AtomNr] = NULL;242 NonMatchNumber++;243 status = false;244 DoeLog(2) && (eLog() << Verbose(2) << id << " can not be found in list." << endl);245 } else {246 //Log() << Verbose(0) << "[" << id << "]\t";247 }248 }249 //Log() << Verbose(0) << endl;250 } else {251 DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << ListOfBonds.size() << "." << endl);252 status = false;253 }254 }255 ;256 257 /** Checks contents of adjacency file against bond structure in structure molecule.258 * \param *path path to file259 * \param **ListOfAtoms allocated (molecule::AtomCount) and filled lookup table for ids (Atom::Nr) to *Atom260 * \return true - structure is equal, false - not equivalence261 */262 bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)263 {264 ifstream File;265 bool status = true;266 atom *Walker = NULL;267 int *CurrentBonds = NULL;268 int NonMatchNumber = 0; // will number of atoms with differing bond structure269 size_t CurrentBondsOfAtom = -1;270 const int AtomCount = getAtomCount();271 272 if (!CheckAdjacencyFileAgainstMolecule_Init(path, File, CurrentBonds)) {273 DoLog(1) && (Log() << Verbose(1) << "Adjacency file not found." << endl);274 return true;275 }276 277 char buffer[MAXSTRINGSIZE];278 int tmp;279 // Parse the file line by line and count the bonds280 while (!File.eof()) {281 File.getline(buffer, MAXSTRINGSIZE);282 stringstream line;283 line.str(buffer);284 int AtomNr = -1;285 line >> AtomNr;286 CurrentBondsOfAtom = -1; // we count one too far due to line end287 // parse into structure288 if ((AtomNr >= 0) && (AtomNr < AtomCount)) {289 Walker = ListOfAtoms[AtomNr];290 while (line >> ws >> tmp) {291 std::cout << "Recognized bond partner " << tmp << std::endl;292 CurrentBonds[++CurrentBondsOfAtom] = tmp;293 ASSERT(CurrentBondsOfAtom < MAXBONDS,294 "molecule::CheckAdjacencyFileAgainstMolecule() - encountered more bonds than allowed: "295 +toString(CurrentBondsOfAtom)+" >= "+toString(MAXBONDS)+"!");296 }297 // compare against present bonds298 CheckAdjacencyFileAgainstMolecule_CompareBonds(status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms);299 } else {300 if (AtomNr != -1)301 DoeLog(2) && (eLog() << Verbose(2) << AtomNr << " is not valid in the range of ids [" << 0 << "," << AtomCount << ")." << endl);302 }303 }304 CheckAdjacencyFileAgainstMolecule_Finalize(File, CurrentBonds);305 306 if (status) { // if equal we parse the KeySetFile307 DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl);308 } else309 DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl);310 return status;311 }312 ;313 314 198 /** Adds a bond as a copy to a given one 315 199 * \param *left leftatom of new bond
Note:
See TracChangeset
for help on using the changeset viewer.