source: src/Graph/CheckAgainstAdjacencyFile.cpp@ 255829

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
Last change on this file since 255829 was 255829, checked in by Frederik Heber <heber@…>, 14 years ago

Removed Helpers.hpp, deleted Helpers.cpp and libMoleCuilderHelpers.la is history.

  • defs.cpp is now compiled into libmolecuilder.la.
  • ShapeUnitTest alone needs defs.cpp.
  • Most changes are removal of Helpers/helpers.hpp.
  • performCriticalExit() now inline function in Helpers/helpers.hpp.
  • also inclusion possible where performCriticalExit() is needed.
  • Helpers/helpers.hpp does not include defs.hpp anymore and this causes lots of missing Helpers/defs.hpp, CodePatterns/Log.hpp and alikes.
  • removed src/Helpers from configure.ac.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * CheckAgainstAdjacencyFile.cpp
10 *
11 * Created on: Mar 3, 2011
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include <iostream>
23
24#include "CheckAgainstAdjacencyFile.hpp"
25
26#include "atom.hpp"
27#include "Bond/bond.hpp"
28#include "CodePatterns/Assert.hpp"
29#include "CodePatterns/Log.hpp"
30#include "CodePatterns/Verbose.hpp"
31#include "Helpers/defs.hpp"
32
33CheckAgainstAdjacencyFile::CheckAgainstAdjacencyFile() :
34 CurrentBonds(new int[MAXBONDS]),
35 status(true),
36 NonMatchNumber(0)
37{
38 for(int i=0;i<MAXBONDS;i++)
39 CurrentBonds[i] = 0;
40}
41
42CheckAgainstAdjacencyFile::~CheckAgainstAdjacencyFile()
43{
44 delete[](CurrentBonds);
45}
46
47void CheckAgainstAdjacencyFile::CompareBonds(const atom *&Walker, size_t &CurrentBondsOfAtom, int AtomNr, std::map<int, atom*> &ListOfAtoms)
48{
49 size_t j = 0;
50 int id = -1;
51
52 //Log() << Verbose(2) << "Walker is " << *Walker << ", bond partners: ";
53 const BondList& ListOfBonds = Walker->getListOfBonds();
54 if (CurrentBondsOfAtom == ListOfBonds.size()) {
55 for (BondList::const_iterator Runner = ListOfBonds.begin();
56 Runner != ListOfBonds.end();
57 ++Runner) {
58 id = (*Runner)->GetOtherAtom(Walker)->getNr();
59 j = 0;
60 for (; (j < CurrentBondsOfAtom) && (CurrentBonds[j++] != id);)
61 ; // check against all parsed bonds
62 if (CurrentBonds[j - 1] != id) { // no match ? Then mark in ListOfAtoms
63 ListOfAtoms[AtomNr] = NULL;
64 NonMatchNumber++;
65 status = false;
66 ELOG(2, id << " can not be found in list." << endl);
67 } else {
68 //Log() << Verbose(0) << "[" << id << "]\t";
69 }
70 }
71 //Log() << Verbose(0) << endl;
72 } else {
73 LOG(0, "STATUS: Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << ListOfBonds.size() << ".");
74 status = false;
75 }
76}
77;
78
79/** Checks contents of adjacency file against bond structure in structure molecule.
80 * \param File file to parser
81 * \param ListOfAtoms map from int (index in file) to atom
82 * \return true - structure is equal, false - not equivalence
83 */
84bool CheckAgainstAdjacencyFile::operator()(std::ifstream &File, std::map<int, atom*> ListOfAtoms)
85{
86 LOG(0, "STATUS: Looking at bond structure stored in adjacency file and comparing to present one ... ");
87 if (File.fail()) {
88 LOG(1, "STATUS: Adjacency file not found." << endl);
89 return false;
90 }
91
92 char buffer[MAXSTRINGSIZE];
93 int tmp;
94 // Parse the file line by line and count the bonds
95 while (!File.eof()) {
96 File.getline(buffer, MAXSTRINGSIZE);
97 stringstream line;
98 line.str(buffer);
99 int AtomNr = -1;
100 line >> AtomNr;
101 size_t CurrentBondsOfAtom = -1; // we count one too far due to line end
102 // parse into structure
103 if (AtomNr >= 0) {
104 ASSERT(ListOfAtoms.count(AtomNr),
105 "CheckAgainstAdjacencyFile::operator() - index "
106 +toString(AtomNr)+" not present in ListOfAtoms.");
107 const atom *Walker = ListOfAtoms[AtomNr];
108 while (line >> ws >> tmp) {
109 LOG(3, "INFO: Recognized bond partner " << tmp);
110 CurrentBonds[++CurrentBondsOfAtom] = tmp;
111 ASSERT(CurrentBondsOfAtom < MAXBONDS,
112 "molecule::CheckAdjacencyFileAgainstMolecule() - encountered more bonds than allowed: "
113 +toString(CurrentBondsOfAtom)+" >= "+toString(int(MAXBONDS))+"!");
114 }
115 // compare against present bonds
116 CompareBonds(Walker, CurrentBondsOfAtom, AtomNr, ListOfAtoms);
117 } else {
118 if (AtomNr != -1)
119 ELOG(2, AtomNr << " is negative.");
120 }
121 }
122
123 if (status) { // if equal we parse the KeySetFile
124 LOG(0, "STATUS: Equal.");
125 } else
126 LOG(0, "STATUS: Not equal by " << NonMatchNumber << " atoms.");
127 return status;
128}
129;
Note: See TracBrowser for help on using the repository browser.