- Timestamp:
- Oct 18, 2009, 5:07:33 PM (15 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:
- ce7cc5
- Parents:
- df8b19
- git-author:
- Frederik Heber <heber@…> (10/18/09 17:06:28)
- git-committer:
- Frederik Heber <heber@…> (10/18/09 17:07:33)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_graph.cpp
rdf8b19 rba4170 846 846 }; 847 847 848 bool CheckAdjacencyFileAgainstMolecule_Init(ofstream *out, char *path, ifstream &File, int *&CurrentBonds) 849 { 850 stringstream filename; 851 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 852 File.open(filename.str().c_str(), ios::out); 853 *out << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... "; 854 if (File == NULL) 855 return false; 856 857 // allocate storage structure 858 CurrentBonds = Malloc<int>(8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 859 return true; 860 }; 861 862 void CheckAdjacencyFileAgainstMolecule_Finalize(ofstream *out, ifstream &File, int *&CurrentBonds) 863 { 864 File.close(); 865 File.clear(); 866 Free(&CurrentBonds); 867 }; 868 869 void CheckAdjacencyFileAgainstMolecule_CompareBonds(ofstream *out, bool &status, int &NonMatchNumber, atom *&Walker, size_t &CurrentBondsOfAtom, int AtomNr, int *&CurrentBonds, atom **ListOfAtoms) 870 { 871 size_t j = 0; 872 int id = -1; 873 874 //*out << Verbose(2) << "Walker is " << *Walker << ", bond partners: "; 875 if (CurrentBondsOfAtom == Walker->ListOfBonds.size()) { 876 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 877 id = (*Runner)->GetOtherAtom(Walker)->nr; 878 j = 0; 879 for (;(j<CurrentBondsOfAtom) && (CurrentBonds[j++] != id);) 880 ; // check against all parsed bonds 881 if (CurrentBonds[j-1] != id) { // no match ? Then mark in ListOfAtoms 882 ListOfAtoms[AtomNr] = NULL; 883 NonMatchNumber++; 884 status = false; 885 //*out << "[" << id << "]\t"; 886 } else { 887 //*out << id << "\t"; 888 } 889 } 890 //*out << endl; 891 } else { 892 *out << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl; 893 status = false; 894 } 895 }; 896 848 897 /** Checks contents of adjacency file against bond structure in structure molecule. 849 898 * \param *out output stream for debugging … … 855 904 { 856 905 ifstream File; 857 stringstream filename;858 906 bool status = true; 859 907 atom *Walker = NULL; 860 char *buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer"); 861 862 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 863 File.open(filename.str().c_str(), ios::out); 864 *out << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... "; 865 if (File != NULL) { 866 // allocate storage structure 867 int NonMatchNumber = 0; // will number of atoms with differing bond structure 868 int *CurrentBonds = Malloc<int>(8, "molecule::CheckAdjacencyFileAgainstMolecule - CurrentBonds"); // contains parsed bonds of current atom 869 size_t CurrentBondsOfAtom; 870 871 // Parse the file line by line and count the bonds 872 while (!File.eof()) { 873 File.getline(buffer, MAXSTRINGSIZE); 874 stringstream line; 875 line.str(buffer); 876 int AtomNr = -1; 877 line >> AtomNr; 878 CurrentBondsOfAtom = -1; // we count one too far due to line end 879 // parse into structure 880 if ((AtomNr >= 0) && (AtomNr < AtomCount)) { 881 Walker = ListOfAtoms[AtomNr]; 882 while (!line.eof()) 883 line >> CurrentBonds[ ++CurrentBondsOfAtom ]; 884 // compare against present bonds 885 //cout << Verbose(2) << "Walker is " << *Walker << ", bond partners: "; 886 if (CurrentBondsOfAtom == Walker->ListOfBonds.size()) { 887 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 888 int id = (*Runner)->GetOtherAtom(Walker)->nr; 889 size_t j = 0; 890 for (;(j<CurrentBondsOfAtom) && (CurrentBonds[j++] != id);); // check against all parsed bonds 891 if (CurrentBonds[j-1] != id) { // no match ? Then mark in ListOfAtoms 892 ListOfAtoms[AtomNr] = NULL; 893 NonMatchNumber++; 894 status = false; 895 //out << "[" << id << "]\t"; 896 } else { 897 //out << id << "\t"; 898 } 899 } 900 //out << endl; 901 } else { 902 *out << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl; 903 status = false; 904 } 905 } 906 } 907 File.close(); 908 File.clear(); 909 if (status) { // if equal we parse the KeySetFile 910 *out << Verbose(1) << "done: Equal." << endl; 911 status = true; 912 } else 913 *out << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl; 914 Free(&CurrentBonds); 915 } else { 908 char *buffer = NULL; 909 int *CurrentBonds = NULL; 910 int NonMatchNumber = 0; // will number of atoms with differing bond structure 911 size_t CurrentBondsOfAtom = -1; 912 913 if (!CheckAdjacencyFileAgainstMolecule_Init(out, path, File, CurrentBonds)) { 916 914 *out << Verbose(1) << "Adjacency file not found." << endl; 917 status = false; 918 } 919 *out << endl; 915 return true; 916 } 917 918 buffer = Malloc<char>(MAXSTRINGSIZE, "molecule::CheckAdjacencyFileAgainstMolecule: *buffer"); 919 // Parse the file line by line and count the bonds 920 while (!File.eof()) { 921 File.getline(buffer, MAXSTRINGSIZE); 922 stringstream line; 923 line.str(buffer); 924 int AtomNr = -1; 925 line >> AtomNr; 926 CurrentBondsOfAtom = -1; // we count one too far due to line end 927 // parse into structure 928 if ((AtomNr >= 0) && (AtomNr < AtomCount)) { 929 Walker = ListOfAtoms[AtomNr]; 930 while (!line.eof()) 931 line >> CurrentBonds[ ++CurrentBondsOfAtom ]; 932 // compare against present bonds 933 CheckAdjacencyFileAgainstMolecule_CompareBonds(out, status, NonMatchNumber, Walker, CurrentBondsOfAtom, AtomNr, CurrentBonds, ListOfAtoms); 934 } 935 } 920 936 Free(&buffer); 921 937 CheckAdjacencyFileAgainstMolecule_Finalize(out, File, CurrentBonds); 938 939 if (status) { // if equal we parse the KeySetFile 940 *out << Verbose(1) << "done: Equal." << endl; 941 } else 942 *out << Verbose(1) << "done: Not equal by " << NonMatchNumber << " atoms." << endl; 922 943 return status; 923 944 };
Note:
See TracChangeset
for help on using the changeset viewer.