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