| [a3427f] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
|  | 4 | * Copyright (C)  2013 University of Bonn. All rights reserved. | 
|---|
| [5aaa43] | 5 | * Copyright (C)  2013 Frederik Heber. All rights reserved. | 
|---|
| [a3427f] | 6 | * | 
|---|
|  | 7 | * | 
|---|
|  | 8 | *   This file is part of MoleCuilder. | 
|---|
|  | 9 | * | 
|---|
|  | 10 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
|  | 11 | *    it under the terms of the GNU General Public License as published by | 
|---|
|  | 12 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
|  | 13 | *    (at your option) any later version. | 
|---|
|  | 14 | * | 
|---|
|  | 15 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
|  | 16 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 17 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 18 | *    GNU General Public License for more details. | 
|---|
|  | 19 | * | 
|---|
|  | 20 | *    You should have received a copy of the GNU General Public License | 
|---|
|  | 21 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
|  | 22 | */ | 
|---|
|  | 23 |  | 
|---|
|  | 24 | /* | 
|---|
|  | 25 | * AnalyseFragmentationResultsAction.cpp | 
|---|
|  | 26 | * | 
|---|
|  | 27 | *  Created on: Mar 8, 2013 | 
|---|
|  | 28 | *      Author: heber | 
|---|
|  | 29 | */ | 
|---|
|  | 30 |  | 
|---|
|  | 31 | // include config.h | 
|---|
|  | 32 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 33 | #include <config.h> | 
|---|
|  | 34 | #endif | 
|---|
|  | 35 |  | 
|---|
|  | 36 | // include headers that implement a archive in simple text format | 
|---|
|  | 37 | // and before MemDebug due to placement new | 
|---|
|  | 38 | #include <boost/archive/text_oarchive.hpp> | 
|---|
|  | 39 | #include <boost/archive/text_iarchive.hpp> | 
|---|
|  | 40 |  | 
|---|
|  | 41 | #include "CodePatterns/MemDebug.hpp" | 
|---|
|  | 42 |  | 
|---|
|  | 43 | #include <boost/mpl/remove.hpp> | 
|---|
|  | 44 |  | 
|---|
|  | 45 | #include <vector> | 
|---|
|  | 46 | #include <fstream> | 
|---|
|  | 47 | #include <iostream> | 
|---|
|  | 48 | #include <string> | 
|---|
|  | 49 | #include <vector> | 
|---|
|  | 50 |  | 
|---|
|  | 51 | #include "CodePatterns/Assert.hpp" | 
|---|
|  | 52 | #include "CodePatterns/Log.hpp" | 
|---|
|  | 53 |  | 
|---|
|  | 54 | #ifdef HAVE_JOBMARKET | 
|---|
|  | 55 | #include "JobMarket/types.hpp" | 
|---|
|  | 56 | #else | 
|---|
|  | 57 | typedef size_t JobId_t; | 
|---|
|  | 58 | #endif | 
|---|
|  | 59 |  | 
|---|
|  | 60 | #include "Fragmentation/Summation/Containers/FragmentationChargeDensity.hpp" | 
|---|
|  | 61 | #include "Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp" | 
|---|
|  | 62 | #include "Fragmentation/Summation/Containers/FragmentationResultContainer.hpp" | 
|---|
|  | 63 | #include "Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp" | 
|---|
|  | 64 | #include "Fragmentation/Summation/Containers/MPQCData.hpp" | 
|---|
|  | 65 | #include "Fragmentation/Summation/Containers/MPQCData_printKeyNames.hpp" | 
|---|
|  | 66 | #include "Fragmentation/Homology/HomologyContainer.hpp" | 
|---|
|  | 67 | #include "Fragmentation/Homology/HomologyGraph.hpp" | 
|---|
|  | 68 | #include "Fragmentation/KeySetsContainer.hpp" | 
|---|
| [5c867e] | 69 | #include "Fragmentation/Summation/SetValues/Eigenvalues.hpp" | 
|---|
| [a3427f] | 70 | #include "Fragmentation/Summation/SetValues/Fragment.hpp" | 
|---|
|  | 71 | #include "Fragmentation/Summation/SetValues/Histogram.hpp" | 
|---|
|  | 72 | #include "Fragmentation/Summation/SetValues/IndexedVectors.hpp" | 
|---|
|  | 73 | #include "Fragmentation/Summation/IndexSetContainer.hpp" | 
|---|
|  | 74 | #include "Fragmentation/Summation/writeTable.hpp" | 
|---|
|  | 75 | #ifdef HAVE_VMG | 
|---|
|  | 76 | #include "Fragmentation/Summation/Containers/VMGData.hpp" | 
|---|
|  | 77 | #include "Fragmentation/Summation/Containers/VMGDataFused.hpp" | 
|---|
|  | 78 | #include "Fragmentation/Summation/Containers/VMGDataMap.hpp" | 
|---|
|  | 79 | #include "Fragmentation/Summation/Containers/VMGData_printKeyNames.hpp" | 
|---|
|  | 80 | #endif | 
|---|
|  | 81 | #include "World.hpp" | 
|---|
|  | 82 |  | 
|---|
|  | 83 | #include "Actions/FragmentationAction/AnalyseFragmentationResultsAction.hpp" | 
|---|
|  | 84 |  | 
|---|
|  | 85 | using namespace MoleCuilder; | 
|---|
|  | 86 |  | 
|---|
|  | 87 | // and construct the stuff | 
|---|
|  | 88 | #include "AnalyseFragmentationResultsAction.def" | 
|---|
|  | 89 | #include "Action_impl_pre.hpp" | 
|---|
|  | 90 | /** =========== define the function ====================== */ | 
|---|
|  | 91 |  | 
|---|
|  | 92 | void writeToFile(const std::string &filename, const std::string contents) | 
|---|
|  | 93 | { | 
|---|
|  | 94 | std::ofstream tablefile(filename.c_str()); | 
|---|
|  | 95 | tablefile << contents; | 
|---|
|  | 96 | tablefile.close(); | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
|  | 99 | /** Print (short range) energy, forces, and timings from received results. | 
|---|
|  | 100 | * | 
|---|
|  | 101 | * @param results summed up results container | 
|---|
|  | 102 | */ | 
|---|
|  | 103 | void printReceivedShortResults( | 
|---|
|  | 104 | const FragmentationShortRangeResults &results) | 
|---|
|  | 105 | { | 
|---|
|  | 106 | // print tables (without eigenvalues, they go extra) | 
|---|
|  | 107 | { | 
|---|
| [5c867e] | 108 | typedef boost::mpl::remove< | 
|---|
|  | 109 | boost::mpl::remove<MPQCDataEnergyVector_t, MPQCDataFused::energy_eigenvalues>::type, | 
|---|
|  | 110 | MPQCDataFused::energy_eigenhistogram>::type | 
|---|
| [a3427f] | 111 | MPQCDataEnergyVector_noeigenvalues_t; | 
|---|
|  | 112 | const std::string energyresult = | 
|---|
|  | 113 | writeTable<MPQCDataEnergyMap_t, MPQCDataEnergyVector_noeigenvalues_t >()( | 
|---|
|  | 114 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 115 | LOG(2, "DEBUG: Energy table is \n" << energyresult); | 
|---|
| [a3427f] | 116 | std::string filename; | 
|---|
|  | 117 | filename += FRAGMENTPREFIX + std::string("_Energy.dat"); | 
|---|
|  | 118 | writeToFile(filename, energyresult); | 
|---|
|  | 119 | } | 
|---|
|  | 120 |  | 
|---|
| [5c867e] | 121 | { | 
|---|
|  | 122 | typedef boost::mpl::list< | 
|---|
|  | 123 | MPQCDataFused::energy_eigenvalues | 
|---|
|  | 124 | > MPQCDataEigenvalues_t; | 
|---|
|  | 125 | const std::string eigenvalueresult = | 
|---|
|  | 126 | writeTable<MPQCDataEnergyMap_t, MPQCDataEigenvalues_t >()( | 
|---|
|  | 127 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 128 | LOG(2, "DEBUG: Eigenvalue table is \n" << eigenvalueresult); | 
|---|
| [5c867e] | 129 | std::string filename; | 
|---|
|  | 130 | filename += FRAGMENTPREFIX + std::string("_Eigenvalues.dat"); | 
|---|
|  | 131 | writeToFile(filename, eigenvalueresult); | 
|---|
|  | 132 | } | 
|---|
|  | 133 |  | 
|---|
|  | 134 | { | 
|---|
|  | 135 | typedef boost::mpl::list< | 
|---|
|  | 136 | MPQCDataFused::energy_eigenhistogram | 
|---|
|  | 137 | > MPQCDataEigenhistogram_t; | 
|---|
|  | 138 | const std::string eigenhistogramresult = | 
|---|
|  | 139 | writeTable<MPQCDataEnergyMap_t, MPQCDataEigenhistogram_t >()( | 
|---|
|  | 140 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 141 | LOG(2, "DEBUG: Eigenhistogram table is \n" << eigenhistogramresult); | 
|---|
| [5c867e] | 142 | std::string filename; | 
|---|
|  | 143 | filename += FRAGMENTPREFIX + std::string("_Eigenhistogram.dat"); | 
|---|
|  | 144 | writeToFile(filename, eigenhistogramresult); | 
|---|
|  | 145 | } | 
|---|
|  | 146 |  | 
|---|
| [a3427f] | 147 | { | 
|---|
|  | 148 | typedef boost::mpl::list< | 
|---|
|  | 149 | MPQCDataFused::energy_eigenvalues | 
|---|
|  | 150 | > MPQCDataEigenvalues_t; | 
|---|
|  | 151 | const std::string eigenvalueresult = | 
|---|
|  | 152 | writeTable<MPQCDataEnergyMap_t, MPQCDataEigenvalues_t >()( | 
|---|
|  | 153 | results.Result_Energy_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 154 | LOG(2, "DEBUG: Eigenvalue table is \n" << eigenvalueresult); | 
|---|
| [a3427f] | 155 | std::string filename; | 
|---|
|  | 156 | filename += FRAGMENTPREFIX + std::string("_Eigenvalues.dat"); | 
|---|
|  | 157 | writeToFile(filename, eigenvalueresult); | 
|---|
|  | 158 | } | 
|---|
|  | 159 |  | 
|---|
|  | 160 | { | 
|---|
|  | 161 | const std::string forceresult = | 
|---|
|  | 162 | writeTable<MPQCDataForceMap_t, MPQCDataForceVector_t>()( | 
|---|
|  | 163 | results.Result_Force_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 164 | LOG(2, "DEBUG: Force table is \n" << forceresult); | 
|---|
| [a3427f] | 165 | std::string filename; | 
|---|
|  | 166 | filename += FRAGMENTPREFIX + std::string("_Forces.dat"); | 
|---|
|  | 167 | writeToFile(filename, forceresult); | 
|---|
|  | 168 | } | 
|---|
|  | 169 | // we don't want to print grid to a table | 
|---|
|  | 170 | { | 
|---|
|  | 171 | // print times (without flops for now) | 
|---|
|  | 172 | typedef boost::mpl::remove< | 
|---|
|  | 173 | boost::mpl::remove<MPQCDataTimeVector_t, MPQCDataFused::times_total_flops>::type, | 
|---|
|  | 174 | MPQCDataFused::times_gather_flops>::type | 
|---|
|  | 175 | MPQCDataTimeVector_noflops_t; | 
|---|
|  | 176 | const std::string timesresult = | 
|---|
|  | 177 | writeTable<MPQCDataTimeMap_t, MPQCDataTimeVector_noflops_t >()( | 
|---|
|  | 178 | results.Result_Time_fused, results.getMaxLevel()); | 
|---|
| [1b5a40] | 179 | LOG(2, "DEBUG: Times table is \n" << timesresult); | 
|---|
| [a3427f] | 180 | std::string filename; | 
|---|
|  | 181 | filename += FRAGMENTPREFIX + std::string("_Times.dat"); | 
|---|
|  | 182 | writeToFile(filename, timesresult); | 
|---|
|  | 183 | } | 
|---|
|  | 184 | } | 
|---|
|  | 185 |  | 
|---|
|  | 186 |  | 
|---|
|  | 187 | /** Print long range energy from received results. | 
|---|
|  | 188 | * | 
|---|
|  | 189 | * @param results summed up results container | 
|---|
|  | 190 | */ | 
|---|
|  | 191 | void printReceivedFullResults( | 
|---|
|  | 192 | const FragmentationLongRangeResults &results) | 
|---|
|  | 193 | { | 
|---|
|  | 194 | // print tables (without eigenvalues, they go extra) | 
|---|
|  | 195 |  | 
|---|
|  | 196 | if (results.Result_LongRange_fused.size() >= (results.getMaxLevel()-2)) | 
|---|
|  | 197 | { | 
|---|
|  | 198 | const std::string gridresult = | 
|---|
|  | 199 | writeTable<VMGDataMap_t, VMGDataVector_t >()( | 
|---|
|  | 200 | results.Result_LongRange_fused, results.getMaxLevel(), 2); | 
|---|
| [1b5a40] | 201 | LOG(2, "DEBUG: VMG table is \n" << gridresult); | 
|---|
| [a3427f] | 202 | std::string filename; | 
|---|
|  | 203 | filename += FRAGMENTPREFIX + std::string("_VMGEnergy.dat"); | 
|---|
|  | 204 | writeToFile(filename, gridresult); | 
|---|
|  | 205 | } | 
|---|
|  | 206 |  | 
|---|
|  | 207 | if (results.Result_LongRangeIntegrated_fused.size() >= (results.getMaxLevel()-2)) | 
|---|
|  | 208 | { | 
|---|
|  | 209 | const std::string gridresult = | 
|---|
|  | 210 | writeTable<VMGDataLongRangeMap_t, VMGDataLongRangeVector_t >()( | 
|---|
|  | 211 | results.Result_LongRangeIntegrated_fused, results.getMaxLevel(), 2); | 
|---|
| [1b5a40] | 212 | LOG(2, "DEBUG: LongRange table is \n" << gridresult); | 
|---|
| [a3427f] | 213 | std::string filename; | 
|---|
|  | 214 | filename += FRAGMENTPREFIX + std::string("_LongRangeEnergy.dat"); | 
|---|
|  | 215 | writeToFile(filename, gridresult); | 
|---|
|  | 216 | } | 
|---|
|  | 217 | } | 
|---|
|  | 218 |  | 
|---|
|  | 219 | bool appendToHomologyFile( | 
|---|
|  | 220 | const boost::filesystem::path &homology_file, | 
|---|
|  | 221 | const FragmentationShortRangeResults &shortrangeresults, | 
|---|
|  | 222 | const FragmentationLongRangeResults &longrangeresults | 
|---|
|  | 223 | ) | 
|---|
|  | 224 | { | 
|---|
|  | 225 | /// read homology container (if present) | 
|---|
|  | 226 | HomologyContainer homology_container; | 
|---|
|  | 227 | if (boost::filesystem::exists(homology_file)) { | 
|---|
|  | 228 | std::ifstream returnstream(homology_file.string().c_str()); | 
|---|
|  | 229 | if (returnstream.good()) { | 
|---|
|  | 230 | boost::archive::text_iarchive ia(returnstream); | 
|---|
|  | 231 | ia >> homology_container; | 
|---|
|  | 232 | } else { | 
|---|
|  | 233 | ELOG(2, "Failed to parse from " << homology_file.string() << "."); | 
|---|
|  | 234 | } | 
|---|
|  | 235 | returnstream.close(); | 
|---|
|  | 236 | } else { | 
|---|
|  | 237 | LOG(2, "Could not open " << homology_file.string() | 
|---|
|  | 238 | << ", creating empty container."); | 
|---|
|  | 239 | } | 
|---|
|  | 240 |  | 
|---|
|  | 241 | /// append all fragments to a HomologyContainer | 
|---|
|  | 242 | HomologyContainer::container_t values; | 
|---|
|  | 243 |  | 
|---|
|  | 244 | // convert KeySetContainer to IndexSetContainer | 
|---|
|  | 245 | IndexSetContainer::ptr ForceContainer(new IndexSetContainer(shortrangeresults.getForceKeySet())); | 
|---|
|  | 246 | const IndexSetContainer::Container_t &Indices = shortrangeresults.getContainer(); | 
|---|
|  | 247 | const IndexSetContainer::Container_t &ForceIndices = ForceContainer->getContainer(); | 
|---|
|  | 248 | IndexSetContainer::Container_t::const_iterator iter = Indices.begin(); | 
|---|
|  | 249 | IndexSetContainer::Container_t::const_iterator forceiter = ForceIndices.begin(); | 
|---|
|  | 250 | /// go through all fragments | 
|---|
|  | 251 | for (;iter != Indices.end(); ++iter, ++forceiter) // go through each IndexSet | 
|---|
|  | 252 | { | 
|---|
|  | 253 | /// create new graph entry in HomologyContainer which is (key,value) type | 
|---|
|  | 254 | LOG(1, "INFO: Creating new graph with " << **forceiter << "."); | 
|---|
|  | 255 | HomologyGraph graph(**forceiter); | 
|---|
|  | 256 | LOG(2, "DEBUG: Created graph " << graph << "."); | 
|---|
|  | 257 | const IndexSet::ptr &index = *iter; | 
|---|
|  | 258 | HomologyContainer::value_t value; | 
|---|
|  | 259 |  | 
|---|
|  | 260 | // obtain fragment as key | 
|---|
|  | 261 | std::map<IndexSet::ptr, std::pair< MPQCDataFragmentMap_t, MPQCDataFragmentMap_t> >::const_iterator fragmentiter | 
|---|
|  | 262 | = longrangeresults.Result_perIndexSet_Fragment.find(index); | 
|---|
|  | 263 | ASSERT( fragmentiter != longrangeresults.Result_perIndexSet_Fragment.end(), | 
|---|
|  | 264 | "appendToHomologyFile() - cannot find index "+toString(*index) | 
|---|
|  | 265 | +" in FragmentResults."); | 
|---|
|  | 266 | value.first = boost::fusion::at_key<MPQCDataFused::fragment>(fragmentiter->second.first); | 
|---|
|  | 267 |  | 
|---|
|  | 268 | // obtain energy as value | 
|---|
|  | 269 | std::map<IndexSet::ptr, std::pair< MPQCDataEnergyMap_t, MPQCDataEnergyMap_t> >::const_iterator energyiter | 
|---|
|  | 270 | = shortrangeresults.Result_perIndexSet_Energy.find(index); | 
|---|
|  | 271 | ASSERT( energyiter != shortrangeresults.Result_perIndexSet_Energy.end(), | 
|---|
|  | 272 | "appendToHomologyFile() - cannot find index "+toString(*index) | 
|---|
|  | 273 | +" in FragmentResults."); | 
|---|
|  | 274 | // value.second = boost::fusion::at_key<MPQCDataFused::energy_total>(energyiter->second.first); // values | 
|---|
|  | 275 | value.second = boost::fusion::at_key<MPQCDataFused::energy_total>(energyiter->second.second); // contributions | 
|---|
|  | 276 | values.insert( std::make_pair( graph, value) ); | 
|---|
|  | 277 | } | 
|---|
|  | 278 | homology_container.insert(values); | 
|---|
|  | 279 |  | 
|---|
| [1b5a40] | 280 | if (DoLog(2)) { | 
|---|
|  | 281 | LOG(2, "DEBUG: Listing all present atomic ids ..."); | 
|---|
|  | 282 | std::stringstream output; | 
|---|
|  | 283 | for (World::AtomIterator iter = World::getInstance().getAtomIter(); | 
|---|
|  | 284 | iter != World::getInstance().atomEnd(); ++iter) | 
|---|
|  | 285 | output << (*iter)->getId() << " "; | 
|---|
|  | 286 | LOG(2, "DEBUG: { " << output.str() << "} ."); | 
|---|
|  | 287 | } | 
|---|
| [a3427f] | 288 |  | 
|---|
|  | 289 | // for debugging: print container | 
|---|
| [1b5a40] | 290 | if (DoLog(2)) { | 
|---|
|  | 291 | LOG(2, "DEBUG: Listing all present homologies ..."); | 
|---|
|  | 292 | for (HomologyContainer::container_t::const_iterator iter = | 
|---|
|  | 293 | homology_container.begin(); iter != homology_container.end(); ++iter) { | 
|---|
|  | 294 | LOG(2, "DEBUG: graph " << iter->first << " has Fragment " | 
|---|
|  | 295 | << iter->second.first << " and associated energy " << iter->second.second << "."); | 
|---|
|  | 296 | } | 
|---|
| [a3427f] | 297 | } | 
|---|
|  | 298 |  | 
|---|
|  | 299 | /// store homology container again | 
|---|
|  | 300 | std::ofstream outputstream(homology_file.string().c_str()); | 
|---|
|  | 301 | if (outputstream.good()) { // check if opened | 
|---|
|  | 302 | boost::archive::text_oarchive oa(outputstream); | 
|---|
|  | 303 | oa << homology_container; | 
|---|
|  | 304 | if (outputstream.fail()) { // check if correctly written | 
|---|
|  | 305 | LOG(1, "Failed to write to file " << homology_file.string() << "."); | 
|---|
|  | 306 | return false; | 
|---|
|  | 307 | } else | 
|---|
|  | 308 | outputstream.close(); | 
|---|
|  | 309 | } else { | 
|---|
|  | 310 | LOG(1, "Failed to open file " << homology_file.string() | 
|---|
|  | 311 | << " for writing."); | 
|---|
|  | 312 | return false; | 
|---|
|  | 313 | } | 
|---|
|  | 314 | return true; | 
|---|
|  | 315 | } | 
|---|
|  | 316 |  | 
|---|
|  | 317 | Action::state_ptr FragmentationAnalyseFragmentationResultsAction::performCall() { | 
|---|
|  | 318 |  | 
|---|
| [55e1bc] | 319 | // if file is given, parse from file into resultscontainer | 
|---|
| [a3427f] | 320 | FragmentationResultContainer& container = FragmentationResultContainer::getInstance(); | 
|---|
| [55e1bc] | 321 | if (!params.resultsfile.get().empty()) { | 
|---|
|  | 322 | boost::filesystem::path resultsfile = params.resultsfile.get(); | 
|---|
|  | 323 | if (boost::filesystem::exists(resultsfile)) { | 
|---|
|  | 324 | LOG(1, "INFO: Parsing results from " << resultsfile.string() << "."); | 
|---|
|  | 325 | std::ifstream returnstream(resultsfile.string().c_str()); | 
|---|
|  | 326 | if (returnstream.good()) { | 
|---|
|  | 327 | boost::archive::text_iarchive ia(returnstream); | 
|---|
|  | 328 | ia >> container; | 
|---|
|  | 329 | } | 
|---|
|  | 330 | } else { | 
|---|
|  | 331 | ELOG(1, "Given file" << resultsfile.string() << " does not exist."); | 
|---|
|  | 332 | } | 
|---|
|  | 333 | } | 
|---|
|  | 334 |  | 
|---|
|  | 335 | // get data and keysets from ResultsContainer | 
|---|
| [a3427f] | 336 | const std::map<JobId_t, MPQCData> &shortrangedata = container.getShortRangeResults(); | 
|---|
|  | 337 | const KeySetsContainer &keysets = container.getKeySets(); | 
|---|
|  | 338 | const KeySetsContainer &forcekeysets = container.getForceKeySets(); | 
|---|
|  | 339 | const bool DoLongrange = container.areFullRangeResultsPresent(); | 
|---|
|  | 340 |  | 
|---|
| [55e1bc] | 341 | if (keysets.KeySets.empty()) { | 
|---|
|  | 342 | ELOG(2, "There are no results in the container."); | 
|---|
|  | 343 | return Action::failure; | 
|---|
|  | 344 | } | 
|---|
|  | 345 |  | 
|---|
| [a3427f] | 346 | FragmentationShortRangeResults shortrangeresults(shortrangedata, keysets, forcekeysets); | 
|---|
|  | 347 | shortrangeresults(shortrangedata); | 
|---|
|  | 348 | printReceivedShortResults(shortrangeresults); | 
|---|
|  | 349 |  | 
|---|
|  | 350 | #ifdef HAVE_VMG | 
|---|
|  | 351 | if (DoLongrange) { | 
|---|
|  | 352 | if ( World::getInstance().getAllAtoms().size() == 0) { | 
|---|
|  | 353 | ELOG(1, "Please load the full molecule into the world before starting this action."); | 
|---|
|  | 354 | return Action::failure; | 
|---|
|  | 355 | } | 
|---|
|  | 356 |  | 
|---|
|  | 357 | FragmentationChargeDensity summedChargeDensity(shortrangedata,keysets); | 
|---|
|  | 358 | const std::vector<SamplingGrid> full_sample = summedChargeDensity.getFullSampledGrid(); | 
|---|
|  | 359 |  | 
|---|
|  | 360 | std::map<JobId_t, VMGData> longrangeData = container.getLongRangeResults(); | 
|---|
|  | 361 | // remove full solution corresponding to full_sample from map (must be highest ids), has to be treated extra | 
|---|
|  | 362 | std::map<JobId_t, VMGData>::iterator iter = longrangeData.end(); | 
|---|
|  | 363 | for (size_t i=0;i<full_sample.size();++i) | 
|---|
|  | 364 | --iter; | 
|---|
|  | 365 | std::map<JobId_t, VMGData>::iterator remove_iter = iter; | 
|---|
|  | 366 | std::vector<VMGData> fullsolutionData; | 
|---|
|  | 367 | for (; iter != longrangeData.end(); ++iter) | 
|---|
|  | 368 | fullsolutionData.push_back(iter->second); | 
|---|
|  | 369 | longrangeData.erase(remove_iter, longrangeData.end()); | 
|---|
|  | 370 |  | 
|---|
|  | 371 | // Final phase: sum up and print result | 
|---|
|  | 372 | FragmentationLongRangeResults longrangeresults( | 
|---|
|  | 373 | shortrangedata,longrangeData,keysets, forcekeysets); | 
|---|
|  | 374 | longrangeresults( | 
|---|
|  | 375 | shortrangedata, | 
|---|
|  | 376 | longrangeData, | 
|---|
|  | 377 | fullsolutionData, | 
|---|
|  | 378 | full_sample); | 
|---|
|  | 379 | printReceivedFullResults(longrangeresults); | 
|---|
|  | 380 |  | 
|---|
|  | 381 | // append all keysets to homology file | 
|---|
|  | 382 | if (!params.homology_file.get().empty()) { | 
|---|
|  | 383 | const boost::filesystem::path &homology_file = params.homology_file.get(); | 
|---|
|  | 384 | if (homology_file.string() != "") { | 
|---|
|  | 385 | LOG(1, "INFO: Appending HomologyGraphs to file " << homology_file.string() << "."); | 
|---|
|  | 386 | if (!appendToHomologyFile(homology_file, shortrangeresults, longrangeresults)) | 
|---|
|  | 387 | return Action::failure; | 
|---|
|  | 388 | } | 
|---|
|  | 389 | } | 
|---|
|  | 390 | } | 
|---|
| [e2925fd] | 391 | #else | 
|---|
|  | 392 | if (DoLongrange) | 
|---|
|  | 393 | ELOG(2, "File contains long-range information but long-range analysis capability not compiled in."); | 
|---|
| [a3427f] | 394 | #endif | 
|---|
|  | 395 |  | 
|---|
|  | 396 | container.clear(); | 
|---|
|  | 397 |  | 
|---|
|  | 398 | return Action::success; | 
|---|
|  | 399 | } | 
|---|
|  | 400 |  | 
|---|
|  | 401 | Action::state_ptr FragmentationAnalyseFragmentationResultsAction::performUndo(Action::state_ptr _state) { | 
|---|
|  | 402 | return Action::success; | 
|---|
|  | 403 | } | 
|---|
|  | 404 |  | 
|---|
|  | 405 | Action::state_ptr FragmentationAnalyseFragmentationResultsAction::performRedo(Action::state_ptr _state){ | 
|---|
|  | 406 | return Action::success; | 
|---|
|  | 407 | } | 
|---|
|  | 408 |  | 
|---|
|  | 409 | bool FragmentationAnalyseFragmentationResultsAction::canUndo() { | 
|---|
|  | 410 | return false; | 
|---|
|  | 411 | } | 
|---|
|  | 412 |  | 
|---|
|  | 413 | bool FragmentationAnalyseFragmentationResultsAction::shouldUndo() { | 
|---|
|  | 414 | return false; | 
|---|
|  | 415 | } | 
|---|
|  | 416 | /** =========== end of function ====================== */ | 
|---|