Changeset 13a953


Ignore:
Timestamp:
Mar 11, 2011, 12:38:30 PM (14 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:
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)
Message:

Moved molecule::CheckAdjacencyAgainstFile() into functor in Graph/.

  • Note that this is currently not working because there is no correct mapping from indices in the adjacency file to the indices of the atoms (and without some fixed mean of aligning atoms, this will never be possible).
Location:
src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/Graph/Makefile.am

    r2d4334 r13a953  
    1010        BreadthFirstSearchAdd.cpp \
    1111        BuildInducedSubgraph.cpp \
     12        CheckAgainstAdjacencyFile.cpp \
    1213        ConnectedSubgraph.cpp \
    1314        CyclicStructureAnalysis.cpp \
     
    1718        BreadthFirstSearchAdd.hpp \
    1819        BuildInducedSubgraph.hpp \
     20        CheckAgainstAdjacencyFile.hpp \
    1921        ConnectedSubgraph.hpp \
    2022        CyclicStructureAnalysis.hpp \
  • src/molecule.hpp

    r2d4334 r13a953  
    216216  bool StoreBondsToFile(std::string filename, std::string path = "");
    217217  bool StoreAdjacencyToFile(std::string filename, std::string path = "");
    218   bool CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms);
    219218  bool ParseOrderAtSiteFromFile(std::string &path);
    220219  bool StoreOrderAtSiteFile(std::string &path);
  • src/molecule_fragmentation.cpp

    r2d4334 r13a953  
    3030#include "element.hpp"
    3131#include "Graph/BondGraph.hpp"
     32#include "Graph/CheckAgainstAdjacencyFile.hpp"
    3233#include "Graph/CyclicStructureAnalysis.hpp"
    3334#include "Graph/DepthFirstSearchAnalysis.hpp"
     
    609610};
    610611
     612
    611613/** Performs a many-body bond order analysis for a given bond order.
    612614 * -# parses adjacency, keysets and orderatsite files
     
    640642  Graph TotalGraph;     // graph with all keysets however local numbers
    641643  int TotalNumberOfKeySets = 0;
    642   atom **ListOfAtoms = NULL;
    643644  atom ***ListOfLocalAtoms = NULL;
    644645  bool *AtomMask = NULL;
     
    655656  // ===== 1. Check whether bond structure is same as stored in files ====
    656657
    657   // create lookup table for Atom::Nr
    658   FragmentationToDo = FragmentationToDo && CreateFatherLookupTable(ListOfAtoms, getAtomCount());
    659 
    660658  // === 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  }
    663677
    664678  // === reset bond degree and perform CorrectBondDegree ===
  • src/molecule_graph.cpp

    r2d4334 r13a953  
    4343#include "WorldTime.hpp"
    4444
    45 #define MAXBONDS 8
    46 
    4745
    4846/** Fills the bond structure of this chain list subgraphs that are derived from a complete \a *reference molecule.
     
    198196;
    199197
    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 structure
    210   CurrentBonds = new int[MAXBONDS]; // contains parsed bonds of current atom
    211   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 bonds
    240       if (CurrentBonds[j - 1] != id) { // no match ? Then mark in ListOfAtoms
    241         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 file
    259  * \param **ListOfAtoms allocated (molecule::AtomCount) and filled lookup table for ids (Atom::Nr) to *Atom
    260  * \return true - structure is equal, false - not equivalence
    261  */
    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 structure
    269   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 bonds
    280   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 end
    287     // parse into structure
    288     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 bonds
    298       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 KeySetFile
    307     DoLog(1) && (Log() << Verbose(1) << "done: Equal." << endl);
    308   } else
    309     DoLog(1) && (Log() << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl);
    310   return status;
    311 }
    312 ;
    313 
    314198/** Adds a bond as a copy to a given one
    315199 * \param *left leftatom of new bond
Note: See TracChangeset for help on using the changeset viewer.