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