File size: 5,458 Bytes
35aaa09 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
/**
* @file boinc_wrapper.h
* @brief BOINC integration wrapper for Docking@HOME
*
* This header provides the interface for integrating AutoDock molecular docking
* tasks with the BOINC distributed computing framework.
*
* @authors OpenPeer AI, Riemann Computing Inc., Bleunomics, Andrew Magdy Kamal
* @version 1.0.0
* @date 2025
*/
#ifndef DOCKING_AT_HOME_BOINC_WRAPPER_H
#define DOCKING_AT_HOME_BOINC_WRAPPER_H
#include <string>
#include <vector>
#include <memory>
#include "boinc_api.h"
#include "boinc_zip.h"
namespace docking_at_home {
namespace boinc {
/**
* @struct DockingTask
* @brief Represents a molecular docking task
*/
struct DockingTask {
std::string task_id;
std::string ligand_file;
std::string receptor_file;
std::string grid_parameter_file;
std::string docking_parameter_file;
int num_runs;
int num_evals;
std::string output_dir;
bool use_gpu;
int gpu_device_id;
};
/**
* @struct DockingResult
* @brief Contains results from a docking computation
*/
struct DockingResult {
std::string task_id;
std::vector<double> binding_energies;
std::vector<std::string> conformations;
double best_binding_energy;
std::string best_conformation;
int successful_runs;
double computation_time;
std::string worker_id;
};
/**
* @class BOINCWrapper
* @brief Main wrapper class for BOINC integration
*/
class BOINCWrapper {
public:
BOINCWrapper();
~BOINCWrapper();
/**
* @brief Initialize BOINC client
* @return true if initialization successful
*/
bool initialize();
/**
* @brief Register the application with BOINC server
* @param app_name Name of the application
* @param version Application version
* @return true if registration successful
*/
bool register_application(const std::string& app_name, const std::string& version);
/**
* @brief Submit a docking task to the BOINC network
* @param task The docking task to submit
* @return Task ID if successful, empty string otherwise
*/
std::string submit_task(const DockingTask& task);
/**
* @brief Process a docking task (called by BOINC client)
* @param task The task to process
* @param result Output parameter for results
* @return true if processing successful
*/
bool process_task(const DockingTask& task, DockingResult& result);
/**
* @brief Check progress of a task
* @param task_id The ID of the task to check
* @return Progress percentage (0-100)
*/
double get_task_progress(const std::string& task_id);
/**
* @brief Retrieve results for a completed task
* @param task_id The ID of the task
* @param result Output parameter for results
* @return true if results retrieved successfully
*/
bool get_task_results(const std::string& task_id, DockingResult& result);
/**
* @brief Update progress to BOINC framework
* @param fraction_done Fraction of work completed (0.0 - 1.0)
*/
void update_progress(double fraction_done);
/**
* @brief Report CPU time used
* @param cpu_time CPU time in seconds
*/
void report_cpu_time(double cpu_time);
/**
* @brief Handle checkpoint creation
* @param checkpoint_file Path to checkpoint file
* @return true if checkpoint created successfully
*/
bool create_checkpoint(const std::string& checkpoint_file);
/**
* @brief Restore from checkpoint
* @param checkpoint_file Path to checkpoint file
* @return true if restore successful
*/
bool restore_checkpoint(const std::string& checkpoint_file);
/**
* @brief Finalize BOINC operations
*/
void finalize();
private:
bool is_initialized_;
std::string app_name_;
std::string worker_id_;
// Helper methods
bool validate_task(const DockingTask& task);
std::string generate_task_id();
bool upload_input_files(const DockingTask& task);
bool download_output_files(const std::string& task_id);
};
/**
* @class BOINCServer
* @brief Server-side BOINC integration for work unit generation
*/
class BOINCServer {
public:
BOINCServer();
~BOINCServer();
/**
* @brief Initialize BOINC server
* @param config_file Path to BOINC server configuration
* @return true if initialization successful
*/
bool initialize(const std::string& config_file);
/**
* @brief Create work units from docking tasks
* @param tasks Vector of docking tasks
* @return Number of work units created
*/
int create_work_units(const std::vector<DockingTask>& tasks);
/**
* @brief Process validated results
* @param result_file Path to result file
* @return true if processing successful
*/
bool process_result(const std::string& result_file);
/**
* @brief Get server statistics
* @return Statistics as JSON string
*/
std::string get_statistics();
private:
bool is_initialized_;
std::string db_host_;
std::string db_name_;
int active_work_units_;
int completed_work_units_;
};
} // namespace boinc
} // namespace docking_at_home
#endif // DOCKING_AT_HOME_BOINC_WRAPPER_H
|