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