Changeset 451148
- Timestamp:
- Apr 29, 2008, 7:55:34 AM (17 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:
- c750cc
- Parents:
- 1fa5b7
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecules.cpp
r1fa5b7 r451148 1942 1942 * \return true - file written successfully, false - writing failed 1943 1943 */ 1944 bool molecule::StoreAdjacencyToFile(ofstream *out, char *path )1944 bool molecule::StoreAdjacencyToFile(ofstream *out, char *path, int bondorder) 1945 1945 { 1946 1946 ofstream AdjacencyFile; … … 1953 1953 cout << Verbose(1) << "Saving adjacency list ... "; 1954 1954 if (AdjacencyFile != NULL) { 1955 AdjacencyFile << "Order\t" << bondorder << endl; 1955 1956 Walker = start; 1956 1957 while(Walker->next != end) { … … 1976 1977 * \param *path path to file 1977 1978 * \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 1978 1980 * \return true - structure is equal, false - not equivalence 1979 1981 */ 1980 bool molecule::CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms )1982 bool molecule::CheckAdjacencyFileAgainstMolecule(ofstream *out, char *path, atom **ListOfAtoms, int bondorder) 1981 1983 { 1982 1984 char *filename = (char *) Malloc(sizeof(char)*255, "molecule::CheckAdjacencyFileAgainstMolecule - filename"); … … 1992 1994 int *CurrentBonds = (int *) Malloc(sizeof(int)*8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 1993 1995 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 } 2020 2030 } 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; 2021 2035 } 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;2026 2036 } 2027 2037 } 2028 }2029 File.close();2030 File.clear();2031 if (status) { // if equal we parse the KeySetFile2032 *out << " done: Equal." << endl;2033 status = true;2034 } else2035 *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 } 2036 2046 Free((void **)&CurrentBonds, "molecule::CheckAdjacencyFileAgainstMolecule - **CurrentBonds"); 2037 2047 } else { … … 2093 2103 status = false; 2094 2104 } 2095 status = status && CheckAdjacencyFileAgainstMolecule(out, configuration->configpath, ListOfAtoms );2105 status = status && CheckAdjacencyFileAgainstMolecule(out, configuration->configpath, ListOfAtoms, BottomUpOrder); 2096 2106 if (status) { // NULL entries in ListOfAtoms contain NonMatches 2097 2107 status = status && ParseKeySetFile(out, configuration->configpath, ListOfAtoms, FragmentList, configuration->GetIsAngstroem()); … … 2102 2112 if (!status) { 2103 2113 // === store Adjacency file === 2104 StoreAdjacencyToFile(out, configuration->configpath );2114 StoreAdjacencyToFile(out, configuration->configpath, BottomUpOrder); 2105 2115 2106 2116 // === first perform a DFS analysis to gather info on cyclic structure and a list of disconnected subgraphs === -
src/molecules.hpp
r1fa5b7 r451148 520 520 /// Fragment molecule by two different approaches: 521 521 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); 524 524 bool ParseKeySetFile(ofstream *out, char *filename, atom **ListOfAtoms, MoleculeListClass *&FragmentList, bool IsAngstroem); 525 525 bool ScanBufferIntoKeySet(ofstream *out, char *buffer, KeySet &CurrentSet);
Note:
See TracChangeset
for help on using the changeset viewer.