|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DOCKING_AT_HOME_AUTODOCK_GPU_CUH
|
|
|
#define DOCKING_AT_HOME_AUTODOCK_GPU_CUH
|
|
|
|
|
|
#include <cuda_runtime.h>
|
|
|
#include <cudpp.h>
|
|
|
#include <vector>
|
|
|
#include <string>
|
|
|
|
|
|
namespace docking_at_home {
|
|
|
namespace autodock {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Atom {
|
|
|
float x, y, z;
|
|
|
int type;
|
|
|
float charge;
|
|
|
float radius;
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Ligand {
|
|
|
std::vector<Atom> atoms;
|
|
|
int num_rotatable_bonds;
|
|
|
float center_x, center_y, center_z;
|
|
|
std::string name;
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Receptor {
|
|
|
std::vector<Atom> atoms;
|
|
|
float grid_min_x, grid_min_y, grid_min_z;
|
|
|
float grid_max_x, grid_max_y, grid_max_z;
|
|
|
float grid_spacing;
|
|
|
std::string name;
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct DockingParameters {
|
|
|
int num_runs;
|
|
|
int num_evals;
|
|
|
int population_size;
|
|
|
float rmsd_tolerance;
|
|
|
int max_generations;
|
|
|
float mutation_rate;
|
|
|
float crossover_rate;
|
|
|
bool use_local_search;
|
|
|
int num_threads_per_block;
|
|
|
int num_blocks;
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct DockingPose {
|
|
|
float translation[3];
|
|
|
float rotation[4];
|
|
|
std::vector<float> torsions;
|
|
|
float binding_energy;
|
|
|
float intermolecular_energy;
|
|
|
float internal_energy;
|
|
|
float torsional_energy;
|
|
|
float rank;
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AutoDockGPU {
|
|
|
public:
|
|
|
AutoDockGPU();
|
|
|
~AutoDockGPU();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool initialize(int device_id = 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool load_ligand(const std::string& filename, Ligand& ligand);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool load_receptor(const std::string& filename, Receptor& receptor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool dock(const Ligand& ligand,
|
|
|
const Receptor& receptor,
|
|
|
const DockingParameters& params,
|
|
|
std::vector<DockingPose>& poses);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string get_device_info();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string get_performance_metrics();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cleanup();
|
|
|
|
|
|
private:
|
|
|
bool is_initialized_;
|
|
|
int device_id_;
|
|
|
cudaDeviceProp device_prop_;
|
|
|
CUDPPHandle cudpp_handle_;
|
|
|
|
|
|
|
|
|
Atom* d_ligand_atoms_;
|
|
|
Atom* d_receptor_atoms_;
|
|
|
float* d_energy_grid_;
|
|
|
float* d_population_;
|
|
|
float* d_energies_;
|
|
|
|
|
|
|
|
|
size_t ligand_atoms_size_;
|
|
|
size_t receptor_atoms_size_;
|
|
|
|
|
|
|
|
|
float total_computation_time_;
|
|
|
int total_evaluations_;
|
|
|
|
|
|
|
|
|
bool allocate_device_memory(const Ligand& ligand, const Receptor& receptor);
|
|
|
bool transfer_to_device(const Ligand& ligand, const Receptor& receptor);
|
|
|
bool compute_energy_grid(const Receptor& receptor);
|
|
|
bool run_genetic_algorithm(const DockingParameters& params,
|
|
|
std::vector<DockingPose>& poses);
|
|
|
bool cluster_results(std::vector<DockingPose>& poses, float rmsd_tolerance);
|
|
|
void free_device_memory();
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__global__ void calculate_energy_kernel(
|
|
|
const Atom* ligand_atoms,
|
|
|
const Atom* receptor_atoms,
|
|
|
int num_ligand_atoms,
|
|
|
int num_receptor_atoms,
|
|
|
float* energies
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__global__ void evaluate_population_kernel(
|
|
|
const float* population,
|
|
|
const Atom* ligand_atoms,
|
|
|
const Atom* receptor_atoms,
|
|
|
const float* energy_grid,
|
|
|
float* fitness_values,
|
|
|
int population_size,
|
|
|
int num_genes
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__global__ void crossover_kernel(
|
|
|
float* population,
|
|
|
const float* parent_indices,
|
|
|
float crossover_rate,
|
|
|
int population_size,
|
|
|
int num_genes,
|
|
|
unsigned long long seed
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__global__ void mutation_kernel(
|
|
|
float* population,
|
|
|
float mutation_rate,
|
|
|
int population_size,
|
|
|
int num_genes,
|
|
|
unsigned long long seed
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__global__ void local_search_kernel(
|
|
|
float* population,
|
|
|
const float* energy_grid,
|
|
|
float* fitness_values,
|
|
|
int population_size,
|
|
|
int num_genes,
|
|
|
int num_iterations
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__global__ void rmsd_kernel(
|
|
|
const DockingPose* poses,
|
|
|
float* rmsd_matrix,
|
|
|
int num_poses
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool sort_poses_by_energy(DockingPose* d_poses, int num_poses, CUDPPHandle cudpp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool find_min_energy(const float* d_energies, int num_energies,
|
|
|
float& min_energy, CUDPPHandle cudpp);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|