Changes in src/molecule_fragmentation.cpp [a67d19:e359a8]
- File:
-
- 1 edited
-
src/molecule_fragmentation.cpp (modified) (62 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_fragmentation.cpp
ra67d19 re359a8 5 5 * Author: heber 6 6 */ 7 8 #include <cstring>9 7 10 8 #include "atom.hpp" … … 18 16 #include "molecule.hpp" 19 17 #include "periodentafel.hpp" 20 #include "World.hpp"21 18 22 19 /************************************* Functions for class molecule *********************************/ … … 44 41 } 45 42 FragmentCount = NoNonHydrogen*(1 << (c*order)); 46 DoLog(1) && (Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl);43 Log() << Verbose(1) << "Upper limit for this subgraph is " << FragmentCount << " for " << NoNonHydrogen << " non-H atoms with maximum bond degree of " << c << "." << endl; 47 44 return FragmentCount; 48 45 }; … … 68 65 } // else it's "-1" or else and thus must not be added 69 66 } 70 DoLog(1) && (Log() << Verbose(1) << "The scanned KeySet is ");67 Log() << Verbose(1) << "The scanned KeySet is "; 71 68 for(KeySet::iterator runner = CurrentSet.begin(); runner != CurrentSet.end(); runner++) { 72 DoLog(0) && (Log() << Verbose(0) << (*runner) << "\t");73 } 74 DoLog(0) && (Log() << Verbose(0) << endl);69 Log() << Verbose(0) << (*runner) << "\t"; 70 } 71 Log() << Verbose(0) << endl; 75 72 return (status != 0); 76 73 }; … … 100 97 101 98 // 1st pass: open file and read 102 DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl);99 Log() << Verbose(1) << "Parsing the KeySet file ... " << endl; 103 100 sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE); 104 101 InputFile.open(filename); … … 113 110 testGraphInsert = FragmentList->insert(GraphPair (CurrentSet,pair<int,double>(NumberOfFragments++,1))); // store fragment number and current factor 114 111 if (!testGraphInsert.second) { 115 DoeLog(0) && (eLog()<< Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl);112 eLog() << Verbose(0) << "KeySet file must be corrupt as there are two equal key sets therein!" << endl; 116 113 performCriticalExit(); 117 114 } … … 122 119 InputFile.clear(); 123 120 Free(&buffer); 124 DoLog(1) && (Log() << Verbose(1) << "done." << endl);121 Log() << Verbose(1) << "done." << endl; 125 122 } else { 126 DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);123 Log() << Verbose(1) << "File " << filename << " not found." << endl; 127 124 status = false; 128 125 } … … 154 151 155 152 // 2nd pass: open TEFactors file and read 156 DoLog(1) && (Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl);153 Log() << Verbose(1) << "Parsing the TEFactors file ... " << endl; 157 154 sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, TEFACTORSFILE); 158 155 InputFile.open(filename); … … 164 161 InputFile >> TEFactor; 165 162 (*runner).second.second = TEFactor; 166 DoLog(2) && (Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl);163 Log() << Verbose(2) << "Setting " << ++NumberOfFragments << " fragment's TEFactor to " << (*runner).second.second << "." << endl; 167 164 } else { 168 165 status = false; … … 172 169 // 4. Free and done 173 170 InputFile.close(); 174 DoLog(1) && (Log() << Verbose(1) << "done." << endl);171 Log() << Verbose(1) << "done." << endl; 175 172 } else { 176 DoLog(1) && (Log() << Verbose(1) << "File " << filename << " not found." << endl);173 Log() << Verbose(1) << "File " << filename << " not found." << endl; 177 174 status = false; 178 175 } … … 202 199 line += KEYSETFILE; 203 200 output.open(line.c_str(), ios::out); 204 DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... ");201 Log() << Verbose(1) << "Saving key sets of the total graph ... "; 205 202 if(output != NULL) { 206 203 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) { … … 212 209 output << endl; 213 210 } 214 DoLog(0) && (Log() << Verbose(0) << "done." << endl);211 Log() << Verbose(0) << "done." << endl; 215 212 } else { 216 DoeLog(0) && (eLog()<< Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl);213 eLog() << Verbose(0) << "Unable to open " << line << " for writing keysets!" << endl; 217 214 performCriticalExit(); 218 215 status = false; … … 243 240 line += TEFACTORSFILE; 244 241 output.open(line.c_str(), ios::out); 245 DoLog(1) && (Log() << Verbose(1) << "Saving TEFactors of the total graph ... ");242 Log() << Verbose(1) << "Saving TEFactors of the total graph ... "; 246 243 if(output != NULL) { 247 244 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) 248 245 output << (*runner).second.second << endl; 249 DoLog(1) && (Log() << Verbose(1) << "done." << endl);246 Log() << Verbose(1) << "done." << endl; 250 247 } else { 251 DoLog(1) && (Log() << Verbose(1) << "failed to open " << line << "." << endl);248 Log() << Verbose(1) << "failed to open " << line << "." << endl; 252 249 status = false; 253 250 } … … 293 290 (*PresentItem).second.first = fabs(Value); 294 291 (*PresentItem).second.second = FragOrder; 295 DoLog(2) && (Log() << Verbose(2) << "Updated element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);292 Log() << Verbose(2) << "Updated element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl; 296 293 } else { 297 DoLog(2) && (Log() << Verbose(2) << "Did not update element " << (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl);294 Log() << Verbose(2) << "Did not update element " << (*PresentItem).first << " as " << FragOrder << " is less than or equal to " << (*PresentItem).second.second << "." << endl; 298 295 } 299 296 } else { 300 DoLog(2) && (Log() << Verbose(2) << "Inserted element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl);297 Log() << Verbose(2) << "Inserted element (" << (*PresentItem).first << ",[" << (*PresentItem).second.first << "," << (*PresentItem).second.second << "])." << endl; 301 298 } 302 299 } else { 303 DoLog(1) && (Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl);300 Log() << Verbose(1) << "No Fragment under No. " << No << "found." << endl; 304 301 } 305 302 }; … … 360 357 atom *Walker = mol->start; 361 358 map<double, pair<int,int> > *FinalRootCandidates = new map<double, pair<int,int> > ; 362 DoLog(1) && (Log() << Verbose(1) << "Root candidate list is: " << endl);359 Log() << Verbose(1) << "Root candidate list is: " << endl; 363 360 for(map<int, pair<double,int> >::iterator runner = AdaptiveCriteriaList->begin(); runner != AdaptiveCriteriaList->end(); runner++) { 364 361 Walker = mol->FindAtom((*runner).first); … … 366 363 //if ((*runner).second.second >= Walker->AdaptiveOrder) { // only insert if this is an "active" root site for the current order 367 364 if (!Walker->MaxOrder) { 368 DoLog(2) && (Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl);365 Log() << Verbose(2) << "(" << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "])" << endl; 369 366 FinalRootCandidates->insert( make_pair( (*runner).second.first, pair<int,int>((*runner).first, (*runner).second.second) ) ); 370 367 } else { 371 DoLog(2) && (Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl);368 Log() << Verbose(2) << "Excluding (" << *Walker << ", " << (*runner).first << ",[" << (*runner).second.first << "," << (*runner).second.second << "]), as it has reached its maximum order." << endl; 372 369 } 373 370 } else { 374 DoeLog(0) && (eLog()<< Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl);371 eLog() << Verbose(0) << "Atom No. " << (*runner).second.first << " was not found in this molecule." << endl; 375 372 performCriticalExit(); 376 373 } … … 397 394 Walker = mol->FindAtom(No); 398 395 //if (Walker->AdaptiveOrder < MinimumRingSize[Walker->nr]) { 399 DoLog(2) && (Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl);396 Log() << Verbose(2) << "Root " << No << " is still above threshold (10^{" << Order <<"}: " << runner->first << ", setting entry " << No << " of Atom mask to true." << endl; 400 397 AtomMask[No] = true; 401 398 status = true; … … 413 410 void PrintAtomMask(bool *AtomMask, int AtomCount) 414 411 { 415 DoLog(2) && (Log() << Verbose(2) << " ");412 Log() << Verbose(2) << " "; 416 413 for(int i=0;i<AtomCount;i++) 417 DoLog(0) && (Log() << Verbose(0) << (i % 10));418 DoLog(0) && (Log() << Verbose(0) << endl);419 DoLog(2) && (Log() << Verbose(2) << "Atom mask is: ");414 Log() << Verbose(0) << (i % 10); 415 Log() << Verbose(0) << endl; 416 Log() << Verbose(2) << "Atom mask is: "; 420 417 for(int i=0;i<AtomCount;i++) 421 DoLog(0) && (Log() << Verbose(0) << (AtomMask[i] ? "t" : "f"));422 DoLog(0) && (Log() << Verbose(0) << endl);418 Log() << Verbose(0) << (AtomMask[i] ? "t" : "f"); 419 Log() << Verbose(0) << endl; 423 420 }; 424 421 … … 447 444 // transmorph graph keyset list into indexed KeySetList 448 445 if (GlobalKeySetList == NULL) { 449 DoeLog(1) && (eLog()<< Verbose(1) << "Given global key set list (graph) is NULL!" << endl);446 eLog() << Verbose(1) << "Given global key set list (graph) is NULL!" << endl; 450 447 return false; 451 448 } … … 455 452 map<int, pair<double,int> > *AdaptiveCriteriaList = ScanAdaptiveFileIntoMap(path, *IndexKeySetList); // (Root No., (Value, Order)) ! 456 453 if (AdaptiveCriteriaList->empty()) { 457 DoeLog(2) && (eLog()<< Verbose(2) << "Unable to parse file, incrementing all." << endl);454 eLog() << Verbose(2) << "Unable to parse file, incrementing all." << endl; 458 455 while (Walker->next != end) { 459 456 Walker = Walker->next; … … 493 490 if (!status) { 494 491 if (Order == 0) 495 DoLog(1) && (Log() << Verbose(1) << "Single stepping done." << endl);492 Log() << Verbose(1) << "Single stepping done." << endl; 496 493 else 497 DoLog(1) && (Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl);494 Log() << Verbose(1) << "Order at every site is already equal or above desired order " << Order << "." << endl; 498 495 } 499 496 } … … 512 509 { 513 510 if (SortIndex != NULL) { 514 DoLog(1) && (Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl);511 Log() << Verbose(1) << "SortIndex is " << SortIndex << " and not NULL as expected." << endl; 515 512 return false; 516 513 } … … 563 560 bool *AtomMask = NULL; 564 561 565 DoLog(0) && (Log() << Verbose(0) << endl);562 Log() << Verbose(0) << endl; 566 563 #ifdef ADDHYDROGEN 567 DoLog(0) && (Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl);564 Log() << Verbose(0) << "I will treat hydrogen special and saturate dangling bonds with it." << endl; 568 565 #else 569 DoLog(0) && (Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl);566 Log() << Verbose(0) << "Hydrogen is treated just like the rest of the lot." << endl; 570 567 #endif 571 568 … … 593 590 // fill the bond structure of the individually stored subgraphs 594 591 MolecularWalker->FillBondStructureFromReference(this, FragmentCounter, ListOfLocalAtoms, false); // we want to keep the created ListOfLocalAtoms 595 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);592 Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl; 596 593 LocalBackEdgeStack = new StackClass<bond *> (MolecularWalker->Leaf->BondCount); 597 594 // // check the list of local atoms for debugging … … 602 599 // else 603 600 // Log() << Verbose(0) << "\t" << ListOfLocalAtoms[FragmentCounter][i]->Name; 604 DoLog(0) && (Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);601 Log() << Verbose(0) << "Gathering local back edges for subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl; 605 602 MolecularWalker->Leaf->PickLocalBackEdges(ListOfLocalAtoms[FragmentCounter++], BackEdgeStack, LocalBackEdgeStack); 606 DoLog(0) && (Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);603 Log() << Verbose(0) << "Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl; 607 604 MolecularWalker->Leaf->CyclicStructureAnalysis(LocalBackEdgeStack, MinimumRingSize); 608 DoLog(0) && (Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl);605 Log() << Verbose(0) << "Done with Analysing the cycles of subgraph " << MolecularWalker->Leaf << " with nr. " << FragmentCounter << "." << endl; 609 606 delete(LocalBackEdgeStack); 610 607 } … … 637 634 while (MolecularWalker->next != NULL) { 638 635 MolecularWalker = MolecularWalker->next; 639 DoLog(1) && (Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl);636 Log() << Verbose(1) << "Fragmenting subgraph " << MolecularWalker << "." << endl; 640 637 //MolecularWalker->Leaf->OutputListOfBonds(out); // output atom::ListOfBonds for debugging 641 638 if (MolecularWalker->Leaf->first->next != MolecularWalker->Leaf->last) { 642 639 // call BOSSANOVA method 643 DoLog(0) && (Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl);640 Log() << Verbose(0) << endl << " ========== BOND ENERGY of subgraph " << FragmentCounter << " ========================= " << endl; 644 641 MolecularWalker->Leaf->FragmentBOSSANOVA(FragmentList[FragmentCounter], RootStack[FragmentCounter], MinimumRingSize); 645 642 } else { 646 DoeLog(1) && (eLog()<< Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl);643 eLog() << Verbose(1) << "Subgraph " << MolecularWalker << " has no atoms!" << endl; 647 644 } 648 645 FragmentCounter++; // next fragment list 649 646 } 650 647 } 651 DoLog(2) && (Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl);648 Log() << Verbose(2) << "CheckOrder is " << CheckOrder << "." << endl; 652 649 delete[](RootStack); 653 650 delete[](AtomMask); … … 680 677 for(Graph::iterator runner = TotalGraph.begin(); runner != TotalGraph.end(); runner++) { 681 678 KeySet test = (*runner).first; 682 DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl);679 Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl; 683 680 BondFragments->insert(StoreFragmentFromKeySet(test, configuration)); 684 681 k++; 685 682 } 686 DoLog(0) && (Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl);683 Log() << Verbose(0) << k << "/" << BondFragments->ListOfMolecules.size() << " fragments generated from the keysets." << endl; 687 684 688 685 // ===== 9. Save fragments' configuration and keyset files et al to disk === … … 691 688 CreateMappingLabelsToConfigSequence(SortIndex); 692 689 693 DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl);690 Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl; 694 691 if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex)) 695 DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl);692 Log() << Verbose(1) << "All configs written." << endl; 696 693 else 697 DoLog(1) && (Log() << Verbose(1) << "Some config writing failed." << endl);694 Log() << Verbose(1) << "Some config writing failed." << endl; 698 695 699 696 // store force index reference file … … 704 701 705 702 // store Adjacency file 706 char *filename = Malloc<char> (MAXSTRINGSIZE, "molecule::FragmentMolecule - *filename"); 707 strcpy(filename, FRAGMENTPREFIX); 708 strcat(filename, ADJACENCYFILE); 709 StoreAdjacencyToFile(configuration->configpath, filename); 710 Free(&filename); 703 StoreAdjacencyToFile(configuration->configpath); 711 704 712 705 // store Hydrogen saturation correction file … … 720 713 721 714 // free memory for bond part 722 DoLog(1) && (Log() << Verbose(1) << "Freeing bond memory" << endl);715 Log() << Verbose(1) << "Freeing bond memory" << endl; 723 716 delete(FragmentList); // remove bond molecule from memory 724 717 Free(&SortIndex); 725 718 } else { 726 DoLog(1) && (Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl);719 Log() << Verbose(1) << "FragmentList is zero on return, splitting failed." << endl; 727 720 } 728 721 delete(BondFragments); 729 DoLog(0) && (Log() << Verbose(0) << "End of bond fragmentation." << endl);722 Log() << Verbose(0) << "End of bond fragmentation." << endl; 730 723 731 724 return ((int)(!FragmentationToDo)+1); // 1 - continue, 2 - stop (no fragmentation occured) … … 746 739 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 747 740 file.open(line.str().c_str()); 748 DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl);741 Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl; 749 742 if (file != NULL) { 750 743 ActOnAllAtoms( &atom::OutputOrder, &file ); 751 744 file.close(); 752 DoLog(1) && (Log() << Verbose(1) << "done." << endl);745 Log() << Verbose(1) << "done." << endl; 753 746 return true; 754 747 } else { 755 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);748 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl; 756 749 return false; 757 750 } … … 774 767 ifstream file; 775 768 776 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl);769 Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl; 777 770 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 778 771 file.open(line.str().c_str()); … … 795 788 SetAtomValueToIndexedArray( MaxArray, &atom::nr, &atom::MaxOrder ); 796 789 797 DoLog(1) && (Log() << Verbose(1) << "done." << endl);790 Log() << Verbose(1) << "done." << endl; 798 791 status = true; 799 792 } else { 800 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl);793 Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl; 801 794 status = false; 802 795 } … … 804 797 Free(&MaxArray); 805 798 806 DoLog(1) && (Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl);799 Log() << Verbose(1) << "End of ParseOrderAtSiteFromFile" << endl; 807 800 return status; 808 801 }; … … 821 814 int SP, Removal; 822 815 823 DoLog(2) && (Log() << Verbose(2) << "Looking for removal candidate." << endl);816 Log() << Verbose(2) << "Looking for removal candidate." << endl; 824 817 SP = -1; //0; // not -1, so that Root is never removed 825 818 Removal = -1; … … 848 841 849 842 Leaf->BondDistance = mol->BondDistance; 843 for(int i=NDIM*2;i--;) 844 Leaf->cell_size[i] = mol->cell_size[i]; 850 845 851 846 // first create the minimal set of atoms from the KeySet … … 906 901 } 907 902 } else { 908 DoeLog(1) && (eLog()<< Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl);903 eLog() << Verbose(1) << "Son " << Runner->Name << " has father " << FatherOfRunner->Name << " but its entry in SonList is " << SonList[FatherOfRunner->nr] << "!" << endl; 909 904 } 910 905 if ((LonelyFlag) && (Leaf->AtomCount > 1)) { 911 DoLog(0) && (Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl);906 Log() << Verbose(0) << *Runner << "has got bonds only to hydrogens!" << endl; 912 907 } 913 908 #ifdef ADDHYDROGEN … … 1056 1051 TouchedList[j] = -1; 1057 1052 } 1058 DoLog(2) && (Log() << Verbose(2) << "Remaining local nr.s on snake stack are: ");1053 Log() << Verbose(2) << "Remaining local nr.s on snake stack are: "; 1059 1054 for(KeySet::iterator runner = FragmentSet->begin(); runner != FragmentSet->end(); runner++) 1060 DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");1061 DoLog(0) && (Log() << Verbose(0) << endl);1055 Log() << Verbose(0) << (*runner) << " "; 1056 Log() << Verbose(0) << endl; 1062 1057 TouchedIndex = 0; // set Index to 0 for list of atoms added on this level 1063 1058 }; … … 1136 1131 Log() << Verbose(1+verbosity) << "Enough items on stack for a fragment!" << endl; 1137 1132 // store fragment as a KeySet 1138 DoLog(2) && (Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: ");1133 Log() << Verbose(2) << "Found a new fragment[" << FragmentSearch->FragmentCounter << "], local nr.s are: "; 1139 1134 for(KeySet::iterator runner = FragmentSearch->FragmentSet->begin(); runner != FragmentSearch->FragmentSet->end(); runner++) 1140 DoLog(0) && (Log() << Verbose(0) << (*runner) << " ");1141 DoLog(0) && (Log() << Verbose(0) << endl);1135 Log() << Verbose(0) << (*runner) << " "; 1136 Log() << Verbose(0) << endl; 1142 1137 //if (!CheckForConnectedSubgraph(FragmentSearch->FragmentSet)) 1143 // DoeLog(1) && (eLog()<< Verbose(1) << "The found fragment is not a connected subgraph!" << endl);1138 //eLog() << Verbose(1) << "The found fragment is not a connected subgraph!" << endl; 1144 1139 InsertFragmentIntoGraph(FragmentSearch); 1145 1140 } … … 1221 1216 { 1222 1217 bond *Binder = NULL; 1223 DoLog(0) && (Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl);1218 Log() << Verbose(0) << "Free'ing all found lists. and resetting index lists" << endl; 1224 1219 for(int i=Order;i--;) { 1225 DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << ": ");1220 Log() << Verbose(1) << "Current SP level is " << i << ": "; 1226 1221 Binder = FragmentSearch.BondsPerSPList[2*i]; 1227 1222 while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) { … … 1234 1229 cleanup(FragmentSearch.BondsPerSPList[2*i], FragmentSearch.BondsPerSPList[2*i+1]); 1235 1230 // also start and end node 1236 DoLog(0) && (Log() << Verbose(0) << "cleaned." << endl);1231 Log() << Verbose(0) << "cleaned." << endl; 1237 1232 } 1238 1233 }; … … 1264 1259 int SP = -1; 1265 1260 1266 DoLog(0) && (Log() << Verbose(0) << "Starting BFS analysis ..." << endl);1261 Log() << Verbose(0) << "Starting BFS analysis ..." << endl; 1267 1262 for (SP = 0; SP < (Order-1); SP++) { 1268 DoLog(1) && (Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)");1263 Log() << Verbose(1) << "New SP level reached: " << SP << ", creating new SP list with " << FragmentSearch.BondsPerSPCount[SP] << " item(s)"; 1269 1264 if (SP > 0) { 1270 DoLog(0) && (Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl);1265 Log() << Verbose(0) << ", old level closed with " << FragmentSearch.BondsPerSPCount[SP-1] << " item(s)." << endl; 1271 1266 FragmentSearch.BondsPerSPCount[SP] = 0; 1272 1267 } else 1273 DoLog(0) && (Log() << Verbose(0) << "." << endl);1268 Log() << Verbose(0) << "." << endl; 1274 1269 1275 1270 RemainingWalkers = FragmentSearch.BondsPerSPCount[SP]; … … 1281 1276 Predecessor = CurrentEdge->leftatom; // ... and leftatom is predecessor 1282 1277 AtomKeyNr = Walker->nr; 1283 DoLog(0) && (Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl);1278 Log() << Verbose(0) << "Current Walker is: " << *Walker << " with nr " << Walker->nr << " and SP of " << SP << ", with " << RemainingWalkers << " remaining walkers on this level." << endl; 1284 1279 // check for new sp level 1285 1280 // go through all its bonds 1286 DoLog(1) && (Log() << Verbose(1) << "Going through all bonds of Walker." << endl);1281 Log() << Verbose(1) << "Going through all bonds of Walker." << endl; 1287 1282 for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) { 1288 1283 OtherWalker = (*Runner)->GetOtherAtom(Walker); … … 1292 1287 #endif 1293 1288 ) { // skip hydrogens and restrict to fragment 1294 DoLog(2) && (Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl);1289 Log() << Verbose(2) << "Current partner is " << *OtherWalker << " with nr " << OtherWalker->nr << " in bond " << *(*Runner) << "." << endl; 1295 1290 // set the label if not set (and push on root stack as well) 1296 1291 if ((OtherWalker != Predecessor) && (OtherWalker->GetTrueFather()->nr > RootKeyNr)) { // only pass through those with label bigger than Root's 1297 1292 FragmentSearch.ShortestPathList[OtherWalker->nr] = SP+1; 1298 DoLog(3) && (Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl);1293 Log() << Verbose(3) << "Set Shortest Path to " << FragmentSearch.ShortestPathList[OtherWalker->nr] << "." << endl; 1299 1294 // add the bond in between to the SP list 1300 1295 Binder = new bond(Walker, OtherWalker); // create a new bond in such a manner, that bond::rightatom is always the one more distant 1301 1296 add(Binder, FragmentSearch.BondsPerSPList[2*(SP+1)+1]); 1302 1297 FragmentSearch.BondsPerSPCount[SP+1]++; 1303 DoLog(3) && (Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl);1298 Log() << Verbose(3) << "Added its bond to SP list, having now " << FragmentSearch.BondsPerSPCount[SP+1] << " item(s)." << endl; 1304 1299 } else { 1305 1300 if (OtherWalker != Predecessor) 1306 DoLog(3) && (Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl);1301 Log() << Verbose(3) << "Not passing on, as index of " << *OtherWalker << " " << OtherWalker->GetTrueFather()->nr << " is smaller than that of Root " << RootKeyNr << "." << endl; 1307 1302 else 1308 DoLog(3) && (Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl);1303 Log() << Verbose(3) << "This is my predecessor " << *Predecessor << "." << endl; 1309 1304 } 1310 1305 } else Log() << Verbose(2) << "Is not in the restricted keyset or skipping hydrogen " << *OtherWalker << "." << endl; … … 1322 1317 { 1323 1318 bond *Binder = NULL; 1324 DoLog(0) && (Log() << Verbose(0) << "Printing all found lists." << endl);1319 Log() << Verbose(0) << "Printing all found lists." << endl; 1325 1320 for(int i=1;i<Order;i++) { // skip the root edge in the printing 1326 1321 Binder = FragmentSearch.BondsPerSPList[2*i]; 1327 DoLog(1) && (Log() << Verbose(1) << "Current SP level is " << i << "." << endl);1322 Log() << Verbose(1) << "Current SP level is " << i << "." << endl; 1328 1323 while (Binder->next != FragmentSearch.BondsPerSPList[2*i+1]) { 1329 1324 Binder = Binder->next; 1330 DoLog(2) && (Log() << Verbose(2) << *Binder << endl);1325 Log() << Verbose(2) << *Binder << endl; 1331 1326 } 1332 1327 } … … 1372 1367 int Counter = FragmentSearch.FragmentCounter; // mark current value of counter 1373 1368 1374 DoLog(0) && (Log() << Verbose(0) << endl);1375 DoLog(0) && (Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl);1369 Log() << Verbose(0) << endl; 1370 Log() << Verbose(0) << "Begin of PowerSetGenerator with order " << Order << " at Root " << *FragmentSearch.Root << "." << endl; 1376 1371 1377 1372 SetSPList(Order, FragmentSearch); … … 1385 1380 // creating fragments with the found edge sets (may be done in reverse order, faster) 1386 1381 int SP = CountNumbersInBondsList(Order, FragmentSearch); 1387 DoLog(0) && (Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl);1382 Log() << Verbose(0) << "Total number of edges is " << SP << "." << endl; 1388 1383 if (SP >= (Order-1)) { 1389 1384 // start with root (push on fragment stack) 1390 DoLog(0) && (Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl);1385 Log() << Verbose(0) << "Starting fragment generation with " << *FragmentSearch.Root << ", local nr is " << FragmentSearch.Root->nr << "." << endl; 1391 1386 FragmentSearch.FragmentSet->clear(); 1392 DoLog(0) && (Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl);1387 Log() << Verbose(0) << "Preparing subset for this root and calling generator." << endl; 1393 1388 1394 1389 // prepare the subset and call the generator … … 1400 1395 Free(&BondsList); 1401 1396 } else { 1402 DoLog(0) && (Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl);1397 Log() << Verbose(0) << "Not enough total number of edges to build " << Order << "-body fragments." << endl; 1403 1398 } 1404 1399 1405 1400 // as FragmentSearch structure is used only once, we don't have to clean it anymore 1406 1401 // remove root from stack 1407 DoLog(0) && (Log() << Verbose(0) << "Removing root again from stack." << endl);1402 Log() << Verbose(0) << "Removing root again from stack." << endl; 1408 1403 FragmentSearch.FragmentSet->erase(FragmentSearch.Root->nr); 1409 1404 … … 1412 1407 1413 1408 // return list 1414 DoLog(0) && (Log() << Verbose(0) << "End of PowerSetGenerator." << endl);1409 Log() << Verbose(0) << "End of PowerSetGenerator." << endl; 1415 1410 return (FragmentSearch.FragmentCounter - Counter); 1416 1411 }; … … 1458 1453 atom *Walker = NULL; 1459 1454 1460 DoLog(0) && (Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl);1455 Log() << Verbose(0) << "Combining the lists of all orders per order and finally into a single one." << endl; 1461 1456 if (FragmentList == NULL) { 1462 1457 FragmentList = new Graph; … … 1491 1486 void FreeAllOrdersList(Graph ***FragmentLowerOrdersList, KeyStack &RootStack, molecule *mol) 1492 1487 { 1493 DoLog(1) && (Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl);1488 Log() << Verbose(1) << "Free'ing the lists of all orders per order." << endl; 1494 1489 int RootNr = 0; 1495 1490 int RootKeyNr = 0; … … 1544 1539 struct UniqueFragments FragmentSearch; 1545 1540 1546 DoLog(0) && (Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl);1541 Log() << Verbose(0) << "Begin of FragmentBOSSANOVA." << endl; 1547 1542 1548 1543 // FragmentLowerOrdersList is a 2D-array of pointer to MoleculeListClass objects, one dimension represents the ANOVA expansion of a single order (i.e. 5) … … 1594 1589 1595 1590 // create top order where nothing is reduced 1596 DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);1597 DoLog(0) && (Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl); // , NumLevels is " << NumLevels << "1591 Log() << Verbose(0) << "==============================================================================================================" << endl; 1592 Log() << Verbose(0) << "Creating KeySets of Bond Order " << Order << " for " << *Walker << ", " << (RootStack.size()-RootNr) << " Roots remaining." << endl; // , NumLevels is " << NumLevels << " 1598 1593 1599 1594 // Create list of Graphs of current Bond Order (i.e. F_{ij}) … … 1605 1600 1606 1601 // output resulting number 1607 DoLog(1) && (Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl);1602 Log() << Verbose(1) << "Number of resulting KeySets is: " << NumMoleculesOfOrder[RootNr] << "." << endl; 1608 1603 if (NumMoleculesOfOrder[RootNr] != 0) { 1609 1604 NumMolecules = 0; … … 1622 1617 } 1623 1618 } 1624 DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);1625 DoLog(1) && (Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl);1626 DoLog(0) && (Log() << Verbose(0) << "==============================================================================================================" << endl);1619 Log() << Verbose(0) << "==============================================================================================================" << endl; 1620 Log() << Verbose(1) << "Total number of resulting molecules is: " << TotalNumMolecules << "." << endl; 1621 Log() << Verbose(0) << "==============================================================================================================" << endl; 1627 1622 1628 1623 // cleanup FragmentSearch structure … … 1642 1637 Free(&NumMoleculesOfOrder); 1643 1638 1644 DoLog(0) && (Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl);1639 Log() << Verbose(0) << "End of FragmentBOSSANOVA." << endl; 1645 1640 }; 1646 1641 … … 1657 1652 atom *Walker = NULL; 1658 1653 atom *OtherWalker = NULL; 1659 double * const cell_size = World::get()->cell_size;1660 1654 double *matrix = ReturnFullMatrixforSymmetric(cell_size); 1661 1655 enum Shading *ColorList = NULL; … … 1666 1660 bool flag = true; 1667 1661 1668 DoLog(2) && (Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl);1662 Log() << Verbose(2) << "Begin of ScanForPeriodicCorrection." << endl; 1669 1663 1670 1664 ColorList = Calloc<enum Shading>(AtomCount, "molecule::ScanForPeriodicCorrection: *ColorList"); … … 1684 1678 OtherBinder = Binder->next; // note down binding partner for later re-insertion 1685 1679 unlink(Binder); // unlink bond 1686 DoLog(2) && (Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl);1680 Log() << Verbose(2) << "Correcting at bond " << *Binder << "." << endl; 1687 1681 flag = true; 1688 1682 break; … … 1700 1694 //Log() << Verbose(3) << "Translation vector is "; 1701 1695 Translationvector.Output(); 1702 DoLog(0) && (Log() << Verbose(0) << endl);1696 Log() << Verbose(0) << endl; 1703 1697 // apply to all atoms of first component via BFS 1704 1698 for (int i=AtomCount;i--;) … … 1722 1716 link(Binder, OtherBinder); 1723 1717 } else { 1724 DoLog(3) && (Log() << Verbose(3) << "No corrections for this fragment." << endl);1718 Log() << Verbose(3) << "No corrections for this fragment." << endl; 1725 1719 } 1726 1720 //delete(CompStack); … … 1731 1725 Free(&ColorList); 1732 1726 Free(&matrix); 1733 DoLog(2) && (Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl);1734 }; 1727 Log() << Verbose(2) << "End of ScanForPeriodicCorrection." << endl; 1728 };
Note:
See TracChangeset
for help on using the changeset viewer.
