Changeset 451148


Ignore:
Timestamp:
Apr 29, 2008, 7:55:34 AM (17 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:
c750cc
Parents:
1fa5b7
Message:

Store/CheckAdj...() now also incorporate bond order to check against.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/molecules.cpp

    r1fa5b7 r451148  
    19421942 * \return true - file written successfully, false - writing failed
    19431943 */
    1944 bool molecule::StoreAdjacencyToFile(ofstream *out, char *path)
     1944bool molecule::StoreAdjacencyToFile(ofstream *out, char *path, int bondorder)
    19451945{
    19461946  ofstream AdjacencyFile;
     
    19531953  cout << Verbose(1) << "Saving adjacency list ... ";
    19541954  if (AdjacencyFile != NULL) {
     1955    AdjacencyFile << "Order\t" << bondorder << endl;
    19551956    Walker = start;
    19561957    while(Walker->next != end) {
     
    19761977 * \param *path path to file
    19771978 * \param **ListOfAtoms allocated (molecule::AtomCount) and filled lookup table for ids (Atom::nr) to *Atom
     1979 * \param bondorder check whether files matches desired bond order
    19781980 * \return true - structure is equal, false - not equivalence
    19791981 */
    1980 bool molecule::CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms)
     1982bool molecule::CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms, int bondorder)
    19811983{
    19821984  char *filename = (char *) Malloc(sizeof(char)*255, "molecule::CheckAdjacencyFileAgainstMolecule - filename");
     
    19921994    int *CurrentBonds = (int *) Malloc(sizeof(int)*8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom
    19931995    int CurrentBondsOfAtom;
    1994     // Parse the file line by line and count the bonds
    1995     while (!File.eof()) {
    1996       File.getline(filename, 255);
    1997       stringstream line;
    1998       line.str(filename);
    1999       int AtomNr = -1;
    2000       line >> AtomNr;
    2001       CurrentBondsOfAtom = -1; // we count one too far due to line end
    2002       // parse into structure
    2003       if ((AtomNr >= 0) && (AtomNr < AtomCount)) {
    2004         while (!line.eof())
    2005           line >> CurrentBonds[ ++CurrentBondsOfAtom ];
    2006         // compare against present bonds
    2007         //cout << Verbose(2) << "Walker is " << *Walker << ", bond partners: ";
    2008         if (CurrentBondsOfAtom == NumberOfBondsPerAtom[AtomNr]) {
    2009           for(int i=0;i<NumberOfBondsPerAtom[AtomNr];i++) {
    2010             int id = ListOfBondsPerAtom[AtomNr][i]->GetOtherAtom(ListOfAtoms[AtomNr])->nr;
    2011             int j = 0;
    2012             for (;(j<CurrentBondsOfAtom) && (CurrentBonds[j++] != id);); // check against all parsed bonds
    2013             if (CurrentBonds[j-1] != id) { // no match ? Then mark in ListOfAtoms
    2014               ListOfAtoms[AtomNr] = NULL;
    2015               NonMatchNumber++;
    2016               status = false;
    2017               //out << "[" << id << "]\t";
    2018             } else {
    2019               //out << id << "\t";
     1996
     1997    // determine order from file
     1998    File.getline(filename, 255);   
     1999    if (bondorder != atoi(&filename[5])) {
     2000      *out << "Bond order desired is " << bondorder << " and does not match one in file " << filename[6] << "." << endl;
     2001      status = false;
     2002    } else {
     2003      // Parse the file line by line and count the bonds
     2004      while (!File.eof()) {
     2005        File.getline(filename, 255);
     2006        stringstream line;
     2007        line.str(filename);
     2008        int AtomNr = -1;
     2009        line >> AtomNr;
     2010        CurrentBondsOfAtom = -1; // we count one too far due to line end
     2011        // parse into structure
     2012        if ((AtomNr >= 0) && (AtomNr < AtomCount)) {
     2013          while (!line.eof())
     2014            line >> CurrentBonds[ ++CurrentBondsOfAtom ];
     2015          // compare against present bonds
     2016          //cout << Verbose(2) << "Walker is " << *Walker << ", bond partners: ";
     2017          if (CurrentBondsOfAtom == NumberOfBondsPerAtom[AtomNr]) {
     2018            for(int i=0;i<NumberOfBondsPerAtom[AtomNr];i++) {
     2019              int id = ListOfBondsPerAtom[AtomNr][i]->GetOtherAtom(ListOfAtoms[AtomNr])->nr;
     2020              int j = 0;
     2021              for (;(j<CurrentBondsOfAtom) && (CurrentBonds[j++] != id);); // check against all parsed bonds
     2022              if (CurrentBonds[j-1] != id) { // no match ? Then mark in ListOfAtoms
     2023                ListOfAtoms[AtomNr] = NULL;
     2024                NonMatchNumber++;
     2025                status = false;
     2026                //out << "[" << id << "]\t";
     2027              } else {
     2028                //out << id << "\t";
     2029              }
    20202030            }
     2031            //out << endl;
     2032          } else {
     2033            *out << "Number of bonds for Atom " << *ListOfAtoms[AtomNr] << " does not match, parsed " << CurrentBondsOfAtom << " against " << NumberOfBondsPerAtom[AtomNr] << "." << endl;
     2034            status = false;
    20212035          }
    2022           //out << endl;
    2023         } else {
    2024           *out << "Number of bonds for Atom " << *ListOfAtoms[AtomNr] << " does not match, parsed " << CurrentBondsOfAtom << " against " << NumberOfBondsPerAtom[AtomNr] << "." << endl;
    2025           status = false;
    20262036        }
    20272037      }
    2028     }
    2029     File.close();
    2030     File.clear();
    2031     if (status) { // if equal we parse the KeySetFile
    2032       *out << " done: Equal." << endl;
    2033       status = true;
    2034     } else
    2035       *out << " done: Not equal by " << NonMatchNumber << " atoms." << endl;
     2038      File.close();
     2039      File.clear();
     2040      if (status) { // if equal we parse the KeySetFile
     2041        *out << " done: Equal." << endl;
     2042        status = true;
     2043      } else
     2044        *out << " done: Not equal by " << NonMatchNumber << " atoms." << endl;
     2045    }
    20362046    Free((void **)&CurrentBonds, "molecule::CheckAdjacencyFileAgainstMolecule - **CurrentBonds");
    20372047  } else {
     
    20932103    status = false;
    20942104  }
    2095   status = status && CheckAdjacencyFileAgainstMolecule(out, configuration->configpath, ListOfAtoms);
     2105  status = status && CheckAdjacencyFileAgainstMolecule(out, configuration->configpath, ListOfAtoms, BottomUpOrder);
    20962106  if (status) {  // NULL entries in ListOfAtoms contain NonMatches
    20972107    status = status && ParseKeySetFile(out, configuration->configpath, ListOfAtoms, FragmentList, configuration->GetIsAngstroem());
     
    21022112  if (!status) {
    21032113    // === store Adjacency file ===
    2104     StoreAdjacencyToFile(out, configuration->configpath);
     2114    StoreAdjacencyToFile(out, configuration->configpath, BottomUpOrder);
    21052115
    21062116    // === first perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs ===
  • src/molecules.hpp

    r1fa5b7 r451148  
    520520  /// Fragment molecule by two different approaches:
    521521  void FragmentMolecule(ofstream *out, int BottomUpOrder, int TopDownOrder, enum BondOrderScheme Scheme, config *configuration, enum CutCyclicBond CutCyclic);
    522   bool StoreAdjacencyToFile(ofstream *out, char *path);
    523   bool CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms);
     522  bool StoreAdjacencyToFile(ofstream *out, char *path, int bondorder);
     523  bool CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms, int bondorder);
    524524  bool ParseKeySetFile(ofstream *out, char *filename, atom **ListOfAtoms, MoleculeListClass *&FragmentList, bool IsAngstroem);
    525525  bool ScanBufferIntoKeySet(ofstream *out, char *buffer, KeySet &CurrentSet);
Note: See TracChangeset for help on using the changeset viewer.