| /** | |
| * @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 | |
| */ | |
| 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 | |