17 #include <utility/exit.hh>
18 #include <numeric/random/random.hh>
19 #include <basic/options/option.hh>
20 #include <basic/options/keys/OptionKeys.hh>
21 #include <basic/options/keys/fingerprint.OptionKeys.gen.hh>
22 #include <basic/database/open.hh>
28 #include <ObjexxFCL/format.hh>
30 #include <utility/vector1.hh>
32 static numeric::random::RandomGenerator
my_RG(6172108);
37 using namespace ObjexxFCL::fmt;
43 using namespace core::optimization;
45 Size const N = particles.size();
46 ligand_natoms_ = pfp_.compute_ligand_natoms();
48 for (
Size j = 1; j <=
N; ++j) {
51 origin_offset.x() = vars[1];
52 origin_offset.y() = vars[2];
53 origin_offset.z() = vars[3];
55 fill_atom_arrays_(j-1, ligand_rsd );
62 int actual_atom_array_size = ligand_natoms_ *
N;
63 nfp_.gpu_.WriteData(nfp_.gpu_atoms_, nfp_.atom_,
sizeof(*nfp_.atom_) * actual_atom_array_size);
65 if(!nfp_.gpu_.ExecuteKernel(
"Check_for_intersection", nfp_.gpu_num_rays_, 256, 64, NULL)) {
66 std::cout <<
"Failed to launch kernel: " << nfp_.gpu_.lastErrorStr() << std::endl;
70 if(!nfp_.gpu_.ExecuteKernel(
"Get_scores", N, 256, 64, NULL)) {
71 std::cout <<
"Failed to launch kernel: " << nfp_.gpu_.lastErrorStr() << std::endl;
75 nfp_.gpu_.ReadData(nfp_.particle_scores_, nfp_.gpu_particle_scores_,
sizeof(*nfp_.particle_scores_) * N);
78 core::Real particle_score = nfp_.particle_scores_[j];
79 particles[j+1]->set_score(particle_score);
87 core::Real particle_score = DarcPSO_fp_compare_( j-1, missing_pt_, steric_, extra_pt_ );
88 particles[j]->set_score(particle_score);
99 using namespace basic::options;
100 core::Real const radius_scale = option[ OptionKeys::fingerprint::atom_radius_scale ];
101 core::Real const atom_buffer = option[ OptionKeys::fingerprint::atom_radius_buffer ];
103 for (
Size i = 1; i <= ligand_natoms_; ++i) {
105 core::Size const curr_array_inx = ( ligand_natoms_ * particle_inx ) + ( i-1 );
108 core::Real const this_atom_radius = ( ligand_rsd->atom_type(i).lj_radius() - atom_buffer ) * radius_scale;
109 nfp_.atom_[curr_array_inx].x = this_atomcoors.x();
110 nfp_.atom_[curr_array_inx].y = this_atomcoors.y();
111 nfp_.atom_[curr_array_inx].z = this_atomcoors.z();
112 nfp_.atom_[curr_array_inx].w = this_atom_radius;
118 core::Real const tmp_atomx=this_atomcoors.x();
119 core::Real const tmp_atomy=this_atomcoors.y();
120 core::Real const tmp_atomz=this_atomcoors.z();
124 if ( std::abs(tmp_atomz) > 0.00001 ) {
125 core::Real const inside_phi_asin = this_atom_radius / tmp_atomz;
126 if ( std::abs(inside_phi_asin) < 1. ) {
127 core::Real const max_angular_displacement_phi = std::abs( asin( inside_phi_asin ) );
128 curr_max_phi = atom_center.
phi + max_angular_displacement_phi;
129 curr_min_phi = atom_center.
phi - max_angular_displacement_phi;
135 if ( ( std::abs(tmp_atomx) > 0.00001 ) || ( std::abs(tmp_atomx) > 0.00001 ) ) {
136 core::Real const inside_psi_asin = this_atom_radius / sqrt( (tmp_atomx*tmp_atomx) + (tmp_atomy*tmp_atomy) );
137 if ( std::abs(inside_psi_asin) < 1. ) {
138 core::Real const max_angular_displacement_psi = std::abs( asin( inside_psi_asin ) );
139 curr_max_psi = atom_center.
psi + max_angular_displacement_psi;
140 curr_min_psi = atom_center.
psi - max_angular_displacement_psi;
144 if ( curr_max_phi > nfp_.ligand_maxmin_phipsi_[particle_inx].x ) nfp_.ligand_maxmin_phipsi_[particle_inx].x = curr_max_phi;
145 if ( curr_max_psi > nfp_.ligand_maxmin_phipsi_[particle_inx].y ) nfp_.ligand_maxmin_phipsi_[particle_inx].y = curr_max_psi;
146 if ( curr_min_phi < nfp_.ligand_maxmin_phipsi_[particle_inx].z ) nfp_.ligand_maxmin_phipsi_[particle_inx].z = curr_min_phi;
147 if ( curr_min_psi < nfp_.ligand_maxmin_phipsi_[particle_inx].w ) nfp_.ligand_maxmin_phipsi_[particle_inx].w = curr_min_psi;
148 nfp_.atom_maxmin_phipsi_[curr_array_inx].x = curr_max_phi;
149 nfp_.atom_maxmin_phipsi_[curr_array_inx].y = curr_max_psi;
150 nfp_.atom_maxmin_phipsi_[curr_array_inx].z = curr_min_phi;
151 nfp_.atom_maxmin_phipsi_[curr_array_inx].w = curr_min_psi;
162 for (std::list<spherical_coor_triplet>::const_iterator ni = nfp_.triplet_fingerprint_data().begin(); ni != nfp_.triplet_fingerprint_data().end(); ++ni) {
168 for (
Size i = 1, i_end = ligand_natoms_; i <= i_end; ++i) {
170 core::Size const curr_array_inx = ( ligand_natoms_ * particle_inx ) + ( i-1 );
172 if ( nfp_.atom_[curr_array_inx].w < 0.001 )
continue;
174 while ( curr_phi < nfp_.atom_maxmin_phipsi_[curr_array_inx].z ) {
175 curr_phi += numeric::constants::r::pi_2;
177 while ( curr_phi > nfp_.atom_maxmin_phipsi_[curr_array_inx].x ) {
178 curr_phi -= numeric::constants::r::pi_2;
180 while ( curr_psi < nfp_.atom_maxmin_phipsi_[curr_array_inx].w ) {
181 curr_psi += numeric::constants::r::pi_2;
183 while ( curr_psi > nfp_.atom_maxmin_phipsi_[curr_array_inx].y ) {
184 curr_psi -= numeric::constants::r::pi_2;
186 if ( curr_phi < nfp_.atom_maxmin_phipsi_[curr_array_inx].z )
continue;
187 if ( curr_psi < nfp_.atom_maxmin_phipsi_[curr_array_inx].w )
continue;
188 if ( curr_phi > nfp_.atom_maxmin_phipsi_[curr_array_inx].x )
continue;
189 if ( curr_psi > nfp_.atom_maxmin_phipsi_[curr_array_inx].y )
continue;
191 core::Real const min_intersect_SQ =
Find_Closest_Intersect_SQ(curr_phi,curr_psi,nfp_.atom_[curr_array_inx].x,nfp_.atom_[curr_array_inx].y,nfp_.atom_[curr_array_inx].z,nfp_.atom_[curr_array_inx].w);
193 if ( min_intersect_SQ < best_rho_sq ) {
194 best_rho_sq = min_intersect_SQ;
199 if ( best_rho_sq < 9998. ) {
200 plaid_rho = sqrt(best_rho_sq);
203 if ( (plaid_rho > 9998.) && (ni->rho > 0.001) ) {
204 Total_score += missing_point_weight;
207 if ( (plaid_rho < 9999.) && (ni->rho < 0.001 ) ) {
208 Total_score += extra_point_weight;
211 if ( (plaid_rho < 9999.) && (ni->rho > 0.001 ) ) {
212 core::Real dist_deviation = ( plaid_rho - ni->rho );
213 if (dist_deviation < 0.0) dist_deviation = ( ni->rho - plaid_rho ) * steric_weight;
214 Total_score += dist_deviation;
219 return (Total_score/num_rays);